Postado Maio 19, 2015 10 anos Olá pessoal! Estou usando o sistema(action) do shumagora, que funciona como um baú que ao abrir pode vir os itens configurados..baualeatorio.lua Mostrar conteúdo oculto function onUse(cid, item, fromPosition, itemEx, toPosition) local rand = math.random(0, 11) local lotteryid = 4850 if item.itemid == lotteryid then if rand == 0 then doCreatureSay(cid, "Abriu e ganhou 15x HANDGUN AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11389,15) doRemoveItem(cid, item.uid, 1) elseif rand == 1 then doCreatureSay(cid, "Abriu e ganhou 15x MAGNUM AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11390,15) doRemoveItem(cid, item.uid, 1) elseif rand == 2 then doCreatureSay(cid, "Abriu e ganhou 15x SHOTGUN AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11391,15) doRemoveItem(cid, item.uid, 1) elseif rand == 3 then doCreatureSay(cid, "Abriu e ganhou 15x RIFLE AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11392,15) doRemoveItem(cid, item.uid, 1) elseif rand == 4 then doCreatureSay(cid, "Abriu e ganhou 15x MACHINEGUN AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11394,15) doRemoveItem(cid, item.uid, 1) elseif rand == 5 then doCreatureSay(cid, "Abriu e ganhou 15x ACID AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11395,15) doRemoveItem(cid, item.uid, 1) elseif rand == 6 then doCreatureSay(cid, "Abriu e ganhou 15x EXPLOSIVE AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11396,15) doRemoveItem(cid, item.uid, 1) elseif rand == 7 then doCreatureSay(cid, "Abriu e ganhou 15x NITROGEN AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11397,15) doRemoveItem(cid, item.uid, 1) elseif rand == 8 then doCreatureSay(cid, "Abriu e ganhou 15x FLASH AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11398,15) doRemoveItem(cid, item.uid, 1) elseif rand == 9 then doCreatureSay(cid, "Abriu e ganhou 15x ELETRIC AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11399,15) doRemoveItem(cid, item.uid, 1) elseif rand == 10 then doCreatureSay(cid, "Abriu e ganhou 15x FLAME AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11400,15) doRemoveItem(cid, item.uid, 1) --! se quiser que quebra --> elseif rand == 11 then doCreatureSay(cid, "BROKE!", TALKTYPE_ORANGE_1) doRemoveItem(cid, item.uid, 1) end end return TRUE end Action TAG <action itemid="4850" event="script" value="baualeatorio.lua"/> Vim ao suporte pedir que adicionem uma chance de cada item, pq do jeito que tá é uma chancezinha aleatória.. queria tipo assim: ITEM 1 - 67% de chance ITEM 2 - 12% de chance ITEM 3 - 5% de chance ITEM 4 - 15% de chance ITEM 5 - 1% de chance ITEM 6 - 3% de chance ITEM 7 - 0.5% de chance (se possível.. ficaria legal tbm mas não é tão necessário euehuehe) espero que consigam entender o que to falando.. cada item com uma porcentagem de chances de vir ao invés de aleatória. grato desde já!
Postado Maio 19, 2015 10 anos Acima de "elseif rand == 1 then", Você coloca isso onde ta 75 e a %. if math.random(1, 100) >= 1 and math.random(1, 100) <= 75 then Editado Maio 19, 2015 10 anos por Ceos (veja o histórico de edições)
Postado Maio 19, 2015 10 anos Solução function onUse(cid, item, fromPosition, itemEx, toPosition) local rand = math.random(1, 120) if rand <= 10 then doCreatureSay(cid, "Abriu e ganhou 15x HANDGUN AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11389,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 20 then doCreatureSay(cid, "Abriu e ganhou 15x MAGNUM AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11390,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 30 then doCreatureSay(cid, "Abriu e ganhou 15x SHOTGUN AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11391,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 40 then doCreatureSay(cid, "Abriu e ganhou 15x RIFLE AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11392,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 50 then doCreatureSay(cid, "Abriu e ganhou 15x MACHINEGUN AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11394,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 60 then doCreatureSay(cid, "Abriu e ganhou 15x ACID AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11395,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 70 then doCreatureSay(cid, "Abriu e ganhou 15x EXPLOSIVE AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11396,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 80 then doCreatureSay(cid, "Abriu e ganhou 15x NITROGEN AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11397,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 90 then doCreatureSay(cid, "Abriu e ganhou 15x FLASH AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11398,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 100 then doCreatureSay(cid, "Abriu e ganhou 15x ELETRIC AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11399,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 110 then doCreatureSay(cid, "Abriu e ganhou 15x FLAME AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11400,15) doRemoveItem(cid, item.uid, 1) elseif rand >= 110 then doCreatureSay(cid, "BROKE!", TALKTYPE_ORANGE_1) doRemoveItem(cid, item.uid, 1) end return true end Sua explicação ficou confusa, então, use isso e teste, pois não são 7 items, são mais que isso, coloquei chances de 10% até 100% de pegar tal item, bom, veja se está bom para você. Em 19/05/2015 em 01:08, Ceos disse: Acima de "elseif rand == 1 then", Você coloca isso onde ta 75 e a %. if math.random(1, 100) >= 1 and math.random(1, 100) <= 75 then E você está errado. Editado Maio 19, 2015 10 anos por Snowsz (veja o histórico de edições) _ .-'` `} _./) / } .'o \ | } '.___.'`.\ {` /`\_/ , `. } ME DA UMA NOZ! \=' .-' _`\ { `'`;/ `, } _\ @ ; } /__`;-...'--' Cluck!
Postado Maio 19, 2015 10 anos Autor Em 19/05/2015 em 01:08, Ceos disse: Acima de "elseif rand == 1 then", Você coloca isso onde ta 75 e a %. if math.random(1, 100) >= 1 and math.random(1, 100) <= 75 then agradeço por tentar ajudar Em 19/05/2015 em 01:38, Snowsz disse: function onUse(cid, item, fromPosition, itemEx, toPosition) local rand = math.random(1, 120) if rand <= 10 then doCreatureSay(cid, "Abriu e ganhou 15x HANDGUN AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11389,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 20 then doCreatureSay(cid, "Abriu e ganhou 15x MAGNUM AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11390,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 30 then doCreatureSay(cid, "Abriu e ganhou 15x SHOTGUN AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11391,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 40 then doCreatureSay(cid, "Abriu e ganhou 15x RIFLE AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11392,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 50 then doCreatureSay(cid, "Abriu e ganhou 15x MACHINEGUN AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11394,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 60 then doCreatureSay(cid, "Abriu e ganhou 15x ACID AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11395,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 70 then doCreatureSay(cid, "Abriu e ganhou 15x EXPLOSIVE AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11396,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 80 then doCreatureSay(cid, "Abriu e ganhou 15x NITROGEN AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11397,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 90 then doCreatureSay(cid, "Abriu e ganhou 15x FLASH AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11398,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 100 then doCreatureSay(cid, "Abriu e ganhou 15x ELETRIC AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11399,15) doRemoveItem(cid, item.uid, 1) elseif rand <= 110 then doCreatureSay(cid, "Abriu e ganhou 15x FLAME AMMO!", TALKTYPE_ORANGE_1) doPlayerAddItem(cid, 11400,15) doRemoveItem(cid, item.uid, 1) elseif rand >= 110 then doCreatureSay(cid, "BROKE!", TALKTYPE_ORANGE_1) doRemoveItem(cid, item.uid, 1) end return true end Sua explicação ficou confusa, então, use isso e teste, pois não são 7 items, são mais que isso, coloquei chances de 10% até 100% de pegar tal item, bom, veja se está bom para você. E você está errado. Snowsz novamente, melhor resposta e REP+, obg pela ajuda novamente
Postado Maio 19, 2015 10 anos biel.stocco, Desculpe eu estava sem tempo, eu ia fazer o script mais snowsz já fez At+
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.