Hello! I'm trying to change this script to ver 1.2 tfs but I can't make it work :/
Anyone can help me?
Thanks a lot!
Code:
- Time Chest by Limos
local config = {
exhausttime = 7200, -- time in seconds
exhauststorage = 2301,
level = 50 -- minimum level to open the chest
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rewarditems = {
{id = 2492, chance = 5, count = 1}, -- start with the lowest chances
{id = 2498, chance = 10, count = 1},
{id = 2488, chance = 15, count = 1},
{id = 2152, chance = 70, count = math.random(1, 50)}
}
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 = getItemInfo(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
Anyone can help me?
Thanks a lot!
Last edited: