Postado Abril 28, 2016 9 anos Então, estou com um script de uma box que ao usar uma box vem um item aleatorio e a box some, mas não é oq ta acontecendo, a box não some e da pra continuar usando ela. Obs: Percebi que esse erro acontece só quando a box envolve porcentagem, no caso dessa ela tem porcentagem na chance de vir itens raros, que são porcentagens baixas. Eu tenho outro script mas essa vem item aleatório, sem porcentagem. Script: function onUse(cid, item, fromPosition, itemEx, toPosition) local rewarditems = { {id = 2492, chance = 5, count = 1}, -- start with the lowest chances {id = 2498, chance = 10, count = 1}, {id = 2488, chance = 15, count = 1}, {id = 2152, chance = 70, count = math.random(1, 50)} } local chance = math.random(1,100) for i = 1, #rewarditems, 1 do if(chance < rewarditems[i].chance) then local info = getItemInfo(rewarditems[i].id) if(rewarditems[i].count > 1) then text = rewarditems[i].count .. " " .. info.plural else text = info.article .. " " .. info.name end local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count) if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) text = "You have failed to open your mystery box. The item is to heavy or you have not enough space to take it." else text = "You have received " .. text .. "." doRemoveItem(item.uid, 1) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text) return true else chance = chance - rewarditems[i].chance end end end quando alguem usa a box da esse erro na distro: alguem pode me ajudar?
Postado Abril 28, 2016 9 anos Troque doRemoveItem(item.uid, 1) por doPlayerRemoveItem(cid, item.uid, 1) Não dou suporte via PM, crie um tópico caso tenha dúvidas. Isso previne que outras pessoas com a mesma dúvida criem tópicos desnecessários.
Postado Abril 28, 2016 9 anos Autor 29 minutos atrás, Talesigorvr disse: Troque doRemoveItem(item.uid, 1) por doPlayerRemoveItem(cid, item.uid, 1) Aparece o mesmo aviso, porem agora o erro é na linha 34, a msm linha em que substitui o que você me passou. Editado Abril 28, 2016 9 anos por Gruly (veja o histórico de edições)
Postado Abril 28, 2016 9 anos Passa o script inteiro, fui ver qual era a linha 26 e tentei achar o erro... Não dou suporte via PM, crie um tópico caso tenha dúvidas. Isso previne que outras pessoas com a mesma dúvida criem tópicos desnecessários.
Postado Abril 28, 2016 9 anos Autor 5 minutos atrás, Talesigorvr disse: Passa o script inteiro, fui ver qual era a linha 26 e tentei achar o erro... function onUse(cid, item, fromPosition, itemEx, toPosition) local rewarditems = { {id = 2472, chance = 17, count = 1}, -- start with the lowest chances {id = 2498, chance = 17, count = 1}, {id = 2645, chance = 17, count = 1}, {id = 2421, chance = 8, count = 1}, {id = 2514, chance = 13, count = 1}, -- start with the lowest chances {id = 2470, chance = 10, count = 1}, {id = 2646, chance = 5, count = 1}, {id = 2523, chance = 3, count = 1}, -- start with the lowest chances {id = 2522, chance = 4, count = 1}, {id = 2471, chance = 2, count = 1}, {id = 2496, chance = 2, count = 1}, {id = 8977, chance = 2, count = 1} } local chance = math.random(1,100) for i = 1, #rewarditems, 1 do if(chance < rewarditems[i].chance) then local info = getItemInfo(rewarditems[i].id) if(rewarditems[i].count > 1) then text = rewarditems[i].count .. " " .. info.plural else text = info.article .. " " .. info.name end local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count) if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) text = "You have failed to open your mystery box. The item is to heavy or you have not enough space to take it." else text = "You have received " .. text .. "." doRemoveItem(item.uid, 1) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text) return true else chance = chance - rewarditems[i].chance end end end function onUse(cid, item, fromPosition, itemEx, toPosition) local rewarditems = { {id = 2472, chance = 17, count = 1}, -- start with the lowest chances {id = 2498, chance = 17, count = 1}, {id = 2645, chance = 17, count = 1}, {id = 2421, chance = 8, count = 1}, {id = 2514, chance = 13, count = 1}, -- start with the lowest chances {id = 2470, chance = 10, count = 1}, {id = 2646, chance = 5, count = 1}, {id = 2523, chance = 3, count = 1}, -- start with the lowest chances {id = 2522, chance = 4, count = 1}, {id = 2471, chance = 2, count = 1}, {id = 2496, chance = 2, count = 1}, {id = 8977, chance = 2, count = 1} } local chance = math.random(1,100) for i = 1, #rewarditems, 1 do if(chance < rewarditems[i].chance) then local info = getItemInfo(rewarditems[i].id) if(rewarditems[i].count > 1) then text = rewarditems[i].count .. " " .. info.plural else text = info.article .. " " .. info.name end local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count) if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) text = "You have failed to open your mystery box. The item is to heavy or you have not enough space to take it." else text = "You have received " .. text .. "." doRemoveItem(item.uid, 1) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text) return true else chance = chance - rewarditems[i].chance end end end @up: Eu tive uma ideia, sera que vcs não consegue colocar um tempo pra usar o item? tipo a cada 24h?
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.