Niloahs
Well-Known Member
- Joined
- Feb 10, 2020
- Messages
- 110
- Solutions
- 1
- Reaction score
- 82
Hello Guys, i hope someone can help me with this script, basicaly what i need is the first equipment the player get in the chest is random, and when he do the quest again, he will get different equipment until completing the set, so the loop start again. Example: player got helmet, second run he got a legs, third run he got a boots...
Lua:
-- Time Chest by Limos
local config = {
exhausttime = 1, -- time in seconds
exhauststorage = 2301,
level = 50 -- minimum level to open the chest
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rewarditems = {
{id = 26425, chance = 50, count = 1}, -- helmet
{id = 26426, chance = 60, count = 1}, -- armor
{id = 26427, chance = 85, count = 1}, -- legs
{id = 26428, chance = 85, count = 1}, -- boots
}
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 exhaustion.check(cid, config.exhauststorage) then
local time = exhaustion.get(cid, config.exhauststorage)
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 "hours" or "hour")..", "..minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second")
elseif time >= 120 then
text = minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second")
else
text = seconds.." "..(seconds > 1 and "seconds" or "second")
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 i = 1, #rewarditems, 1 do
if chance < rewarditems[i].chance then
local info = getItemDescriptions(rewarditems[i].id)
if rewarditems[i].count > 1 then
text = rewarditems[i].count .. " " .. info.plural
else
text = info.article .. " " .. info.name
end
local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].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 - rewarditems[i].chance
end
end
end