Postado Setembro 3, 2018 6 anos Olá comunidade, tenho esse script funciona para dar item por porcentagem ao utilizar um itemid, o script está funcionando perfeitamente só não remove o item ao dar use, podem me ajudar? local config = { [80] = {9693, 1}, [60] = {2157, 50}, [50] = {2157, 100}, [30] = {12435, 1}, [20] = {12614, 1}, [10] = {7477, 1}, [10] = {7439, 1}, [10] = {ID, COUNT}, [3] = {ID, COUNT}, [1] = {ID, COUNT}, } function onUse(cid, item) if getPlayerStorageValue(cid, STORAGE) > 0 then doRemoveItem(cid, item.itemid) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você já recebeu seu prêmio.") return false end local chance_growing = {} for chance, _ in pairs(config) do table.insert(chance_growing, chance) end table.sort(chance_growing, function(a, b) return a > b end) local chance = 0 for _, v in pairs(chance_growing) do if math.random(100) < v then chance = v break end end local item = config[chance] if item then doPlayerAddItem(cid, item[1], item[2]) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você encontrou ".. item[2] .." ".. item[1] .. ".") setPlayerStorageValue(cid, STORAGE, 1) doSendMagicEffect(getThingPos(cid), 13) else doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Não foi dessa vez, tente na próxima ):") end doRemoveItem(item.uid, 1) return true end erro na distro [3/9/2018 16:37:29] [Error - Action Interface] [3/9/2018 16:37:29] data/actions/scripts/dice.lua:onUse [3/9/2018 16:37:29] Description: [3/9/2018 16:37:29] (luaDoRemoveItem) Item not found “Enquanto nos derem ao menos 1% de chance, seguiremos lutando. E venceremos! Esse é o verdadeiro e único Clube da Fé! Vai São Paulo!”
Postado Setembro 3, 2018 6 anos Solução local config = { {chance = {from = 0, to = 30.5}, itemId = 123, count = 2}, {chance = {from = 30.5, to = 60}, itemId = 123, count = 2}, {chance = {from = 60, to = 100}, itemId = 123, count = 2}, } function onUse(cid, item) if getPlayerStorageValue(cid, STORAGE) > 0 then doRemoveItem(item.uid, 1) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você já recebeu seu prêmio.") return false end local chance = math.random(0, 10000) / 100 for i = 1, #config do local reward = config[i] if chance >= reward.chance.from and chance < reward.chance.to then doPlayerAddItem(cid, reward.itemId, reward.count) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você encontrou ".. reward.count .." ".. reward.itemId .. ".") setPlayerStorageValue(cid, STORAGE, 1) doSendMagicEffect(getThingPos(cid), 13) doRemoveItem(item.uid, 1) end end return true end
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.