Postado Novembro 14, 2018 6 anos Bom dia, estou com uma duvida em um script, ja tentei colocar quantidade do item, mas nao estou conseguindo fazer funcionar. Alguém pode me ajudar? ? Ex. TFS 0.4; function onUse(cid, item, fromPos, item2, count, toPos) local _ = { [1] = {aid = 1234, item = 2160,25}, -- Aqui gostaria de colocar a quantidade 25 e colocar mais de um item em um unico bau. [2] = {aid = 1235, item = 2195}, [3] = {aid = 1231, item = 3121}, } for i = 1, #_ do _.storage = 202049 + i end for i, valor in ipairs(_) do if item.actionid == valor.aid then if getPlayerFreeCap(cid) >= getItemWeightById(valor.item, 1) then if getPlayerStorageValue(cid, valor.storage) == -1 then if doPlayerAddItem(cid, valor.item, 1, false) then doPlayerSendTextMessage(cid, 22, 'You have found a '..getItemNameById(valor.item)..'.') setPlayerStorageValue(cid, valor.storage, 1) else doPlayerSendTextMessage(cid, 22, 'You have found a '..getItemNameById(valor.item)..', but you need a free slot.') end else doPlayerSendTextMessage(cid, 22, 'It is empty.') end else doPlayerSendTextMessage(cid, 22, 'You have found a '..getItemNameById(valor.item)..'. It weighs '..getItemWeightById(valor.item, 1)..'.00 and it is too heavy.') end break end end return true end Gostaria de colocar mais de um item no bau e quantidade, mas manter esse esquema de script pois iria facilitar muito organizar as quests do meu servidor. Obrigado! Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui.
Postado Novembro 14, 2018 6 anos function onUse(cid, item, fromPos, item2, count, toPos) local config = { [1] = {aid = 1234, item = 2160, quant = 25}, -- Aqui gostaria de colocar a quantidade 25 e colocar mais de um item em um unico bau. [2] = {aid = 1235, item = 2195, quant = 1}, [3] = {aid = 1231, item = 3121, quant = 1} } for i = 1, #config do config.storage = 202049 + i end for i, valor in ipairs(config) do if item.actionid == valor.aid then if getPlayerFreeCap(cid) >= getItemWeightById(valor.item, valor.quant) then if getPlayerStorageValue(cid, valor.storage) <= 0 then if doPlayerAddItem(cid, valor.item, valor.quant, false) then doPlayerSendTextMessage(cid, 22, 'You have found a '..valor.quant..' '..getItemNameById(valor.item)..'.') setPlayerStorageValue(cid, valor.storage, 1) else doPlayerSendTextMessage(cid, 22, 'You have found a '..valor.quant..' '..getItemNameById(valor.item)..', but you need a free slot.') end else doPlayerSendTextMessage(cid, 22, 'It is empty.') end else doPlayerSendTextMessage(cid, 22, 'You have found a '..valor.quant..' '..getItemNameById(valor.item)..'. It weighs '..getItemWeightById(valor.item, valor.quant)..'.00 and it is too heavy.') end end end return true end Editado Novembro 14, 2018 6 anos por luanluciano93 (veja o histórico de edições)
Postado Novembro 14, 2018 6 anos Autor Mas e se eu quiser por mais de um item no mesmo bau, como exemplo uma MPA e um MMS no mesmo bau? E muito obrigado.
Postado Novembro 14, 2018 6 anos @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)
Postado Novembro 14, 2018 6 anos @tataboy67 Se me permite, nesta parte: for i = 1, #v.reward do doPlayerAddItem(cid, i[1], i[2]) end Deveria ser: for i = 1, #v.reward do doPlayerAddItem(cid, v.reward[i][1], v.reward[i][2]) end não?
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.