Postado Dezembro 1, 2023 1 ano Entao, queria que esse script tivesse o codigo de chance em cada item. Cada item tem sua chace de coletado. Alguem da uma moral de po o codigo porfavor !? >.< Ex: [-1] = 6541, [chance = 10] [10] = 6542, [chance = 20] [20] = 6543, [chance = 5] [30] = 6544, [chance = 30] [40] = 6545, [chance = 80] Citar terra = {11787,} levels = { [-1] = 6541, [10] = 6542, [20] = 6543, [30] = 6544, [40] = 6545, } 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 } function onUse(cid, item, fromPosition, itemEx, toPosition) local drops = {} function getDrops(cid) for i= -1,getPlayerStorageValue(cid, config.storage) do if levels[i] then table.insert(drops, levels[i]) end end return true end if isInArray(terra, itemEx.itemid) then 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
Postado Dezembro 2, 2023 1 ano Solução 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
Postado Dezembro 5, 2023 1 ano Autor Em 02/12/2023 em 07:36, GM Vortex disse: 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 Haha, muito obrigadooooo ! como sempe, voce salvando a galera ! *-*
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.