• 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!

Lua Exp potion

Kawaki69

Member
Joined
Mar 4, 2022
Messages
72
Reaction score
8
I have this error in the console using tfs 1.4
Lua:
local config = {
    rate = 1.5,
    time = 1, -- Hours of Exp Time
    storage = 20011,
    exhauststorage = 9583,
    exhausttime = 43200 -- 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 >= 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

    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
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/okdoky/exp_potion.lua:onUse
data/actions/scripts/okdoky/exp_potion.lua:17: attempt to index global 'exhaustion' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/actions/scripts/okdoky/exp_potion.lua:17: in function <data/actions/scripts/okdoky/exp_potion.lua:15>
 
Your "exhaustion" doesn't exist in your lua libs. Find something like global.lua, or compat.lua and add this to the bottom of that file

 
Solution
Your "exhaustion" doesn't exist in your lua libs. Find something like global.lua, or compat.lua and add this to the bottom of that file

Thank you it worked and this error appears suddenly and the items didn't gone and this message appear in game
Code:
17:55 Your extra experience rate is now: 1.5. It will last for 1 hour.
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/okdoky/exp_potion.lua:onUse
data/actions/scripts/okdoky/exp_potion.lua:36: attempt to call global 'doPlayerSetRate' (a nil value)
stack traceback:
        [C]: in function 'doPlayerSetRate'
        data/actions/scripts/okdoky/exp_potion.lua:36: in function <data/actions/scripts/okdoky/exp_potion.lua:15>
 
Thank you it worked and this error appears suddenly and the items didn't gone and this message appear in game
Code:
17:55 Your extra experience rate is now: 1.5. It will last for 1 hour.
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/okdoky/exp_potion.lua:onUse
data/actions/scripts/okdoky/exp_potion.lua:36: attempt to call global 'doPlayerSetRate' (a nil value)
stack traceback:
        [C]: in function 'doPlayerSetRate'
        data/actions/scripts/okdoky/exp_potion.lua:36: in function <data/actions/scripts/okdoky/exp_potion.lua:15>
Now you need to found the correct function that set exp rate in your server and change where is "doPlayerSetRate" for that function
 
Thank you it worked
Could you please mark my answer as solution and mark as solved?
exp_potion.lua:36
script "exp_potion.lua" line #36
attempt to call global 'doPlayerSetRate' (a nil value)
doPlayerSetRate either returns nil (nothing) or it is nothing (nil), doesn't exist. Just like with your previous error. Please try to learn to interpret the errors, its important as you may not always find a solution from someone else's help.
The problem is obvious, you are trying to take an old script and use it in a new engine, when doing these things it is important to know how to interpret the errors or you will not be able to successfully import all scripts that you want.
Please note, 1.4 doesn't use cid anymore, instead it passes userdata, so really you will just keep running into problems without converting it to new standards. You will need to learn lua to so.
Please make a new thread for the new problem
 
doPlayerSetRate does not exist in 1.4. Rates are no longer in C++, now they are calculated in Lua in data/events/scripts/player.lua.
Easiest way to increase player exp is to set some player storage to os.time() on which it should stop increasing exp ex. 1 hour setPlayerStorageValue(cid, 123, os.time() + 3600)

In data/events/scripts/player.lua under:
Lua:
function Player:onGainExperience(source, exp, rawExp)
   if not source or source:isPlayer() then
      return exp
   end
add:
Lua:
-- +50% exp for potion, '20011' is storage from potion config
if self:getStorageValue(20011) >= os.time() then
   exp = exp * 1.5
end

and replace your script with this:
Lua:
local config = {
    rate = 1.5,
    time = 1, -- Hours of Exp Time
    storage = 20011,
    exhauststorage = 9583,
    exhausttime = 43200 -- 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)
        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

    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.")

        setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600)
        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
You don't set exp rate in potion script anymore. You also don't need addEvent to stop it after 1 hour. player.lua controls exp rate and will stop adding +50% when storage 20011 become lower than current time.
 
doPlayerSetRate does not exist in 1.4. Rates are no longer in C++, now they are calculated in Lua in data/events/scripts/player.lua.
Easiest way to increase player exp is to set some player storage to os.time() on which it should stop increasing exp ex. 1 hour setPlayerStorageValue(cid, 123, os.time() + 3600)

In data/events/scripts/player.lua under:
Lua:
function Player:onGainExperience(source, exp, rawExp)
   if not source or source:isPlayer() then
      return exp
   end
add:
Lua:
-- +50% exp for potion, '20011' is storage from potion config
if self:getStorageValue(20011) >= os.time() then
   exp = exp * 1.5
end

and replace your script with this:
Lua:
local config = {
    rate = 1.5,
    time = 1, -- Hours of Exp Time
    storage = 20011,
    exhauststorage = 9583,
    exhausttime = 43200 -- 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)
        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

    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.")

        setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600)
        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
You don't set exp rate in potion script anymore. You also don't need addEvent to stop it after 1 hour. player.lua controls exp rate and will stop adding +50% when storage 20011 become lower than current time.
Sir you are an absolute genius! Worked 100% Thank you! Thread can be closed, thank you!
 
Sir you are an absolute genius! Worked 100% Thank you! Thread can be closed, thank you!
Thank you so much for marking someone else's answer as the solution to your problem. Especially since you said my fix worked. That was super bogus, and its the type of thing that makes people want to stop helping. I'll be sure to ignore any support threads started by you in the future.
 
Thank you so much for marking someone else's answer as the solution to your problem. Especially since you said my fix worked. That was super bogus, and its the type of thing that makes people want to stop helping. I'll be sure to ignore any support threads started by you in the future.
Greetings sir, Why did you take it so seriously personal? I said worked yeah but this doesn't fix the script itself and this answer isn't a full answer I'm sorry but how can I make the two best answers? this is a good community I didn't do anything wrong, and if I did, I apologize to you and the community If there was a button to add the best answer to both sides, I would do this.
 
Greetings sir, Why did you take it so seriously personal? I said worked yeah but this doesn't fix the script itself and this answer isn't a full answer I'm sorry but how can I make the two best answers? this is a good community I didn't do anything wrong, and if I did, I apologize to you and the community If there was a button to add the best answer to both sides, I would do this.
You created this thread to fix the problem of "nil" error for "exhaustion". I did that for you. Then I asked you to create a new thread for the new problem.
It doesn't matter forreal, but I'm just annoyed that every time I help, end up regretting it. You learned nothing, didn't try to learn anything, and then didn't even mark my answer when it is definitely the solution to the this threads original problem. Had you made another thread, and marked my answer, as you are supposed to do, I would have helped you on the new thread too. It's cool though, you do you.
Post automatically merged:

this answer isn't a full answer
most definitely was a full answer, you just asked for more help after the original problem was solved.
 
@Gesior.pl have problem on tfs 1.5 have error you can't help me?
Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/double_exp.lua:onUse
data/actions/scripts/double_exp.lua:11: attempt to index global 'exhaustion' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/actions/scripts/double_exp.lua:11: in function <data/actions/scripts/double_exp.lua:9>
 
@Gesior.pl have problem on tfs 1.5 have error you can't help me?
Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/double_exp.lua:onUse
data/actions/scripts/double_exp.lua:11: attempt to index global 'exhaustion' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/actions/scripts/double_exp.lua:11: in function <data/actions/scripts/double_exp.lua:9>
Exhaustion functions are not part of the server by default anymore. (I think?)
Gotta add them yourself.

lib/core/player.lua
Lua:
function Player.setExhaustion(self, value, time)
    self:setStorageValue(value, time + os.time())
end

function Player.getExhaustion(self, value)
    local storage = self:getStorageValue(value)
    if not storage or storage <= os.time() then
        return 0
    end
   
    return storage - os.time()
end

function Player:hasExhaustion(value)
    return self:getExhaustion(value) >= os.time() and true or false
end

---
Edit

an alternative exhaustion was posted above.

2nd comment

 
@Xikini thanks, look this im adding this to player.lua to lib player.lua it's this same error. emm Look my player.lua
im used tfs 1.5 8.6 downgrade by nekiro
Lua:
local foodCondition = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)

function Player.feed(self, food)
    local condition = self:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
    if condition then
        condition:setTicks(condition:getTicks() + (food * 1000))
    else
        local vocation = self:getVocation()
        if not vocation then
            return nil
        end

        foodCondition:setTicks(food * 1000)
        foodCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, vocation:getHealthGainAmount())
        foodCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, vocation:getHealthGainTicks() * 1000)
        foodCondition:setParameter(CONDITION_PARAM_MANAGAIN, vocation:getManaGainAmount())
        foodCondition:setParameter(CONDITION_PARAM_MANATICKS, vocation:getManaGainTicks() * 1000)

        self:addCondition(foodCondition)
    end
    return true
end

function Player.getClosestFreePosition(self, position, extended)
    if self:getGroup():getAccess() and self:getAccountType() >= ACCOUNT_TYPE_GOD then
        return position
    end
    return Creature.getClosestFreePosition(self, position, extended)
end
function Player.setExhaustion(self, value, time)
    self:setStorageValue(value, time + os.time())
end

function Player.getExhaustion(self, value)
    local storage = self:getStorageValue(value)
    if not storage or storage <= os.time() then
        return 0
    end
  
    return storage - os.time()
end

function Player:hasExhaustion(value)
    return self:getExhaustion(value) >= os.time() and true or false
end

function Player.getDepotItems(self, depotId)
    return self:getDepotChest(depotId, true):getItemHoldingCount()
end

function Player.hasFlag(self, flag)
    return self:getGroup():hasFlag(flag)
end

function Player.getLossPercent(self)
    local blessings = 0
    local lossPercent = {
        [0] = 100,
        [1] = 70,
        [2] = 45,
        [3] = 25,
        [4] = 10,
        [5] = 0
    }

    for i = 1, 5 do
        if self:hasBlessing(i) then
            blessings = blessings + 1
        end
    end
    return lossPercent[blessings]
end

function Player.getPremiumTime(self)
    return math.max(0, self:getPremiumEndsAt() - os.time())
end

function Player.setPremiumTime(self, seconds)
    self:setPremiumEndsAt(os.time() + seconds)
    return true
end

function Player.addPremiumTime(self, seconds)
    self:setPremiumTime(self:getPremiumTime() + seconds)
    return true
end

function Player.removePremiumTime(self, seconds)
    local currentTime = self:getPremiumTime()
    if currentTime < seconds then
        return false
    end

    self:setPremiumTime(currentTime - seconds)
    return true
end

function Player.getPremiumDays(self)
    return math.floor(self:getPremiumTime() / 86400)
end

function Player.addPremiumDays(self, days)
    return self:addPremiumTime(days * 86400)
end

function Player.removePremiumDays(self, days)
    return self:removePremiumTime(days * 86400)
end

function Player.isPremium(self)
    return self:getPremiumTime() > 0 or configManager.getBoolean(configKeys.FREE_PREMIUM) or self:hasFlag(PlayerFlag_IsAlwaysPremium)
end

function Player.sendCancelMessage(self, message)
    if type(message) == "number" then
        message = Game.getReturnMessage(message)
    end
    return self:sendTextMessage(MESSAGE_STATUS_SMALL, message)
end

function Player.isUsingOtClient(self)
    return self:getClient().os >= CLIENTOS_OTCLIENT_LINUX
end

function Player.sendExtendedOpcode(self, opcode, buffer)
    if not self:isUsingOtClient() then
        return false
    end

    local networkMessage = NetworkMessage()
    networkMessage:addByte(0x32)
    networkMessage:addByte(opcode)
    networkMessage:addString(buffer)
    networkMessage:sendToPlayer(self)
    networkMessage:delete()
    return true
end

APPLY_SKILL_MULTIPLIER = true
local addSkillTriesFunc = Player.addSkillTries
function Player.addSkillTries(...)
    APPLY_SKILL_MULTIPLIER = false
    local ret = addSkillTriesFunc(...)
    APPLY_SKILL_MULTIPLIER = true
    return ret
end

local addManaSpentFunc = Player.addManaSpent
function Player.addManaSpent(...)
    APPLY_SKILL_MULTIPLIER = false
    local ret = addManaSpentFunc(...)
    APPLY_SKILL_MULTIPLIER = true
    return ret
end

-- Always pass the number through the isValidMoney function first before using the transferMoneyTo
function Player.transferMoneyTo(self, target, amount)
    if not target then
        return false
    end

    -- See if you can afford this transfer
    local balance = self:getBankBalance()
    if amount > balance then
        return false
    end

    -- See if player is online
    local targetPlayer = Player(target.guid)
    if targetPlayer then
        targetPlayer:setBankBalance(targetPlayer:getBankBalance() + amount)
    else
        db.query("UPDATE `players` SET `balance` = `balance` + " .. amount .. " WHERE `id` = '" .. target.guid .. "'")
    end

    self:setBankBalance(self:getBankBalance() - amount)
    return true
end

function Player.canCarryMoney(self, amount)
    -- Anyone can carry as much imaginary money as they desire
    if amount == 0 then
        return true
    end

    -- The 3 below loops will populate these local variables
    local totalWeight = 0
    local inventorySlots = 0

    local currencyItems = Game.getCurrencyItems()
    for index = #currencyItems, 1, -1 do
        local currency = currencyItems[index]
        -- Add currency coins to totalWeight and inventorySlots
        local worth = currency:getWorth()
        local currencyCoins = math.floor(amount / worth)
        if currencyCoins > 0 then
            amount = amount - (currencyCoins * worth)
            while currencyCoins > 0 do
                local count = math.min(100, currencyCoins)
                totalWeight = totalWeight + currency:getWeight(count)
                currencyCoins = currencyCoins - count
                inventorySlots = inventorySlots + 1
            end
        end
    end

    -- If player don't have enough capacity to carry this money
    if self:getFreeCapacity() < totalWeight then
        return false
    end

    -- If player don't have enough available inventory slots to carry this money
    local backpack = self:getSlotItem(CONST_SLOT_BACKPACK)
    if not backpack or backpack:getEmptySlots(true) < inventorySlots then
        return false
    end
    return true
end

function Player.withdrawMoney(self, amount)
    local balance = self:getBankBalance()
    if amount > balance or not self:addMoney(amount) then
        return false
    end

    self:setBankBalance(balance - amount)
    return true
end

function Player.depositMoney(self, amount)
    if not self:removeMoney(amount) then
        return false
    end

    self:setBankBalance(self:getBankBalance() + amount)
    return true
end

function Player.removeTotalMoney(self, amount)
    local moneyCount = self:getMoney()
    local bankCount = self:getBankBalance()
    if amount <= moneyCount then
        self:removeMoney(amount)
        return true
    elseif amount <= (moneyCount + bankCount) then
        if moneyCount ~= 0 then
            self:removeMoney(moneyCount)
            local remains = amount - moneyCount
            self:setBankBalance(bankCount - remains)
            self:sendTextMessage(MESSAGE_INFO_DESCR, ("Paid %d from inventory and %d gold from bank account. Your account balance is now %d gold."):format(moneyCount, amount - moneyCount, self:getBankBalance()))
            return true
        else
            self:setBankBalance(bankCount - amount)
            self:sendTextMessage(MESSAGE_INFO_DESCR, ("Paid %d gold from bank account. Your account balance is now %d gold."):format(amount, self:getBankBalance()))
            return true
        end
    end
    return false
end

function Player.addLevel(self, amount, round)
    round = round or false
    local level, amount = self:getLevel(), amount or 1
    if amount > 0 then
        return self:addExperience(Game.getExperienceForLevel(level + amount) - (round and self:getExperience() or Game.getExperienceForLevel(level)))
    else
        return self:removeExperience(((round and self:getExperience() or Game.getExperienceForLevel(level)) - Game.getExperienceForLevel(level + amount)))
    end
end

function Player.addMagicLevel(self, value)
    local currentMagLevel = self:getBaseMagicLevel()
    local sum = 0

    if value > 0 then
        while value > 0 do
            sum = sum + self:getVocation():getRequiredManaSpent(currentMagLevel + value)
            value = value - 1
        end

        return self:addManaSpent(sum - self:getManaSpent())
    else
        value = math.min(currentMagLevel, math.abs(value))
        while value > 0 do
            sum = sum + self:getVocation():getRequiredManaSpent(currentMagLevel - value + 1)
            value = value - 1
        end

        return self:removeManaSpent(sum + self:getManaSpent())
    end
end

function Player.addSkillLevel(self, skillId, value)
    local currentSkillLevel = self:getSkillLevel(skillId)
    local sum = 0

    if value > 0 then
        while value > 0 do
            sum = sum + self:getVocation():getRequiredSkillTries(skillId, currentSkillLevel + value)
            value = value - 1
        end

        return self:addSkillTries(skillId, sum - self:getSkillTries(skillId))
    else
        value = math.min(currentSkillLevel, math.abs(value))
        while value > 0 do
            sum = sum + self:getVocation():getRequiredSkillTries(skillId, currentSkillLevel - value + 1)
            value = value - 1
        end

        return self:removeSkillTries(skillId, sum + self:getSkillTries(skillId), true)
    end
end

function Player.addSkill(self, skillId, value, round)
    if skillId == SKILL_LEVEL then
        return self:addLevel(value, round or false)
    elseif skillId == SKILL_MAGLEVEL then
        return self:addMagicLevel(value)
    end
    return self:addSkillLevel(skillId, value)
end

function Player.getWeaponType(self)
    local weapon = self:getSlotItem(CONST_SLOT_LEFT)
    if weapon then
        return weapon:getType():getWeaponType()
    end
    return WEAPON_NONE
end
 
Does this work for tfs 1.3?
Post automatically merged:

doPlayerSetRate does not exist in 1.4. Rates are no longer in C++, now they are calculated in Lua in data/events/scripts/player.lua.
Easiest way to increase player exp is to set some player storage to os.time() on which it should stop increasing exp ex. 1 hour setPlayerStorageValue(cid, 123, os.time() + 3600)

In data/events/scripts/player.lua under:
Lua:
function Player:onGainExperience(source, exp, rawExp)
   if not source or source:isPlayer() then
      return exp
   end
add:
Lua:
-- +50% exp for potion, '20011' is storage from potion config
if self:getStorageValue(20011) >= os.time() then
   exp = exp * 1.5
end

and replace your script with this:
Lua:
local config = {
    rate = 1.5,
    time = 1, -- Hours of Exp Time
    storage = 20011,
    exhauststorage = 9583,
    exhausttime = 43200 -- 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)
        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

    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.")

        setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600)
        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
You don't set exp rate in potion script anymore. You also don't need addEvent to stop it after 1 hour. player.lua controls exp rate and will stop adding +50% when storage 20011 become lower than current time.
Does this work for tfs 1.3?
 
Back
Top