local cfg = {
storage = 15052, -- storage do tempo
interval = 100, -- tempo em segundos para usar de novo
exit = {x = 5068, y = 5011, z = 7}, -- posição de saida
cap_needed = 105, -- cap necessario
rewards = {
-- recompensas (sera ganhado o item com maior chance em caso de falha em todas as chances)
{id = 9971, amount = 150, chance = 33}, -- 150kk
{id = 9693, amount = 1, chance = 17}, -- Addon Doll
{id = 7443, amount = 1, chance = 18}, -- Event Exp Potion
{id = 7440, amount = 1, chance = 19}, -- Double Exp Potion
{id = 2346, amount = 1, chance = 20}, -- Stamina Refiller
{id = 12614, amount = 10, chance = 30}, -- Dodge Stone
{id = 12435, amount = 10, chance = 31}, -- Critical Stone
{id = 12640, amount = 10, chance = 32}, -- Reflect Feather
{id = 8978, amount = 1, chance = 11}, -- Super UP
{id = 5808, amount = 1, chance = 10}, -- Genius Brain
{id = 8306, amount = 1, chance = 9} -- Pure Energy
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local timeNow = os.time()
local remainingTime = (tonumber(getCreatureStorage(cid, cfg.storage)) or 0) - timeNow
if (remainingTime > 0) then
doTeleportThing(cid, cfg.exit)
doSendMagicEffect(fromPosition, 12)
doPlayerSendTextMessage(cid, 27, "Seu tempo para Quest ainda não expirou! Você não deveria estar nesta SALA!!")
return true
end
if (getPlayerFreeCap(cid) < cfg.cap_needed) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Você precisa ter mais que '" .. cfg.cap_needed ..".00oz' para abrir o baú, por segurança.")
return true
end
local chosenReward = nil
local highestChance = nil
local highestChanceReward = nil
local chance = math.random(100)
local tmpChance = nil
for i = 1, #cfg.rewards do
local reward = cfg.rewards[i]
if (not highestChance or reward.chance > highestChance) then
highestChanceReward = reward
end
if (reward.chance >= chance and (not tmpChance or reward.chance < tmpChance)) then
chosenReward = reward
tmpChance = reward.chance
end
end
if (not chosenReward) then
chosenReward = highestChanceReward
end
if (doPlayerAddItem(cid, chosenReward.id, chosenReward.amount)) then
doTeleportThing(cid, cfg.exit)
doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
doCreatureSetStorage(cid, cfg.storage, timeNow + cfg.interval)
doPlayerSendTextMessage(cid, 27, "Você finalizou a Quest e recebeu um item. Poderá fazer a novamente em nesse exato momento!!")
else
doPlayerPopupFYI(cid, " [+] Quest [+]\n\nVocê está sem espaço em sua backpack. Libere espaço.\nSe continuar clicando poderá perder sua!")
end
return true
end