Postado Maio 5, 2016 9 anos Olá Pessoal do TK venho pedir a ajuda novamente a os mestres do fórum. Tenho um Script de box rand itens funcionando 100%, porem eu gostaria que a box fosse aberta por uma key(item), eu já escolhi o item e tals. Vou postar o código do rand itens e vamos ver se alguém consegue me ajudar. function onUse(cid, item, fromPosition, itemEx, toPosition) local rewarditems = { {id = 11441, chance = 10, count = 1}, {id = 11442, chance = 10, count = 1}, {id = 11443, chance = 10, count = 1}, {id = 11444, chance = 10, count = 1}, {id = 11445, chance = 10, count = 1}, {id = 11446, chance = 10, count = 1}, {id = 11447, chance = 10, count = 1}, {id = 11448, chance = 10, count = 1}, {id = 11449, chance = 10, count = 1}, {id = 11450, chance = 10, count = 1}, {id = 11451, chance = 10, count = 1}, {id = 11452, chance = 10, count = 1} } local box = 13197 --ID da box. 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 if item.itemid == box then doPlayerAddItem(cid, rewarditems[i].id, rewarditems[i].count) doPlayerRemoveItem(cid, box, 1) doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) text = "You have received " .. text .. "." else text = "You have failed to open your mystery box. The item is to heavy or you have not enough space to take it." end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text) return true else chance = chance - rewarditems[i].chance end end end Acredito que este script vai ajudar muita gente que gostaria de fazer eventos do tipo. Obrigado.
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.