• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Use Item To give you an exp

Misokoko

New Member
Joined
Mar 29, 2013
Messages
126
Reaction score
0
i found that a script when u use an item that is gives you 1.5 exp rate for 1 hour but the problem is when the player dies or logout he got the exp for unlimited time and not be able to use the other one.

My tfs 0.4 rev 3777

Code:
local config = {
rate = 1.5,
time = 1, -- Hours of Exp Time
storage = 20011,
exhauststorage = 9583,
exhausttime = 3600 -- time in seconds
}
local function endExpRate(cid)
if isPlayer(cid) == TRUE then
doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
setPlayerStorageValue(cid, config.storage, -1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
end
end
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)
if time >= 3600 then
text = ""..hours.." hours, "..minutes.." minutes and "..seconds.." seconds"
elseif time >= 3600 then
text = ""..hours.." hour, "..minutes.." minutes and "..seconds.." seconds"
elseif time >= 10 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

if(getPlayerStorageValue(cid, config.storage) < 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your extra experience rate is now: " .. config.rate .. ". It will last for ".. config.time .." hour.")
doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600)
addEvent(endExpRate, config.time * 3600 * 1000, cid)
doRemoveItem(item.uid, 1)
exhaustion.set(cid, config.exhauststorage, config.exhausttime)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have extra experience time left.")
end
return TRUE
end
 
Back
Top