Estou com um problema nesse sistema de bau de recompensas, ele esta dando só os dois primeiros itens da tabela, não importa quantos itens eu adiciono nela, só ganha os 2 primeiros, alguém poderia me ajudar?
-- Time Chest by Limos
local config = {
exhausttime = 86400, -- time in seconds
exhauststorage = 2301,
level = 25 -- minimum level to open the chest
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rewarditems = {
--[[[25] = {
tilllevel = 50,
{id = 2152, chance = 5, count = math.random(1, 50)}, -- start with the lowest chances
{id = 17214, chance = 10, count = 1},
{id = 17215, chance = 15, count = 1},
{id = 2160, chance = 70, count = math.random(1, 50)}
},
[50] = {
tilllevel = 100,
{id = 7730, chance = 5, count = 1},
{id = 2466, chance = 10, count = 1},
{id = 2497, chance = 15, count = 1},
{id = 2152, chance = 70, count = math.random(1, 20)}
},
[100] = {
tilllevel = 200,
{id = 2492, chance = 5, count = 1},
{id = 2498, chance = 10, count = 1},
{id = 2195, chance = 15, count = 1},
{id = 2152, chance = 70, count = math.random(20, 50)}
},]]--
[80] = {
tilllevel = 10000,
{id = 17214, chance = 50, count = 1},
{id = 2392, chance = 100, count = 1},
{id = 16116, chance = 55, count = 1},
}
}
if(getPlayerLevel(cid) < config.level) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You need to be level "..config.level.." to open the chest.")
return true
end
if getPlayerStorageValue(cid, config.exhauststorage) and getPlayerStorageValue(cid, config.exhauststorage) - os.time(t) > 0 then
local time = getPlayerStorageValue(cid, config.exhauststorage) - os.time(t)
local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
if time >= 3600 then
text = hours.." "..(hours == 1 and "hour" or "hours")..", "..minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds")
elseif time >= 120 then text = minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds")
else
text = seconds.." "..(seconds == 1 and "second" or "seconds")
end
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "It is empty. You need to wait "..text.." before you can get a reward again.")
return true
end
local chance = math.random(1,100)
for v, x in pairs(rewarditems) do
if(getPlayerLevel(cid) >= v and getPlayerLevel(cid) < x.tilllevel) then
level = v
till = x.tilllevel
end
end
for a, b in pairs(rewarditems[level]) do
if b == till then return true end
if(chance < b.chance) then
local info = getItemInfo(b.id)
if(b.count > 1) then
text = b.count .. " " .. info.plural
else
text = info.article .. " " .. info.name
end
local item = doCreateItemEx(b.id, b.count)
if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
text = "You have found a reward. It is to heavy or you have not enough space."
else text = "You have found " .. text .. "."
exhaustion.set(cid, config.exhauststorage, config.exhausttime)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
return true
else
chance = chance - b.chance
end
end
end
Pergunta
Taiger 286
Estou com um problema nesse sistema de bau de recompensas, ele esta dando só os dois primeiros itens da tabela, não importa quantos itens eu adiciono nela, só ganha os 2 primeiros, alguém poderia me ajudar?
-- Time Chest by Limos local config = { exhausttime = 86400, -- time in seconds exhauststorage = 2301, level = 25 -- minimum level to open the chest } function onUse(cid, item, fromPosition, itemEx, toPosition) local rewarditems = { --[[[25] = { tilllevel = 50, {id = 2152, chance = 5, count = math.random(1, 50)}, -- start with the lowest chances {id = 17214, chance = 10, count = 1}, {id = 17215, chance = 15, count = 1}, {id = 2160, chance = 70, count = math.random(1, 50)} }, [50] = { tilllevel = 100, {id = 7730, chance = 5, count = 1}, {id = 2466, chance = 10, count = 1}, {id = 2497, chance = 15, count = 1}, {id = 2152, chance = 70, count = math.random(1, 20)} }, [100] = { tilllevel = 200, {id = 2492, chance = 5, count = 1}, {id = 2498, chance = 10, count = 1}, {id = 2195, chance = 15, count = 1}, {id = 2152, chance = 70, count = math.random(20, 50)} },]]-- [80] = { tilllevel = 10000, {id = 17214, chance = 50, count = 1}, {id = 2392, chance = 100, count = 1}, {id = 16116, chance = 55, count = 1}, } } if(getPlayerLevel(cid) < config.level) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) doPlayerSendCancel(cid, "You need to be level "..config.level.." to open the chest.") return true end if getPlayerStorageValue(cid, config.exhauststorage) and getPlayerStorageValue(cid, config.exhauststorage) - os.time(t) > 0 then local time = getPlayerStorageValue(cid, config.exhauststorage) - os.time(t) local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60) if time >= 3600 then text = hours.." "..(hours == 1 and "hour" or "hours")..", "..minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds") elseif time >= 120 then text = minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds") else text = seconds.." "..(seconds == 1 and "second" or "seconds") end doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "It is empty. You need to wait "..text.." before you can get a reward again.") return true end local chance = math.random(1,100) for v, x in pairs(rewarditems) do if(getPlayerLevel(cid) >= v and getPlayerLevel(cid) < x.tilllevel) then level = v till = x.tilllevel end end for a, b in pairs(rewarditems[level]) do if b == till then return true end if(chance < b.chance) then local info = getItemInfo(b.id) if(b.count > 1) then text = b.count .. " " .. info.plural else text = info.article .. " " .. info.name end local item = doCreateItemEx(b.id, b.count) if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) text = "You have found a reward. It is to heavy or you have not enough space." else text = "You have found " .. text .. "." exhaustion.set(cid, config.exhauststorage, config.exhausttime) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text) return true else chance = chance - b.chance end end end
Link para o comentário
Compartilhar em outros sites
7 respostass a esta questão
Posts Recomendados