local config = {
rate = 2.0,
time = 1, -- Hours of Exp Time
storage = 20011,
exhauststorage = 9583,
exhausttime = 3600 -- time in seconds
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
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)
local text
if time >= 7200 then
text = "" .. hours .. " hours, " .. minutes .. " minutes and " .. seconds .. " seconds"
elseif time >= 3600 then
text = "" .. hours .. " hour, " .. minutes .. " minutes and " .. seconds .. " seconds"
elseif time >= 60 then
text = "" .. minutes .. " minutes and " .. seconds .. " seconds"
else
text = "" .. seconds .. " seconds"
end
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You need to wait " .. text .. " before you can use this again.")
return true
end
local lastUsageTime = getPlayerStorageValue(cid, config.storage) or 0
if lastUsageTime < os.time() then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your extra experience rate is double now . It will last for " .. config.time .. " hour.")
setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600)
doRemoveItem(item.uid, 1)
exhaustion.set(cid, config.exhauststorage, config.exhausttime)
else
local remainingTime = lastUsageTime - os.time()
local remainingHours = math.floor(remainingTime / 3600)
local remainingMinutes = math.floor((remainingTime - (remainingHours * 3600)) / 60)
local remainingSeconds = remainingTime % 60
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have double experience time left: " .. remainingHours .. " hours, " .. remainingMinutes .. " minutes, and " .. remainingSeconds .. " seconds.")
end
return true
end