local config = {
effect = 54, -- efeito em cima do jogador
effectReward = 30, -- efeito em cima do premio
effectLever = 26, -- efeito em cima da alavanca
eventCoin = 12637, -- valor para jogar
qtdCoin = 5, -- quantidade do coin para jogar
effectLose = 29, -- efeito em cima do premio quando perder
exaust = 10.0, -- Segundos de exaust
storage = 23111, -- Storage do exaust
used = 10, -- Tempo da duração da roleta
used_storage = 23112, -- Storage pra verificar se a roleta esta sendo usada
used = 10,
poss = {
[1] = {x = 150, y = 50, z = 9}, -- Coloque a coordenada da POS1 no Map Editor
[2] = {x = 151, y = 50, z = 9}, -- Coloque a coordenada da POS2 no Map Editor
[3] = {x = 152, y = 50, z = 9}, -- Coloque a coordenada da POS3 no Map Editor
[4] = {x = 153, y = 50, z = 9}, -- Coloque a coordenada da POS4 no Map Editor
[5] = {x = 154, y = 50, z = 9}, -- Coloque a coordenada da POS5 no Map Editor - local do premio
[6] = {x = 155, y = 50, z = 9}, -- Coloque a coordenada da POS6 no Map Editor
[7] = {x = 156, y = 50, z = 9}, -- Coloque a coordenada da POS7 no Map Editor
[8] = {x = 157, y = 50, z = 9}, -- Coloque a coordenada da POS8 no Map Editor
[9] = {x = 158, y = 50, z = 9} -- Coloque a coordenada da POS9 no Map Editor
},
items = { -- id = id do item - chance = chance de aparecer o item - count = a quantidade de item que a pessoa ira ganhar
[1] = {id = 9693, chance = 65, count = 1},
[2] = {id = 2346, chance = 60, count = 1},
[3] = {id = 12630, chance = 75, count = 1},
[4] = {id = 5957, chance = 50, count = 1},
[5] = {id = 2157, chance = 70, count = 50},
[6] = {id = 8851, chance = 15, count = 1},
[7] = {id = 2453, chance = 15, count = 1},
[8] = {id = 2447, chance = 15, count = 1},
[9] = {id = 8931, chance = 15, count = 1},
[10] = {id = 7455, chance = 15, count = 1},
[11] = {id = 10503, chance = 10, count = 1},
[12] = {id = 10309, chance = 30, count = 1}
}
}
local slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9
local function cleanTile(item, i)
doCleanTile(config.poss[i], true)
doCreateItem(item, 1, config.poss[i])
end
local function raffle(item)
if slot8 ~= nil then
slot9 = slot8
cleanTile(471, 9)
doCreateItem(slot9.id, slot9.count, config.poss[9])
end
if slot7 ~= nil then
slot8 = slot7
cleanTile(471, 8)
doCreateItem(slot8.id, slot8.count, config.poss[8])
end
if slot6 ~= nil then
slot7 = slot6
cleanTile(471, 7)
doCreateItem(slot7.id, slot7.count, config.poss[7])
end
if slot5 ~= nil then
slot6 = slot5
cleanTile(471, 6)
doCreateItem(slot6.id, slot6.count, config.poss[6])
end
if slot4 ~= nil then
slot5 = slot4
cleanTile(11059, 5)
doCreateItem(slot5.id, slot5.count, config.poss[5])
end
if slot3 ~= nil then
slot4 = slot3
cleanTile(471, 4)
doCreateItem(slot4.id, slot4.count, config.poss[4])
end
if slot2 ~= nil then
slot3 = slot2
cleanTile(471, 3)
doCreateItem(slot3.id, slot3.count, config.poss[3])
end
if slot1 ~= nil then
slot2 = slot1
cleanTile(471, 2)
doCreateItem(slot2.id, slot2.count, config.poss[2])
end
slot1 = {id = item.id, count = item.count}
cleanTile(471, 1)
doCreateItem(slot1.id, slot1.count, config.poss[1])
end
local function result(uid)
if isPlayer(uid) then
if config.lose and slot5.id == config.itemLose then
doSendMagicEffect(getCreaturePosition(uid), CONST_ME_POFF)
doSendMagicEffect(config.poss[5], config.effectLose)
doCreatureSay(cid,"[ROLETA MALUTA] Que azar, tente novamente!",TALKTYPE_ORANGE_1)
else
doSendMagicEffect(getCreaturePosition(uid), config.effect)
doSendMagicEffect(config.poss[5], config.effectReward)
doCreatureSay(uid,"[ROLETA MALUTA] Você ganhou " .. slot5.count .. " " .. getItemNameById(slot5.id) .. ". Parabens sortudo!!",TALKTYPE_ORANGE_1)
doPlayerAddItem(uid, slot5.id, slot5.count)
doBroadcastMessage("[ROLETA MALUCA]: O jogador "..getPlayerName(uid).." ganhou "..getItemNameById(slot5.id).." na roleta maluca, que sorte!", 20)
end
end
end
function onUse(cid, item, pos, itemEx, posEx)
if item.itemid == 1945 then doTransformItem(item.uid, item.itemid + 1) end
if item.itemid == 1946 then doTransformItem(item.uid, item.itemid - 1) end
if getGlobalStorageValue(config.used_storage) <= os.time() then
if not exhaustion.check(cid, config.storage) then
if getPlayerItemCount(cid, config.eventCoin) >= config.qtdCoin then
local rand = math.random(10, 30)
doSendMagicEffect(pos, config.effectLever)
setGlobalStorageValue(config.used_storage, rand + 5 + os.time())
exhaustion.set(cid, config.storage, rand)
doPlayerRemoveItem(cid, config.eventCoin, config.qtdCoin)
local loop = 0
slot1 = nil
slot2 = nil
slot3 = nil
slot4 = nil
slot5 = nil
slot6 = nil
slot7 = nil
slot8 = nil
slot9 = nil
for i = 1, #config.poss do
if i == 5 then
cleanTile(11059, i)
else
cleanTile(471, i)
end
end
while rand >= loop do
local roll = math.random(1, 100)
index = math.random(#config.items)
if roll <= config.items[index].chance then
local item = config.items[index]
loop = loop + 1
addEvent(raffle, loop * 400, item)
end
end
addEvent(result, (rand + 2) * 1000, cid)
else
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
doCreatureSay(cid,"[ROLETA MALUCA] Voce precisa ter " .. config.qtdCoin .. " " .. getItemNameById(config.eventCoin) .. " na BP!",TALKTYPE_ORANGE_1)
end
else
doSendMagicEffect(fromPosition, CONST_ME_POFF)
doCreatureSay(cid,"Exhaustion, aguarde " .. exhaustion.get(cid, config.storage) .. " segundos para usar a roleta novamente!",TALKTYPE_ORANGE_1)
return false
end
return true
else
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
doCreatureSay(cid,"[ROLETA MALUCA] Sorteio em andamento, espere finalizar para iniciar outro.",TALKTYPE_ORANGE_1)
end
end