Postado Agosto 25, 2023 1 ano .Qual servidor ou website você utiliza como base? Canary Qual o motivo deste tópico? O script funciona perfeitamente, porém não estou conseguindo ajustar a porcentagem dos itens, não consegui entender a forma de calcular a porcentagem de chance. Precisava de alguns exemplos só pra ter uma boa noção. Está surgindo algum erro? Se sim coloque-o aqui. Citar Você tem o código disponível? Se tiver publique-o aqui: local tiles = { Position(32163, 32295, 6), Position(32164, 32295, 6), Position(32165, 32295, 6), Position(32166, 32295, 6), -- Center Tile is winning Tile -- Position(32167, 32295, 6), Position(32168, 32295, 6), Position(32169, 32295, 6) } local items = { -- Chance Win / itemid / amount / chance amount (out of 100000) [{1, 10001}] = {itemid = 3079, amount = 1, amountChance = 80000}, -- 1, 10001 = 10000 (100000/10000 = 10% chance to win) [100000 / 80000 = 80% chance for amount to increase] [{10002, 15002}] = {itemid = 3388, amount = 1, amountChance = 70000}, [{15003, 20003}] = {itemid = 43869, amount = 1, amountChance = 60000}, [{20004, 25004}] = {itemid = 43886, amount = 1, amountChance = 50000}, [{25005, 30005}] = {itemid = 43880, amount = 1, amountChance = 40000}, [{30006, 35006}] = {itemid = 43878, amount = 1, amountChance = 30000}, [{35007, 40007}] = {itemid = 3389, amount = 1, amountChance = 25000}, [{40008, 45008}] = {itemid = 3387, amount = 1, amountChance = 15000} } -- local items = { -- -- Chance Win / itemid / amount / chance amount (out of 100000) -- [{1, 80001}] = {itemid = 3387, amount = 5, amountChance = 80000}, -- 1, 10001 = 10000 (100000/10000 = 10% chance to win) [100000 / 80000 = 80% chance for amount to increase] -- [{80002, 85002}] = {itemid = 3388, amount = 5, amountChance = 50000}, -- [{85003, 88003}] = {itemid = 2160, amount = 5, amountChance = 25000} -- } local itemsList = {3387, 3388, 3389, 43869, 43886, 43880, 43878, 3079} local canGetNoItem = false -- If true players can get nothing at all. -- local autoWin = {itemid = 3043, amount = 100, amountChance = 99999999} -- Item that is always won if they have to get something. -- local leverAID = 53452 -- AID in map for item that is used to roll -- local leverItemID = 1723 -- itemid for item that is used to roll -- -- Item required to spin activate roulette -- local itemRequired = 3043 local itemAmount = 100 local roulette = Action() function roulette.onUse(player, item, fromPosition, target, toPosition, isHotkey) if not player:removeItem(itemRequired, itemAmount) then return player:sendCancelMessage("Voce nao tem "..itemAmount.." "..ItemType(itemRequired):getName()..".") end local rand = math.random(100000) local win = false for i, v in pairs(items) do if rand >= i[1] and rand <= i[2] then win = items[i] break end end if not canGetNoItem and not win then win = autoWin end local winAmount = 0 if win then for i = 1, win.amount do local rand = math.random(100000) if rand <= win.amountChance then winAmount = winAmount + 1 end end end rollItems(win, winAmount, 30, player:getName()) return true end function rollItems(winTable, winAmount, spins, name) moveItems() if spins == 3 then if not winTable then spins = spins - 1 addEvent(rollItems, 200, winTable, winAmount, spins, name) return true end Game.createItem(winTable.itemid, winAmount, tiles[1]) spins = spins - 1 addEvent(rollItems, 200, winTable, winAmount, spins, name) return true end if spins >= 1 and spins ~= 3 then local randEmpty = math.random(6) if randEmpty == 1 then spins = spins - 1 addEvent(rollItems, 200, winTable, winAmount, spins, name) return true end local randomItem = itemsList[math.random(#itemsList)] local itemType = ItemType(randomItem) if itemType:isStackable() then Game.createItem(randomItem, math.random(5), tiles[1]) else Game.createItem(randomItem, 1, tiles[1]) end spins = spins - 1 addEvent(rollItems, 200, winTable, winAmount, spins, name) return true end if spins == 0 then giveReward(winTable, winAmount, name) end end function moveItems() local tileItems = {} for i = 1, #tiles do local tile = Tile(tiles[i]) if tile and tile:getTopDownItem() then tileItems[i] = tile:getTopDownItem() elseif tile and not tile:getTopDownItem() then tileItems[i] = false end end for i = 1, #tileItems do if i == 7 and tileItems[i] ~= false then tileItems[i]:remove() return true elseif tileItems[i] ~= false then tileItems[i]:moveTo(tiles[i + 1]) end end end function giveReward(winTable, winAmount, name) local player = Player(name) if not player then return true end if not winTable then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "TESTE") return true end player:addItem(winTable.itemid, winAmount) player:getPosition():sendMagicEffect(CONST_ME_FIREAREA) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Parabens! Voce recebeu um "..ItemType(winTable.itemid):getName()..".") -- player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You won "..winAmount.." "..ItemType(winTable.itemid):getName()..".") end roulette:id(leverItemID) roulette:register() Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui.
Postado Agosto 27, 2023 1 ano Solução Pelo que entendi disso V (100000/10000 = 10% chance to win) 1000 = 1% 10000 = 10% 50000 = 50% 100000 = 100% Como exemplo a primeira linha dos premios: [{1, 10001}] = {itemid = 3079, amount = 1, amountChance = 80000}, O item 3079 tem 80% de chance de ser o item entregue para o vencedor. Editado Agosto 27, 2023 1 ano por King Laker (veja o histórico de edições)
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.