local levels = {
[-1] = {itemid = 6541, chance = 10},
[10] = {itemid = 6542, chance = 20},
[20] = {itemid = 6543, chance = 5},
[30] = {itemid = 6544, chance = 30},
[40] = {itemid = 6545, chance = 80},
}
local config = {
storage = 19333,
chance = 1, --- chance de achar um item ou não
k = 1, --- constante de level.. quanto maior, mais fácil é upar. (a fórmula é level ao quadrado dividido pela constante)
experience = 19334
}
local terra = {11787}
function getDrops(cid)
local drops = {}
for i = -1, getPlayerStorageValue(cid, config.storage) do
if levels[i] then
local item = levels[i].itemid
local chance = levels[i].chance
if config.chance >= math.random(1, 100) then -- Ajustado para um intervalo de 1 a 100
if math.random(1, 100) <= chance then
table.insert(drops, item)
end
end
end
end
return drops
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local drops = {}
if isInArray(terra, itemEx.itemid) then
drops = getDrops(cid)
doPlayerSetStorageValue(cid, config.experience, getPlayerStorageValue(cid, config.experience) + 1)
local experience = getPlayerStorageValue(cid, config.experience)
if experience >= (8 + (getPlayerStorageValue(cid, config.storage) ^ 2)) / config.k then
doPlayerSetStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage) + 1)
doPlayerSendTextMessage(cid, 27, "Parabens, voce subiu de nivel! Seu nivel atual e " .. getPlayerStorageValue(cid, config.storage) .. ".")
if getPlayerStorageValue(cid, config.storage) == 100 then
doPlayerSendTextMessage(cid, 20, "[MINING] --> Por alcancar o nivel " .. getPlayerStorageValue(cid, config.storage) .. " voce foi premiado com o capacete de mineracao.")
doPlayerAddItem(cid, 7497, 1, true)
end
end
if config.chance >= math.random(1, 150) then
if #drops >= 1 then
local item = drops[math.random(1, #drops)]
doPlayerSendTextMessage(cid, 27, "[MINING] --> Voce encontrou um(a) " .. getItemNameById(item) .. ".")
doSendAnimatedText(toPosition, "Sucesso", 210)
doPlayerAddItem(cid, item, 1, true)
end
doSendMagicEffect(toPosition, 3)
else
doSendAnimatedText(toPosition, "Tack", 215)
doSendMagicEffect(toPosition, 2)
return true
end
elseif itemEx.itemid == item.itemid then
doPlayerSendTextMessage(cid, 27, "[MINING] --> Seu nivel na mineracao e: [" .. getPlayerStorageValue(cid, config.storage) .. "].")
else
return false
end
return true
end