Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Time Chests by Limos
- function onUse(cid, item, fromPosition, itemEx, toPosition)
- local chests = {
- [8001] = {
- waittime = 14400, -- time in seconds
- storage = 2301,
- rewarditems = {
- {id = 2152, count = math.random(1, 50)},
- {id = 2462, count = 1},
- {id = 2124, count = 1},
- {id = 2647, count = 1}
- }
- },
- [8002] = {
- waittime = 14400, -- time in seconds
- storage = 2302,
- rewarditems = {
- {id = 2160, count = math.random(1, 5)},
- {id = 2498, count = 1},
- {id = 2492, count = 1},
- {id = 2488, count = 1}
- }
- },
- [8003] = {
- waittime = 14400, -- time in seconds
- storage = 2303,
- rewarditems = {
- {id = 2160, count = math.random(20, 50)},
- {id = 7385, count = 1},
- {id = 2514, count = 1},
- {id = 2470, count = 1}
- }
- }
- }
- local x = chests[item.uid]
- if exhaustion.check(cid, x.storage) then
- local time = exhaustion.get(cid, x.storage)
- 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, #x.rewarditems)
- local info = getItemInfo(x.rewarditems[chance].id)
- if x.rewarditems[chance].count > 1 then
- text = x.rewarditems[chance].count .. " " .. info.plural
- else
- text = info.article .. " " .. info.name
- end
- local item = doCreateItemEx(x.rewarditems[chance].id, x.rewarditems[chance].count)
- if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
- doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
- text = "You have found a reward. It is too heavy or you have not enough space."
- else
- text = "You have found " .. text .. "."
- exhaustion.set(cid, x.storage, x.waittime)
- end
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement