Ir para conteúdo

Featured Replies

Postado
  • Autor
  Em 14/11/2018 em 16:05, tataboy67 disse:

@ghunalma 

local storageChests = 202049					-- Storage

local config = {

	[1] = {
		actionID = 1234,				-- ActionID Bau
		questName = "Hybrid Quest",			-- Nome da Quest
		levelNec = 400,					-- Nivel necessário
		reward = {						
			[1] = {2160, 10},			-- {ItemID, Count}
		}
	},

	[2] = {
		actionID = 1235,
		questName = "Afonso Quest",
		levelNec = 200,
		reward = {
			[1] = {2159, 15},
			[2] = {2160, 100},
		}
	},

}

for i = 1, #config do
	storageChests = storageChests + i
end

function onUse(cid, item, fromPos, item2, count, toPos)
	for k, v in ipairs(config) do
		if item.actionid == v.actionID then
			if storageChests >= 1 then
				doPlayerSendTextMessage(cid, 22, "You have completed this quest.")
				return true
			end

			if getPlayerLevel(cid) <= v.levelNec then
				doPlayerSendTextMessage(cid, 22, "You need a level "..v.levelNec..".")
				return true
			end
			
			for i = 1, #v.reward do
				doPlayerAddItem(cid, i[1], i[2])
			end
			setPlayerStorageValue(cid, storageChests, 1)
			doPlayerSendTextMessage(cid, 22, "Congratulations, you completed the quest: {"..v.questName.."}.")
		end
	end
end

Faça o teste amigo.

(Não testado)

 

Valeu, vou testar e jaja posto de funcionou. Obrigado.

Nao funcionou aqui amigo. Nem com a modificação do @lordzetros  citou. 

  • Respostas 14
  • Visualizações 1k
  • Created
  • Última resposta

Top Posters In This Topic

Postado
local storageChests = 202049					-- Storage

local config = {
	----------------------------------------
	{
		actionID = 1234,				-- ActionID Bau
		questName = "Hybrid Quest",			-- Nome da Quest
		levelNec = 400,					-- Nivel necessário
		reward = {						
			[1] = {2160, 10},			-- {ItemID, Count}
		}
	},
	----------------------------------------
	{
		actionID = 1235,
		questName = "Afonso Quest",
		levelNec = 200,
		reward = {
			[1] = {2159, 15},
			[2] = {2160, 100},
		}
	},
	----------------------------------------

}

function onUse(cid, item, fromPos, item2, toPos)
	for k, v in ipairs(config) do
		if item.actionid == v.actionID then
			if (getPlayerStorageValue(cid, (storageChests + k)) ~= -1) then
				doPlayerSendTextMessage(cid, 22, "You have completed this quest.")
				return true
			end

			if (getPlayerLevel(cid) <= v.levelNec) then
				doPlayerSendTextMessage(cid, 22, "You need a level "..v.levelNec..".")
				return true
			end
			
			for i = 1, #v.reward do
				doPlayerAddItem(cid, v.reward[i][1], v.reward[i][2])
			end
			setPlayerStorageValue(cid, storageChests + k, 1)
			doPlayerSendTextMessage(cid, 22, "Congratulations, you completed the quest: {"..v.questName.."}.")
		end
	end
end

Não cheguei a testar, mas dá um feedback depois, caso tenha dado algum problema. 

Editado por lordzetros (veja o histórico de edições)

Feliz daquele que ensina o que sabe, e aprende o que ensina.

 

               

star-wars-animated-gif-23.gif

Postado
  Em 15/11/2018 em 00:29, lordzetros disse:
local storageChests = 202049					-- Storage

local config = {
	----------------------------------------
	{
		actionID = 1234,				-- ActionID Bau
		questName = "Hybrid Quest",			-- Nome da Quest
		levelNec = 400,					-- Nivel necessário
		reward = {						
			[1] = {2160, 10},			-- {ItemID, Count}
		}
	},
	----------------------------------------
	{
		actionID = 1235,
		questName = "Afonso Quest",
		levelNec = 200,
		reward = {
			[1] = {2159, 15},
			[2] = {2160, 100},
		}
	},
	----------------------------------------

}

function onUse(cid, item, fromPos, item2, toPos)
	for k, v in ipairs(config) do
		if item.actionid == v.actionID then
			if (getPlayerStorageValue(cid, (storageChests + k)) ~= -1) then
				doPlayerSendTextMessage(cid, 22, "You have completed this quest.")
				return true
			end

			if (getPlayerLevel(cid) <= v.levelNec) then
				doPlayerSendTextMessage(cid, 22, "You need a level "..v.levelNec..".")
				return true
			end
			
			for i = 1, #v.reward do
				doPlayerAddItem(cid, v.reward[i][1], v.reward[i][2])
			end
			setPlayerStorageValue(cid, storageChests + k, 1)
			doPlayerSendTextMessage(cid, 22, "Congratulations, you completed the quest: {"..v.questName.."}.")
		end
	end
end

Não cheguei a testar, mas dá um feedback depois, caso tenha dado algum problema. 

 

Opa, se der algum problema vc concerta pra ele? acabei de fazer no corre aqui :/ 

Postado
local config = {
	[1234] = { -- ActionId do baú
		rewards {
			[1] = {itemId = 2160, amount = 25} -- Item ID e quantidade, por padrão quantidade é 1
		},
		storage = 213213
	},

	[1235] = {
		rewards = {
			[1] = {itemId = 2195}
		},
		storage = 213213
	},

	[1231] = {
		rewards = {
			[1] = {itemId = 3121}
		},
		storage = 213213
	}
}

function onUse(cid, item, fromPos, item2, count, toPos)
	local tmpConfig = config[item.actionid]
	if tmpConfig == nil then
		return false
	end

	if player:getStorageValue(tmpConfig.storage) > 0 then
		doPlayerSendTextMessage(cid, 22, 'It is empty.')
		return true
	end

	local weight = 0
	for i = 1, #tmpConfig.rewards do
		local reward = tmpConfig.rewards[i]
		local weightReward = getItemWeightById(reward.itemId, reward.amount or 1)
		weight = weight + weightReward
	end

	if getPlayerFreeCap(cid) < weight then
		doPlayerSendTextMessage(cid, 22, 'You have found a reward. It weighs '.. weight ..'.00 and it is too heavy.')
		return true
	end

	local backpack = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid
	local freeSlots = math.max(0, getContainerCap(backpack) - getContainerSize(backpack))
	if freeSlots < #tmpConfig.rewards then
		doPlayerSendTextMessage(cid, 22, 'You have found a reward, but you need a free slot.')
		return true
	end

	for i = 1, #tmpConfig.rewards do
		local reward = tmpConfig.rewards[i]
		doPlayerSendTextMessage(cid, 22, 'You have found a '.. getItemNameById(reward.itemId) ..'.')
		doPlayerAddItem(cid, reward.itemId, reward.amount or 1)
	end

	setPlayerStorageValue(cid, tmpConfig.storage, 1)
	return true
end

Testa aí, depois me fala... Eu não testei

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo