Postado Dezembro 8, 2020 4 anos Alguém poderia arrumar esse script para mim? toda vez que o player usar ele não é removido do mesmo... TF 0,4 Serv 8,6 local items = { {itemId = 12779, count = 1, chance = 1}, {itemId = 12780, count = 2, chance = 99}, } local broadcastitems = {2361} function onUse(cid, item, frompos, item2, topos) local totalChance, randomTable, randomNumber = 0, {}, 0 for _, itemInfo in pairs (items) do randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1} totalChance = totalChance + itemInfo.chance end randomNumber = math.random(1, totalChance) for itemId, itemInfo in pairs (randomTable) do local min, max = itemInfo.min, itemInfo.min + itemInfo.max if randomNumber >= min and randomNumber <= max then local newItem = doPlayerAddItem(cid, itemId, qntItemsByPercnt(), false) if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end doRemoveItem(item.uid, 1) local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0} doSendMagicEffect(pos, 442) -- Id do efeito. local iInfo = getItemInfo(itemId) doPlayerSendTextMessage(cid, 19, "Voce ganhou "..iInfo.name.."") for i, broaditem in ipairs(broadcastitems) do if itemId==broaditem then doBroadcastMessage(getCreatureName(cid).." acabou de ganhar "..iInfo.name.." (Raro) na senzu box.", 19) end end break end end return true end A random quando o player usar ela não remove, quando o player usar e sai o item "raro" a função RemoveItem(item.uid, 1) funciona, alguém poderia resolver? rep+
Postado Dezembro 8, 2020 4 anos 16 horas atrás, XGaduX disse: Alguém poderia arrumar esse script para mim? toda vez que o player usar ele não é removido do mesmo... TF 0,4 Serv 8,6 local items = { {itemId = 12779, count = 1, chance = 1}, {itemId = 12780, count = 2, chance = 99}, } local broadcastitems = {2361} function onUse(cid, item, frompos, item2, topos) local totalChance, randomTable, randomNumber = 0, {}, 0 for _, itemInfo in pairs (items) do randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1} totalChance = totalChance + itemInfo.chance end randomNumber = math.random(1, totalChance) for itemId, itemInfo in pairs (randomTable) do local min, max = itemInfo.min, itemInfo.min + itemInfo.max if randomNumber >= min and randomNumber <= max then local newItem = doPlayerAddItem(cid, itemId, qntItemsByPercnt(), false) if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end doRemoveItem(item.uid, 1) local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0} doSendMagicEffect(pos, 442) -- Id do efeito. local iInfo = getItemInfo(itemId) doPlayerSendTextMessage(cid, 19, "Voce ganhou "..iInfo.name.."") for i, broaditem in ipairs(broadcastitems) do if itemId==broaditem then doBroadcastMessage(getCreatureName(cid).." acabou de ganhar "..iInfo.name.." (Raro) na senzu box.", 19) end end break end end return true end Expand A random quando o player usar ela não remove, quando o player usar e sai o item "raro" a função RemoveItem(item.uid, 1) funciona, alguém poderia resolver? rep+ Testa ai: Spoiler local items = { {itemId = 12779, count = 1, chance = 1}, {itemId = 12780, count = 2, chance = 99}, } local broadcastitems = {2361} function onUse(cid, item, frompos, item2, topos) local totalChance, randomTable, randomNumber = 0, {}, 0 for _, itemInfo in pairs (items) do randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1} totalChance = totalChance + itemInfo.chance end randomNumber = math.random(1, totalChance) for itemId, itemInfo in pairs (randomTable) do local min, max = itemInfo.min, itemInfo.min + itemInfo.max if randomNumber >= min and randomNumber <= max then local newItem = doPlayerAddItem(cid, itemId, qntItemsByPercnt(), false) if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end doRemoveItem(item.uid, 1) local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0} doSendMagicEffect(pos, 442) -- Id do efeito. local iInfo = getItemInfo(itemId) doPlayerSendTextMessage(cid, 19, "Voce ganhou "..iInfo.name.."") doRemoveItem(item.uid, 1) for i, broaditem in ipairs(broadcastitems) do if itemId==broaditem then doBroadcastMessage(getCreatureName(cid).." acabou de ganhar "..iInfo.name.." (Raro) na senzu box.", 19) end doRemoveItem(item.uid, 1) end break end end return true end
Postado Dezembro 10, 2020 4 anos Autor Em 08/12/2020 em 17:21, Nysman disse: Testa ai: Ocultar conteúdo local items = { {itemId = 12779, count = 1, chance = 1}, {itemId = 12780, count = 2, chance = 99}, } local broadcastitems = {2361} function onUse(cid, item, frompos, item2, topos) local totalChance, randomTable, randomNumber = 0, {}, 0 for _, itemInfo in pairs (items) do randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1} totalChance = totalChance + itemInfo.chance end randomNumber = math.random(1, totalChance) for itemId, itemInfo in pairs (randomTable) do local min, max = itemInfo.min, itemInfo.min + itemInfo.max if randomNumber >= min and randomNumber <= max then local newItem = doPlayerAddItem(cid, itemId, qntItemsByPercnt(), false) if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end doRemoveItem(item.uid, 1) local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0} doSendMagicEffect(pos, 442) -- Id do efeito. local iInfo = getItemInfo(itemId) doPlayerSendTextMessage(cid, 19, "Voce ganhou "..iInfo.name.."") doRemoveItem(item.uid, 1) for i, broaditem in ipairs(broadcastitems) do if itemId==broaditem then doBroadcastMessage(getCreatureName(cid).." acabou de ganhar "..iInfo.name.." (Raro) na senzu box.", 19) end doRemoveItem(item.uid, 1) end break end end return true end Funciona ela remove, mas se vc tive acima de 4 box ao clicar os 4 boxs somem e se clicar muito rápido não some. [10:3:14.080] [Error - Action Interface] [10:3:14.082] data/actions/scripts/senzubox/senzumystic.lua:onUse [10:3:14.083] Description: [10:3:14.083] (luaDoRemoveItem) Item not found Editado Dezembro 10, 2020 4 anos por XGaduX (veja o histórico de edições)
Postado Dezembro 10, 2020 4 anos Erro meu, agr funciona perfeito: Spoiler local items = { {itemId = 12779, count = 1, chance = 1}, {itemId = 12780, count = 2, chance = 99}, } local broadcastitems = {2361} function onUse(cid, item, frompos, item2, topos) local totalChance, randomTable, randomNumber = 0, {}, 0 for _, itemInfo in pairs (items) do randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1} totalChance = totalChance + itemInfo.chance end randomNumber = math.random(1, totalChance) for itemId, itemInfo in pairs (randomTable) do local min, max = itemInfo.min, itemInfo.min + itemInfo.max if randomNumber >= min and randomNumber <= max then local newItem = doPlayerAddItem(cid, itemId, qntItemsByPercnt(), false) if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0} doSendMagicEffect(pos, 442) -- Id do efeito. local iInfo = getItemInfo(itemId) doPlayerSendTextMessage(cid, 19, "Voce ganhou "..iInfo.name.."") for i, broaditem in ipairs(broadcastitems) do if itemId==broaditem then doBroadcastMessage(getCreatureName(cid).." acabou de ganhar "..iInfo.name.." (Raro) na senzu box.", 19) end end doRemoveItem(item.uid, 1) return true end break end end return true end Editado Dezembro 10, 2020 4 anos por Nysman (veja o histórico de edições)
Postado Dezembro 10, 2020 4 anos local items = { {itemId = 12779, count = 1, chance = 1}, {itemId = 12780, count = 2, chance = 99}, } local broadcastitems = {2361} function onUse(cid, item, frompos, item2, topos) local totalChance, randomTable, randomNumber = 0, {}, 0 for _, itemInfo in pairs (items) do randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1} totalChance = totalChance + itemInfo.chance end randomNumber = math.random(1, totalChance) for itemId, itemInfo in pairs (randomTable) do local min, max = itemInfo.min, itemInfo.min + itemInfo.max if randomNumber >= min and randomNumber <= max then local newItem = doPlayerAddItem(cid, itemId, qntItemsByPercnt(), false) if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0} doSendMagicEffect(pos, 442) -- Id do efeito. local iInfo = getItemInfo(itemId) doPlayerSendTextMessage(cid, 19, "Voce ganhou "..iInfo.name.."") for i, broaditem in ipairs(broadcastitems) do if itemId==broaditem then doBroadcastMessage(getCreatureName(cid).." acabou de ganhar "..iInfo.name.." (Raro) na senzu box.", 19) end end break end end doRemoveItem(item.uid) 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.