• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

not working in script, please help to fix it

pisquila

Member
Joined
Nov 14, 2023
Messages
48
Reaction score
5
tfs 0.4 / 8.60


ERROR:
[20:7:42.474] [Error - Action Interface]
[20:7:42.474] data/actions/scripts/exp_potion.lua:onUse
[20:7:42.474] Description:
[20:7:42.474] data/lib/exp_potion.lua:27: attempt to index field '?' (a nil value)
[20:7:42.474] stack traceback:
[20:7:42.474] data/lib/exp_potion.lua:27: in function <data/lib/exp_potion.lua:14>
[20:7:42.490] (tail call): ?


SCRIPT
local potions = {
[6541] = {needLevel = 10, rate = 3.0, duration = 1800},
[6542] = {needLevel = 20, rate = 5.0, duration = 1800},
[6543] = {needLevel = 30, rate = 7.0, duration = 1800},
[6544] = {needLevel = 40, rate = 9.0, duration = 1800},
[6545] = {needLevel = 50, rate = 11.0, duration = 1800},
[2328] = {needLevel = 55, rate = 13.0, duration = 1800},
}

if not expPotions then
expPotions = {playerData = {}}
end

function expPotions:onUse(cid, item, fromPosition, itemEx, toPosition)
local itemId = item.itemid
local potion = potions[itemId]
if not potion then
return false
end

if getPlayerLevel(cid) < potion.needLevel then
doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
return true
end

local guid = getPlayerGUID(cid)
local expData = self.playerData[guid][itemId]
if not expData then
-- caso alguma nova exp potion seja adicionada às configurações em tempo real
-- alguns jogadores online que tentarem usar, precisarão relogar.
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
return true
end

local now = os.time()
if expData.duration > now then
doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
return true
end

expData.rate = expData.rate + potion.rate
expData.duration = potion.duration + now

doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
potion.rate * 100, string.diff(potion.duration, true)
))

doRemoveItem(item.uid, 1)
return true
end

function expPotions:onLogin(cid)
local guid = getPlayerGUID(cid)

self.playerData[guid] = {}
for itemId in pairs(potions) do
self.playerData[guid][itemId] = {rate = 0, duration = 0}
end
return true
end

function expPotions:getCombo(cid)
local playerData = self.playerData[getPlayerGUID(cid)]
local potionsCombo = 1

if playerData then
for itemId, expData in pairs(playerData) do
potionsCombo = potionsCombo + expData.rate
end
end
return potionsCombo
end

function expPotions:onSay(cid, words, param)
local str = 'Experience Potion Combos:\n'

local playerData = self.playerData[getPlayerGUID(cid)]
if playerData then
for itemId, expData in pairs(playerData) do
str = str .. ('\n%s - %d%%'):format(getItemInfo(itemId).name, expData.rate * 100)
end
end

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
return true
end
 

Attachments

  • sadsadsadsadsadsa.webp
    sadsadsadsadsadsa.webp
    16.1 KB · Views: 9 · VirusTotal
Last edited:
tfs 0.4 / 8.60


ERROR:



SCRIPT
LUA:
local potions = {
    [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
    [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
    [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
    [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
    [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
    [2328] = {needLevel = 55, rate = 13.0, duration = 1800},
}

if not expPotions then
    expPotions = {playerData = {}}
end

function expPotions:onUse(cid, item, fromPosition, itemEx, toPosition)
    local itemId = item.itemid
    local potion = potions[itemId]
    if not potion then
        return false
    end

    if getPlayerLevel(cid) < potion.needLevel then
        doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
        return true
    end

    local guid = getPlayerGUID(cid)
    if not self.playerData[guid] or not self.playerData[guid][itemId] then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
        return true
    end

    local expData = self.playerData[guid][itemId]
    local now = os.time()

    if expData.duration > now then
        doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
        return true
    end

    expData.rate = expData.rate + potion.rate
    expData.duration = now + potion.duration

    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
        potion.rate * 100, string.diff(potion.duration, true)
    ))

    doRemoveItem(item.uid, 1)
    return true
end

function expPotions:onLogin(cid)
    local guid = getPlayerGUID(cid)
    self.playerData[guid] = {}

    for itemId in pairs(potions) do
        self.playerData[guid][itemId] = {rate = 0, duration = 0}
    end
    return true
end

function expPotions:getCombo(cid)
    local playerData = self.playerData[getPlayerGUID(cid)]
    local potionsCombo = 1

    if playerData then
        for _, expData in pairs(playerData) do
            potionsCombo = potionsCombo + expData.rate
        end
    end
    return potionsCombo
end

function expPotions:onSay(cid, words, param)
    local str = 'Experience Potion Combos:\n'
    local playerData = self.playerData[getPlayerGUID(cid)]

    if playerData then
        for itemId, expData in pairs(playerData) do
            str = str .. ('\n%s - %d%%'):format(getItemInfo(itemId).name, expData.rate * 100)
        end
    end

    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
    return true
end
 
Last edited:
Code:
local potions = {
    [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
    [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
    [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
    [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
    [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
    [2328] = {needLevel = 55, rate = 13.0, duration = 1800},
}

if not expPotions then
    expPotions = {playerData = {}}
end

function expPotions:onUse(cid, item, fromPosition, itemEx, toPosition)
    local itemId = item.itemid
    local potion = potions[itemId]
    if not potion then return false end

    if getPlayerLevel(cid) < potion.needLevel then
        doPlayerSendCancel(cid, ('You need to be at least level %d to use this potion.'):format(potion.needLevel))
        return true
    end

    local guid = getPlayerGUID(cid)
    self.playerData[guid] = self.playerData[guid] or {}
    self.playerData[guid][itemId] = self.playerData[guid][itemId] or {rate = 0, duration = 0}

    local expData = self.playerData[guid][itemId]
    local now = os.time()

    if expData.duration > now then
        doCreatureSay(cid, 'You must wait until the current bonus expires before using another.', TALKTYPE_ORANGE_1, false, cid)
        return true
    end

    expData.rate = potion.rate
    expData.duration = now + potion.duration

    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('You now have +%d%% experience for %s.'):format(
        potion.rate * 100, string.diff(potion.duration, true)
    ))

    doRemoveItem(item.uid, 1)
    return true
end

function expPotions:onLogin(cid)
    local guid = getPlayerGUID(cid)
    self.playerData[guid] = {}

    for itemId in pairs(potions) do
        self.playerData[guid][itemId] = {rate = 0, duration = 0}
    end

    return true
end

function expPotions:getCombo(cid)
    local guid = getPlayerGUID(cid)
    local playerData = self.playerData[guid]
    local totalRate = 1

    if playerData then
        for _, expData in pairs(playerData) do
            if os.time() < expData.duration then
                totalRate = totalRate + expData.rate
            end
        end
    end

    return totalRate
end

function expPotions:onSay(cid, words, param)
    local str = 'Active Experience Potions:\n'
    local guid = getPlayerGUID(cid)
    local playerData = self.playerData[guid]

    if playerData then
        for itemId, expData in pairs(playerData) do
            if os.time() < expData.duration then
                local timeLeft = string.diff(expData.duration - os.time(), true)
                str = str .. ('\n%s: +%d%% (%s left)'):format(getItemInfo(itemId).name, expData.rate * 100, timeLeft)
            end
        end
    else
        str = str .. '\nNo active bonuses.'
    end

    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
    return true
end
 
LUA:
local potions = {
    [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
    [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
    [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
    [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
    [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
    [2328] = {needLevel = 55, rate = 13.0, duration = 1800},
}

if not expPotions then
    expPotions = {playerData = {}}
end

function expPotions:onUse(cid, item, fromPosition, itemEx, toPosition)
    local itemId = item.itemid
    local potion = potions[itemId]
    if not potion then
        return false
    end

    if getPlayerLevel(cid) < potion.needLevel then
        doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
        return true
    end

    local guid = getPlayerGUID(cid)
    if not self.playerData[guid] or not self.playerData[guid][itemId] then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
        return true
    end

    local expData = self.playerData[guid][itemId]
    local now = os.time()

    if expData.duration > now then
        doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
        return true
    end

    expData.rate = expData.rate + potion.rate
    expData.duration = now + potion.duration

    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
        potion.rate * 100, string.diff(potion.duration, true)
    ))

    doRemoveItem(item.uid, 1)
    return true
end

function expPotions:onLogin(cid)
    local guid = getPlayerGUID(cid)
    self.playerData[guid] = {}

    for itemId in pairs(potions) do
        self.playerData[guid][itemId] = {rate = 0, duration = 0}
    end
    return true
end

function expPotions:getCombo(cid)
    local playerData = self.playerData[getPlayerGUID(cid)]
    local potionsCombo = 1

    if playerData then
        for _, expData in pairs(playerData) do
            potionsCombo = potionsCombo + expData.rate
        end
    end
    return potionsCombo
end

function expPotions:onSay(cid, words, param)
    local str = 'Experience Potion Combos:\n'
    local playerData = self.playerData[getPlayerGUID(cid)]

    if playerData then
        for itemId, expData in pairs(playerData) do
            str = str .. ('\n%s - %d%%'):format(getItemInfo(itemId).name, expData.rate * 100)
        end
    end

    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
    return true
end
It didn't give any error, but it's not assigning the exp bonus when using the item
Post automatically merged:

Code:
local potions = {
    [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
    [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
    [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
    [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
    [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
    [2328] = {needLevel = 55, rate = 13.0, duration = 1800},
}

if not expPotions then
    expPotions = {playerData = {}}
end

function expPotions:onUse(cid, item, fromPosition, itemEx, toPosition)
    local itemId = item.itemid
    local potion = potions[itemId]
    if not potion then return false end

    if getPlayerLevel(cid) < potion.needLevel then
        doPlayerSendCancel(cid, ('You need to be at least level %d to use this potion.'):format(potion.needLevel))
        return true
    end

    local guid = getPlayerGUID(cid)
    self.playerData[guid] = self.playerData[guid] or {}
    self.playerData[guid][itemId] = self.playerData[guid][itemId] or {rate = 0, duration = 0}

    local expData = self.playerData[guid][itemId]
    local now = os.time()

    if expData.duration > now then
        doCreatureSay(cid, 'You must wait until the current bonus expires before using another.', TALKTYPE_ORANGE_1, false, cid)
        return true
    end

    expData.rate = potion.rate
    expData.duration = now + potion.duration

    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('You now have +%d%% experience for %s.'):format(
        potion.rate * 100, string.diff(potion.duration, true)
    ))

    doRemoveItem(item.uid, 1)
    return true
end

function expPotions:onLogin(cid)
    local guid = getPlayerGUID(cid)
    self.playerData[guid] = {}

    for itemId in pairs(potions) do
        self.playerData[guid][itemId] = {rate = 0, duration = 0}
    end

    return true
end

function expPotions:getCombo(cid)
    local guid = getPlayerGUID(cid)
    local playerData = self.playerData[guid]
    local totalRate = 1

    if playerData then
        for _, expData in pairs(playerData) do
            if os.time() < expData.duration then
                totalRate = totalRate + expData.rate
            end
        end
    end

    return totalRate
end

function expPotions:onSay(cid, words, param)
    local str = 'Active Experience Potions:\n'
    local guid = getPlayerGUID(cid)
    local playerData = self.playerData[guid]

    if playerData then
        for itemId, expData in pairs(playerData) do
            if os.time() < expData.duration then
                local timeLeft = string.diff(expData.duration - os.time(), true)
                str = str .. ('\n%s: +%d%% (%s left)'):format(getItemInfo(itemId).name, expData.rate * 100, timeLeft)
            end
        end
    else
        str = str .. '\nNo active bonuses.'
    end

    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
    return true
end


gave error
[3:22:59.904] [Error - Action Interface]
[3:22:59.904] data/actions/scripts/exp_potion.lua:onUse
[3:22:59.904] Description:
[3:22:59.904] data/lib/exp_potion.lua:41: attempt to call field 'diff' (a nil value)
[3:22:59.904] stack traceback:
[3:22:59.904] data/lib/exp_potion.lua:41: in function <data/lib/exp_potion.lua:14>
[3:22:59.904] (tail call): ?
 

Attachments

  • 33333333333333333.webp
    33333333333333333.webp
    18.9 KB · Views: 1 · VirusTotal
LUA:
local potions = {
    [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
    [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
    [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
    [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
    [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
    [2328] = {needLevel = 55, rate = 13.0, duration = 1800},
}

if not expPotions then
    expPotions = {playerData = {}}
end

-- Optional: define string.diff if not already defined elsewhere in your server
if not string.diff then
    function string.diff(seconds, short)
        local minutes = math.floor(seconds / 60)
        if short then
            return minutes .. ' min'
        else
            return minutes .. ' minutos'
        end
    end
end

function expPotions:onUse(cid, item, fromPosition, itemEx, toPosition)
    local itemId = item.itemid
    local potion = potions[itemId]
    if not potion then
        return false
    end

    if getPlayerLevel(cid) < potion.needLevel then
        doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
        return true
    end

    local guid = getPlayerGUID(cid)
    self.playerData[guid] = self.playerData[guid] or {}
    local expData = self.playerData[guid][itemId]

    if not expData then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
        return true
    end

    local now = os.time()
    if expData.duration > now then
        doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
        return true
    end

    expData.rate = expData.rate + potion.rate
    expData.duration = now + potion.duration

    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
        math.floor(potion.rate * 100), string.diff(potion.duration, true)
    ))

    doRemoveItem(item.uid, 1)
    return true
end

function expPotions:onLogin(cid)
    local guid = getPlayerGUID(cid)
    self.playerData[guid] = {}
    for itemId in pairs(potions) do
        self.playerData[guid][itemId] = {rate = 0, duration = 0}
    end
    return true
end

function expPotions:getCombo(cid)
    local playerData = self.playerData[getPlayerGUID(cid)]
    local potionsCombo = 1

    if playerData then
        for _, expData in pairs(playerData) do
            potionsCombo = potionsCombo + expData.rate
        end
    end
    return potionsCombo
end

function expPotions:onSay(cid, words, param)
    local str = 'Experience Potion Combos:\n'
    local playerData = self.playerData[getPlayerGUID(cid)]

    if playerData then
        for itemId, expData in pairs(playerData) do
            str = str .. ('\n%s - %d%%'):format(getItemInfo(itemId).name, expData.rate * 100)
        end
    end

    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
    return true
end
 
LUA:
local potions = {
    [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
    [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
    [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
    [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
    [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
    [2328] = {needLevel = 55, rate = 13.0, duration = 1800},
}

if not expPotions then
    expPotions = {playerData = {}}
end

-- Optional: define string.diff if not already defined elsewhere in your server
if not string.diff then
    function string.diff(seconds, short)
        local minutes = math.floor(seconds / 60)
        if short then
            return minutes .. ' min'
        else
            return minutes .. ' minutos'
        end
    end
end

function expPotions:onUse(cid, item, fromPosition, itemEx, toPosition)
    local itemId = item.itemid
    local potion = potions[itemId]
    if not potion then
        return false
    end

    if getPlayerLevel(cid) < potion.needLevel then
        doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
        return true
    end

    local guid = getPlayerGUID(cid)
    self.playerData[guid] = self.playerData[guid] or {}
    local expData = self.playerData[guid][itemId]

    if not expData then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
        return true
    end

    local now = os.time()
    if expData.duration > now then
        doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
        return true
    end

    expData.rate = expData.rate + potion.rate
    expData.duration = now + potion.duration

    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
        math.floor(potion.rate * 100), string.diff(potion.duration, true)
    ))

    doRemoveItem(item.uid, 1)
    return true
end

function expPotions:onLogin(cid)
    local guid = getPlayerGUID(cid)
    self.playerData[guid] = {}
    for itemId in pairs(potions) do
        self.playerData[guid][itemId] = {rate = 0, duration = 0}
    end
    return true
end

function expPotions:getCombo(cid)
    local playerData = self.playerData[getPlayerGUID(cid)]
    local potionsCombo = 1

    if playerData then
        for _, expData in pairs(playerData) do
            potionsCombo = potionsCombo + expData.rate
        end
    end
    return potionsCombo
end

function expPotions:onSay(cid, words, param)
    local str = 'Experience Potion Combos:\n'
    local playerData = self.playerData[getPlayerGUID(cid)]

    if playerData then
        for itemId, expData in pairs(playerData) do
            str = str .. ('\n%s - %d%%'):format(getItemInfo(itemId).name, expData.rate * 100)
        end
    end

    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
    return true
end
no error, but the experience bonus is not added
 
I noticed your script has everything combined onUse, onLogin, and onSay all in the same file: data/actions/scripts/exp_potion.lua.
That won't work like that.
This kind of setup would only work if you're using mods. In that case, you can put everything into a single script, and the server will load it automatically without needing to register anything in the XML.
But the way it is now (under actions), you can't mix all those functions in one file. You need to separate each function into its appropriate place.

So, I made it here for you mods
exp_potion.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Experience Potion System" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
    <config name="exp_potion_config"><![CDATA[
        config = {
            potions = {
                [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
                [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
                [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
                [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
                [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
                [2328] = {needLevel = 55, rate = 13.0, duration = 1800}
            },
            storage_base = 30002
        }
    ]]></config>
 
    <action itemid="6541" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
   
        if not potion then
            return false
        end
   
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
   
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
   
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
   
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
   
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
   
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
   
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6542" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
   
        if not potion then
            return false
        end
   
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
   
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
   
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
   
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
   
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
   
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
   
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6543" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
   
        if not potion then
            return false
        end
   
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
   
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
   
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
   
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
   
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
   
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
   
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6544" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
   
        if not potion then
            return false
        end
   
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
   
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
   
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
   
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
   
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
   
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
   
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6545" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
   
        if not potion then
            return false
        end
   
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
   
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
   
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
   
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
   
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
   
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
   
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="2328" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
   
        if not potion then
            return false
        end
   
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
   
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
   
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
   
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
   
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
   
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
   
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <event type="login" name="ExpPotionLogin" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
   
        for itemId, potion in pairs(config.potions) do
            local storageKey = config.storage_base + itemId
            if getPlayerStorageValue(cid, storageKey) == -1 then
                setPlayerStorageValue(cid, storageKey, 0)
            end
        end
    ]]></event>
 
    <talkaction words="/expcombo" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local str = 'Experience Potion Combos:\n'
   
        for itemId, potion in pairs(config.potions) do
            local storageKey = config.storage_base + itemId
            local expData = getPlayerStorageValue(cid, storageKey)
            local now = os.time()
       
            if expData > now then
                str = str .. ('\n%s - %d%% (Ativo)'):format(getItemInfo(itemId).name, potion.rate * 100)
            else
                str = str .. ('\n%s - %d%% (Inativo)'):format(getItemInfo(itemId).name, potion.rate * 100)
            end
        end
   
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
        return true
    ]]></talkaction>
 
    <item id="6541" article="a" name="experience potion level 10" override="yes"/>
    <item id="6542" article="a" name="experience potion level 20" override="yes"/>
    <item id="6543" article="a" name="experience potion level 30" override="yes"/>
    <item id="6544" article="a" name="experience potion level 40" override="yes"/>
    <item id="6545" article="a" name="experience potion level 50" override="yes"/>
    <item id="2328" article="a" name="experience potion level 55" override="yes"/>
</mod>

@pisquila

I recommend that you stop using TFS 0.x and migrate to the latest TFS 1.x nekiro or Sarah 8.60 you can find. Nowadays, there are way more scripts available, ready-to-use systems, improvements, and an active community to help you out.
It's really hard to find people still working with TFS 0.x who can give support. Just my opinion, but I think it's definitely worth switching to TFS 1.x.
 
Last edited:
I noticed your script has everything combined onUse, onLogin, and onSay all in the same file: data/actions/scripts/exp_potion.lua.
That won't work like that.
This kind of setup would only work if you're using mods. In that case, you can put everything into a single script, and the server will load it automatically without needing to register anything in the XML.
But the way it is now (under actions), you can't mix all those functions in one file. You need to separate each function into its appropriate place.

So, I made it here for you mods
exp_potion.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Experience Potion System" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
    <config name="exp_potion_config"><![CDATA[
        config = {
            potions = {
                [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
                [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
                [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
                [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
                [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
                [2328] = {needLevel = 55, rate = 13.0, duration = 1800}
            },
            storage_base = 30002
        }
    ]]></config>
 
    <action itemid="6541" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6542" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6543" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6544" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6545" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="2328" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <event type="login" name="ExpPotionLogin" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
 
        for itemId, potion in pairs(config.potions) do
            local storageKey = config.storage_base + itemId
            if getPlayerStorageValue(cid, storageKey) == -1 then
                setPlayerStorageValue(cid, storageKey, 0)
            end
        end
    ]]></event>
 
    <talkaction words="/expcombo" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local str = 'Experience Potion Combos:\n'
 
        for itemId, potion in pairs(config.potions) do
            local storageKey = config.storage_base + itemId
            local expData = getPlayerStorageValue(cid, storageKey)
            local now = os.time()
   
            if expData > now then
                str = str .. ('\n%s - %d%% (Ativo)'):format(getItemInfo(itemId).name, potion.rate * 100)
            else
                str = str .. ('\n%s - %d%% (Inativo)'):format(getItemInfo(itemId).name, potion.rate * 100)
            end
        end
 
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
        return true
    ]]></talkaction>
 
    <item id="6541" article="a" name="experience potion level 10" override="yes"/>
    <item id="6542" article="a" name="experience potion level 20" override="yes"/>
    <item id="6543" article="a" name="experience potion level 30" override="yes"/>
    <item id="6544" article="a" name="experience potion level 40" override="yes"/>
    <item id="6545" article="a" name="experience potion level 50" override="yes"/>
    <item id="2328" article="a" name="experience potion level 55" override="yes"/>
</mod>

@pisquila

I recommend that you stop using TFS 0.x and migrate to the latest TFS 1.x nekiro or Sarah 8.60 you can find. Nowadays, there are way more scripts available, ready-to-use systems, improvements, and an active community to help you out.
It's really hard to find people still working with TFS 0.x who can give support. Just my opinion, but I think it's definitely worth switching to TFS 1.x.
This script does not work for tfs/otx 0.4, it was made only for 1.x+, the treatment of final experience feedback data is different.
 
Last edited:
This script does not work for tfs/otx 0.4, it was made only for 1.x+, the treatment of final experience feedback data is different.
This script was designed for TFS 0.x using mods, where it's perfectly normal to combine multiple functions (onUse, onLogin, onSay, etc.) into a single .lua file, which is automatically loaded via XML.
Yes, the experience feedback handling is different in version 1.x, but here the focus was on the 0.x structure. I used buypremium_command.xml from TFS 0.4 as a reference, which follows the same logic, and adapted the idea for exp_potion.xml.
I haven't tested it on a server yet, so it might need some adjustments but the approach is consistent with how mods work in TFS 0.x.

 
I noticed your script has everything combined onUse, onLogin, and onSay all in the same file: data/actions/scripts/exp_potion.lua.
That won't work like that.
This kind of setup would only work if you're using mods. In that case, you can put everything into a single script, and the server will load it automatically without needing to register anything in the XML.
But the way it is now (under actions), you can't mix all those functions in one file. You need to separate each function into its appropriate place.

So, I made it here for you mods
exp_potion.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Experience Potion System" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
    <config name="exp_potion_config"><![CDATA[
        config = {
            potions = {
                [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
                [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
                [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
                [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
                [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
                [2328] = {needLevel = 55, rate = 13.0, duration = 1800}
            },
            storage_base = 30002
        }
    ]]></config>
 
    <action itemid="6541" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6542" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <ação itemid="6543" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
        itemId local = item.itemid
        poção local = config.potions[itemId]
 
        se não for poção então
            retornar falso
        fim
 
        se getPlayerLevel(cid) < potion.needLevel então
            doPlayerSendCancel(cid, ('Você precisa ser o nível %d+ para usar esta poção.'):format(potion.needLevel))
            retornar verdadeiro
        fim
 
        guid local = obterGUIDDoJogador(cid)
        chave de armazenamento local = config.storage_base + itemId
        expData local = obterPlayerStorageValue(cid, storageKey)
 
        se expData == -1 então
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            retornar verdadeiro
        fim
 
        local agora = os.time()
        se expData > agora então
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            retornar verdadeiro
        fim
 
        -- Definir nova duração
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(obterPosCoisa(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            poção.taxa * 100, string.diff(poção.duração, verdadeiro)
        ))
 
        doRemoveItem(item.uid, 1)
        retornar verdadeiro
    ]]></ação>
 
    <ação itemid="6544" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
        itemId local = item.itemid
        poção local = config.potions[itemId]
 
        se não for poção então
            retornar falso
        fim
 
        se getPlayerLevel(cid) < potion.needLevel então
            doPlayerSendCancel(cid, ('Você precisa ser o nível %d+ para usar esta poção.'):format(potion.needLevel))
            retornar verdadeiro
        fim
 
        guid local = obterGUIDDoJogador(cid)
        chave de armazenamento local = config.storage_base + itemId
        expData local = obterPlayerStorageValue(cid, storageKey)
 
        se expData == -1 então
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            retornar verdadeiro
        fim
 
        local agora = os.time()
        se expData > agora então
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            retornar verdadeiro
        fim
 
        -- Definir nova duração
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(obterPosCoisa(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            poção.taxa * 100, string.diff(poção.duração, verdadeiro)
        ))
 
        doRemoveItem(item.uid, 1)
        retornar verdadeiro
    ]]></ação>
 
    <ação itemid="6545" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
        itemId local = item.itemid
        poção local = config.potions[itemId]
 
        se não for poção então
            retornar falso
        fim
 
        se getPlayerLevel(cid) < potion.needLevel então
            doPlayerSendCancel(cid, ('Você precisa ser o nível %d+ para usar esta poção.'):format(potion.needLevel))
            retornar verdadeiro
        fim
 
        guid local = obterGUIDDoJogador(cid)
        chave de armazenamento local = config.storage_base + itemId
        expData local = obterPlayerStorageValue(cid, storageKey)
 
        se expData == -1 então
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            retornar verdadeiro
        fim
 
        local agora = os.time()
        se expData > agora então
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            retornar verdadeiro
        fim
 
        -- Definir nova duração
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(obterPosCoisa(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            poção.taxa * 100, string.diff(poção.duração, verdadeiro)
        ))
 
        doRemoveItem(item.uid, 1)
        retornar verdadeiro
    ]]></ação>
 
    <ação itemid="2328" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
        itemId local = item.itemid
        poção local = config.potions[itemId]
 
        se não for poção então
            retornar falso
        fim
 
        se getPlayerLevel(cid) < potion.needLevel então
            doPlayerSendCancel(cid, ('Você precisa ser o nível %d+ para usar esta poção.'):format(potion.needLevel))
            retornar verdadeiro
        fim
 
        guid local = obterGUIDDoJogador(cid)
        chave de armazenamento local = config.storage_base + itemId
        expData local = obterPlayerStorageValue(cid, storageKey)
 
        se expData == -1 então
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            retornar verdadeiro
        fim
 
        local agora = os.time()
        se expData > agora então
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            retornar verdadeiro
        fim
 
        -- Definir nova duração
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(obterPosCoisa(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            poção.taxa * 100, string.diff(poção.duração, verdadeiro)
        ))
 
        doRemoveItem(item.uid, 1)
        retornar verdadeiro
    ]]></ação>
 
    <tipo de evento="login" nome="ExpPotionLogin" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
 
        para itemId, poção em pares (config.potions) faça
            chave de armazenamento local = config.storage_base + itemId
            se getPlayerStorageValue(cid, storageKey) == -1 então
                setPlayerStorageValue(cid, storageKey, 0)
            fim
        fim
    ]]></evento>
 
    <talkaction palavras="/expcombo" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local str = 'Experimente combinações de poções:\n'
 
        para itemId, poção em pares (config.potions) faça
            chave de armazenamento local = config.storage_base + itemId
            expData local = obterPlayerStorageValue(cid, storageKey)
            local agora = os.time()
   
            se expData > agora então
                str = str .. ('\n%s - %d%% (Ativo)'):format(getItemInfo(itemId).name, potion.rate * 100)
            outro
                str = str .. ('\n%s - %d%% (Inativo)'):format(getItemInfo(itemId).name, potion.rate * 100)
            fim
        fim
 
        doPlayerSendTextMessage(cid, DESCRIÇÃO_DE_INFO_DA_MENSAGEM, str)
        retornar verdadeiro
    ]]></talkaction>
 
    <item id="6541" article="a" name="poção de experiência nível 10" override="yes"/>
    <item id="6542" article="a" name="poção de experiência nível 20" override="yes"/>
    <item id="6543" article="a" name="poção de experiência nível 30" override="yes"/>
    <item id="6544" article="a" name="poção de experiência nível 40" override="yes"/>
    <item id="6545" article="a" name="poção de experiência nível 50" override="yes"/>
    <item id="2328" article="a" name="poção de experiência nível 55" override="yes"/>
</mod>
[/CÓDIGO]

[HEADING=3]@[USER=257310]pisquila[/USER][/HEADING]
Recomendo que você pare de usar o TFS 0.x e migre para o TFS 1.x nekiro ou Sarah 8.60 mais recente que encontrar. Hoje em dia, há muito mais scripts disponíveis, sistemas prontos para uso, melhorias e uma comunidade ativa para ajudar você.
É muito difícil encontrar pessoas que ainda trabalhem com o TFS 0.x e que possam dar suporte. É só a minha opinião, mas acho que definitivamente vale a pena migrar para o TFS 1.x.
[/QUOTE]

Error

Em primeiro lugar, agradeço por tentar ajudar!

Infelizmente, não consigo migrar para outras versões do TF. Só sei compilar usando DEV, sem contar que os scripts que eu uso parariam de funcionar, certo?
Esse é o meu "bloqueio" por não migrar!

I noticed your script has everything combined onUse, onLogin, and onSay all in the same file: data/actions/scripts/exp_potion.lua.
That won't work like that.
This kind of setup would only work if you're using mods. In that case, you can put everything into a single script, and the server will load it automatically without needing to register anything in the XML.
But the way it is now (under actions), you can't mix all those functions in one file. You need to separate each function into its appropriate place.

So, I made it here for you mods
exp_potion.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Experience Potion System" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
    <config name="exp_potion_config"><![CDATA[
        config = {
            potions = {
                [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
                [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
                [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
                [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
                [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
                [2328] = {needLevel = 55, rate = 13.0, duration = 1800}
            },
            storage_base = 30002
        }
    ]]></config>
 
    <action itemid="6541" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6542" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6543" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6544" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6545" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="2328" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
 
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
 
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
 
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
 
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
 
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <event type="login" name="ExpPotionLogin" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
 
        for itemId, potion in pairs(config.potions) do
            local storageKey = config.storage_base + itemId
            if getPlayerStorageValue(cid, storageKey) == -1 then
                setPlayerStorageValue(cid, storageKey, 0)
            end
        end
    ]]></event>
 
    <talkaction words="/expcombo" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local str = 'Experience Potion Combos:\n'
 
        for itemId, potion in pairs(config.potions) do
            local storageKey = config.storage_base + itemId
            local expData = getPlayerStorageValue(cid, storageKey)
            local now = os.time()
    
            if expData > now then
                str = str .. ('\n%s - %d%% (Ativo)'):format(getItemInfo(itemId).name, potion.rate * 100)
            else
                str = str .. ('\n%s - %d%% (Inativo)'):format(getItemInfo(itemId).name, potion.rate * 100)
            end
        end
 
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
        return true
    ]]></talkaction>
 
    <item id="6541" article="a" name="experience potion level 10" override="yes"/>
    <item id="6542" article="a" name="experience potion level 20" override="yes"/>
    <item id="6543" article="a" name="experience potion level 30" override="yes"/>
    <item id="6544" article="a" name="experience potion level 40" override="yes"/>
    <item id="6545" article="a" name="experience potion level 50" override="yes"/>
    <item id="2328" article="a" name="experience potion level 55" override="yes"/>
</mod>

@pisquila

I recommend that you stop using TFS 0.x and migrate to the latest TFS 1.x nekiro or Sarah 8.60 you can find. Nowadays, there are way more scripts available, ready-to-use systems, improvements, and an active community to help you out.
It's really hard to find people still working with TFS 0.x who can give support. Just my opinion, but I think it's definitely worth switching to TFS 1.x.
 
Last edited:
Post automatically merged:




gave error
LUA:
local potions = {
    [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
    [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
    [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
    [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
    [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
    [2328] = {needLevel = 55, rate = 13.0, duration = 1800},
}

if not expPotions then
    expPotions = {playerData = {}}
end

function formatTime(seconds)
    local hours = math.floor(seconds / 3600)
    seconds = seconds % 3600
    local minutes = math.floor(seconds / 60)
    seconds = seconds % 60

    local result = ""
    if hours > 0 then result = result .. hours .. "h " end
    if minutes > 0 then result = result .. minutes .. "m " end
    result = result .. seconds .. "s"
    return result
end

function expPotions:onUse(cid, item, fromPosition, itemEx, toPosition)
    local itemId = item.itemid
    local potion = potions[itemId]
    if not potion then return false end

    if getPlayerLevel(cid) < potion.needLevel then
        doPlayerSendCancel(cid, ('You need to be at least level %d to use this potion.'):format(potion.needLevel))
        return true
    end

    local guid = getPlayerGUID(cid)
    self.playerData[guid] = self.playerData[guid] or {}
    self.playerData[guid][itemId] = self.playerData[guid][itemId] or {rate = 0, duration = 0}

    local expData = self.playerData[guid][itemId]
    local now = os.time()

    if expData.duration > now then
        doCreatureSay(cid, 'You must wait until the current bonus expires before using another.', TALKTYPE_ORANGE_1, false, cid)
        return true
    end

    expData.rate = potion.rate
    expData.duration = now + potion.duration

    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('You now have +%d%% experience for %s.'):format(
        potion.rate * 100, formatTime(potion.duration)
    ))

    doRemoveItem(item.uid, 1)
    return true
end

function expPotions:onLogin(cid)
    local guid = getPlayerGUID(cid)
    self.playerData[guid] = {}

    for itemId in pairs(potions) do
        self.playerData[guid][itemId] = {rate = 0, duration = 0}
    end

    return true
end

function expPotions:getCombo(cid)
    local guid = getPlayerGUID(cid)
    local playerData = self.playerData[guid]
    local totalRate = 1

    if playerData then
        for _, expData in pairs(playerData) do
            if os.time() < expData.duration then
                totalRate = totalRate + expData.rate
            end
        end
    end

    return totalRate
end

function expPotions:onSay(cid, words, param)
    local str = 'Active Experience Potions:\n'
    local guid = getPlayerGUID(cid)
    local playerData = self.playerData[guid]

    if playerData then
        for itemId, expData in pairs(playerData) do
            if os.time() < expData.duration then
                local timeLeft = formatTime(expData.duration - os.time())
                str = str .. ('\n%s: +%d%% (%s left)'):format(getItemInfo(itemId).name, expData.rate * 100, timeLeft)
            end
        end
    else
        str = str .. '\nNo active bonuses.'
    end

    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
    return true
end
 
Last edited:
First of all, I appreciate you trying to help!

Unfortunately, I can't migrate to other versions of TF. I only know how to compile using DEV, and not to mention that the scripts I use would stop working, right?
That's my "block" for not migrating!
First of all, I appreciate you trying to help!

Unfortunately, I can't migrate to other versions of TF. I only know how to compile using DEV, and not to mention that the scripts I use would stop working, right?
That's my "block" for not migrating!
I noticed your script has everything combined onUse, onLogin, and onSay all in the same file: data/actions/scripts/exp_potion.lua.
That won't work like that.
This kind of setup would only work if you're using mods. In that case, you can put everything into a single script, and the server will load it automatically without needing to register anything in the XML.
But the way it is now (under actions), you can't mix all those functions in one file. You need to separate each function into its appropriate place.

So, I made it here for you mods
exp_potion.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Experience Potion System" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
    <config name="exp_potion_config"><![CDATA[
        config = {
            potions = {
                [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
                [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
                [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
                [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
                [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
                [2328] = {needLevel = 55, rate = 13.0, duration = 1800}
            },
            storage_base = 30002
        }
    ]]></config>
 
    <action itemid="6541" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
  
        if not potion then
            return false
        end
  
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
  
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
  
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
  
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
  
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
  
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
  
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6542" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
  
        if not potion then
            return false
        end
  
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
  
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
  
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
  
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
  
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
  
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
  
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6543" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
  
        if not potion then
            return false
        end
  
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
  
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
  
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
  
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
  
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
  
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
  
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6544" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
  
        if not potion then
            return false
        end
  
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
  
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
  
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
  
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
  
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
  
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
  
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="6545" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
  
        if not potion then
            return false
        end
  
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
  
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
  
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
  
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
  
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
  
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
  
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <action itemid="2328" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
  
        if not potion then
            return false
        end
  
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
  
        local guid = getPlayerGUID(cid)
        local storageKey = config.storage_base + itemId
        local expData = getPlayerStorageValue(cid, storageKey)
  
        if expData == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.')
            return true
        end
  
        local now = os.time()
        if expData > now then
            doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid)
            return true
        end
  
        -- Set new duration
        setPlayerStorageValue(cid, storageKey, potion.duration + now)
  
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
  
        doRemoveItem(item.uid, 1)
        return true
    ]]></action>
 
    <event type="login" name="ExpPotionLogin" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
  
        for itemId, potion in pairs(config.potions) do
            local storageKey = config.storage_base + itemId
            if getPlayerStorageValue(cid, storageKey) == -1 then
                setPlayerStorageValue(cid, storageKey, 0)
            end
        end
    ]]></event>
 
    <talkaction words="/expcombo" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local str = 'Experience Potion Combos:\n'
  
        for itemId, potion in pairs(config.potions) do
            local storageKey = config.storage_base + itemId
            local expData = getPlayerStorageValue(cid, storageKey)
            local now = os.time()
      
            if expData > now then
                str = str .. ('\n%s - %d%% (Ativo)'):format(getItemInfo(itemId).name, potion.rate * 100)
            else
                str = str .. ('\n%s - %d%% (Inativo)'):format(getItemInfo(itemId).name, potion.rate * 100)
            end
        end
  
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
        return true
    ]]></talkaction>
 
    <item id="6541" article="a" name="experience potion level 10" override="yes"/>
    <item id="6542" article="a" name="experience potion level 20" override="yes"/>
    <item id="6543" article="a" name="experience potion level 30" override="yes"/>
    <item id="6544" article="a" name="experience potion level 40" override="yes"/>
    <item id="6545" article="a" name="experience potion level 50" override="yes"/>
    <item id="2328" article="a" name="experience potion level 55" override="yes"/>
</mod>

@pisquila

I recommend that you stop using TFS 0.x and migrate to the latest TFS 1.x nekiro or Sarah 8.60 you can find. Nowadays, there are way more scripts available, ready-to-use systems, improvements, and an active community to help you out.
It's really hard to find people still working with TFS 0.x who can give support. Just my opinion, but I think it's definitely worth switching to TFS 1.x.

It didn't work
No error, but it didn't add the exp bonus.
 
First of all, I appreciate you trying to help!

Unfortunately, I can't migrate to other versions of TF. I only know how to compile using DEV, and not to mention that the scripts I use would stop working, right?
That's my "block" for not migrating!


It didn't work
No error, but it didn't add the exp bonus.
There are alot tutorials how compile TFS 1.x in the forum just check it, your script is total wrong, what TFS are you using 3777?
 
First of all, I appreciate you trying to help!

Unfortunately, I can't migrate to other versions of TF. I only know how to compile using DEV, and not to mention that the scripts I use would stop working, right?
That's my "block" for not migrating!


It didn't work
No error, but it didn't add the exp bonus.
Check my script and tell me if you find any errors and if the script works.
 
Unfortunately, I can't migrate to other versions of TF. I only know how to compile using DEV, and not to mention that the scripts I use would stop working, right?

You will get way more problems than compile in DEV and some old scripts
Don't waste your time and change to TFS 1.5 8.60
You won't regret it once you changed everything
Annnnnnnd u will for sure lost few features like cliport for GM and cast system (if you even got it in your source) but nothing to cry about if you ask me xD
 
@

pisquila

I had to download TFS 0.x to carefully fix the script...

Without any EXP bonus, I killed the rat and got 37 EXP.
With the bonus, I got 112 EXP.
Be happy use the script!

exp_potion.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Experience Potion System" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
    <config name="exp_potion_config"><![CDATA[
        config = {
            potions = {
                [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
                [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
                [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
                [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
                [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
                [2328] = {needLevel = 55, rate = 13.0, duration = 1800}
            },
            storage_total_exp = 30001,
            storage_exp_end = 30000
        }
    ]]></config>
 
    <action itemid="6541" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
  
        if not potion then
            return false
        end
  
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
  
        local now = os.time()
        local currentExpEnd = getPlayerStorageValue(cid, config.storage_exp_end)
        
        if currentExpEnd > now then
            local timeLeft = currentExpEnd - now
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativo! Aguarde %s para usar outra potion.'):format(string.diff(timeLeft, true)))
            return true
        end
        
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, potion.rate)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
        
        setPlayerStorageValue(cid, config.storage_exp_end, now + potion.duration)
        addEvent(expPotionEnd, potion.duration * 1000, cid)
        
        return true
    ]]></action>
 
    <action itemid="6542" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
  
        if not potion then
            return false
        end
  
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
  
        local now = os.time()
        local currentExpEnd = getPlayerStorageValue(cid, config.storage_exp_end)
        
        if currentExpEnd > now then
            local timeLeft = currentExpEnd - now
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativo! Aguarde %s para usar outra potion.'):format(string.diff(timeLeft, true)))
            return true
        end
        
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, potion.rate)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
        
        setPlayerStorageValue(cid, config.storage_exp_end, now + potion.duration)
        addEvent(expPotionEnd, potion.duration * 1000, cid)
        
        return true
    ]]></action>
 
    <action itemid="6543" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
  
        if not potion then
            return false
        end
  
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
  
        local now = os.time()
        local currentExpEnd = getPlayerStorageValue(cid, config.storage_exp_end)
        
        if currentExpEnd > now then
            local timeLeft = currentExpEnd - now
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativo! Aguarde %s para usar outra potion.'):format(string.diff(timeLeft, true)))
            return true
        end
        
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, potion.rate)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
        
        setPlayerStorageValue(cid, config.storage_exp_end, now + potion.duration)
        addEvent(expPotionEnd, potion.duration * 1000, cid)
        
        return true
    ]]></action>
 
    <action itemid="6544" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
  
        if not potion then
            return false
        end
  
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
  
        local now = os.time()
        local currentExpEnd = getPlayerStorageValue(cid, config.storage_exp_end)
        
        if currentExpEnd > now then
            local timeLeft = currentExpEnd - now
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativo! Aguarde %s para usar outra potion.'):format(string.diff(timeLeft, true)))
            return true
        end
        
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, potion.rate)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
        
        setPlayerStorageValue(cid, config.storage_exp_end, now + potion.duration)
        addEvent(expPotionEnd, potion.duration * 1000, cid)
        
        return true
    ]]></action>
 
    <action itemid="6545" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
  
        if not potion then
            return false
        end
  
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
  
        local now = os.time()
        local currentExpEnd = getPlayerStorageValue(cid, config.storage_exp_end)
        
        if currentExpEnd > now then
            local timeLeft = currentExpEnd - now
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativo! Aguarde %s para usar outra potion.'):format(string.diff(timeLeft, true)))
            return true
        end
        
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, potion.rate)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
        
        setPlayerStorageValue(cid, config.storage_exp_end, now + potion.duration)
        addEvent(expPotionEnd, potion.duration * 1000, cid)
        
        return true
    ]]></action>
 
    <action itemid="2328" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
  
        if not potion then
            return false
        end
  
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
  
        local now = os.time()
        local currentExpEnd = getPlayerStorageValue(cid, config.storage_exp_end)
        
        if currentExpEnd > now then
            local timeLeft = currentExpEnd - now
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativo! Aguarde %s para usar outra potion.'):format(string.diff(timeLeft, true)))
            return true
        end
        
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, potion.rate)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
        
        setPlayerStorageValue(cid, config.storage_exp_end, now + potion.duration)
        addEvent(expPotionEnd, potion.duration * 1000, cid)
        
        return true
    ]]></action>
 
    <event type="login" name="ExpPotionLogin" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        
        local now = os.time()
        local expEnd = getPlayerStorageValue(cid, config.storage_exp_end)
        
        if expEnd <= now then
            setPlayerStorageValue(cid, config.storage_exp_end, 0)
            doPlayerSetExperienceRate(cid, 1)
        else
            local timeLeft = expEnd - now
            doPlayerSetExperienceRate(cid, 3)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Bônus de experiência ativo! Tempo restante: %s'):format(string.diff(timeLeft, true)))
            addEvent(expPotionEnd, timeLeft * 1000, cid)
        end
    ]]></event>
 
    <event type="logout" name="ExpPotionLogout" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        
        local expEnd = getPlayerStorageValue(cid, config.storage_exp_end)
        if expEnd > 0 then
            setPlayerStorageValue(cid, config.storage_exp_end, 0)
            doPlayerSetExperienceRate(cid, 1)
        end
    ]]></event>
 
    <talkaction words="/expcombo" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local str = 'Experience Potion System:\n'
  
        local now = os.time()
        local expEnd = getPlayerStorageValue(cid, config.storage_exp_end)
        
        if expEnd > now then
            str = str .. ('\nBônus ativo: +300%% de experiência')
            str = str .. ('\nTempo restante: %s'):format(string.diff(expEnd - now, true))
        else
            str = str .. '\nNenhum bônus ativo'
        end
        
        str = str .. '\n\nPotions disponíveis:'
        for itemId, potion in pairs(config.potions) do
            str = str .. ('\n%s - +%d%% (Level %d+)'):format(getItemInfo(itemId).name, potion.rate * 100, potion.needLevel)
        end
  
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
        return true
    ]]></talkaction>
 
    <script name="expPotionEnd" event="buffer"><![CDATA[
        function expPotionEnd(cid)
            if isPlayer(cid) then
                doPlayerSetExperienceRate(cid, 1)
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Seu bônus de experiência expirou!')
            end
        end
    ]]></script>
 
    <item id="6541" article="a" name="experience potion level 10" override="yes"/>
    <item id="6542" article="a" name="experience potion level 20" override="yes"/>
    <item id="6543" article="a" name="experience potion level 30" override="yes"/>
    <item id="6544" article="a" name="experience potion level 40" override="yes"/>
    <item id="6545" article="a" name="experience potion level 50" override="yes"/>
    <item id="2328" article="a" name="experience potion level 55" override="yes"/>
</mod>
 
Primeiramente, agradeço por tentar ajudar!

Infelizmente, não consigo migrar para outras versões do TF. Só sei compilar usando DEV, sem contar que os scripts que eu uso parariam de funcionar, certo?
Esse é o meu "bloqueio" para não migrar!


Não funcionou
Nenhum erro, mas não adicionou o bônus de experiência.

First of all, I appreciate you trying to help!

Unfortunately, I can't migrate to other versions of TF. I only know how to compile using DEV, and not to mention that the scripts I use would stop working, right?
That's my "block" for not migrating!


It didn't work
No error, but it didn't add the exp bonus.
The tfs/otx2 experience treatment is from the "doPlayerSetExperienceRate" function, the mods are correct, what you will have to do is call the experience change through onLogin.

For example, you will use a local variable rate = 1 below you add which bonuses the server will have, for example if you use storage as a potion, check if the player has the storage and add rate = rate + "bonus", after going through all of them you trigger the function to change experience, "doPlayerSetExperienceRate(cid, rate)".
 
@

pisquila

Tive que baixar o TFS 0.x para corrigir o script com cuidado...

Sem nenhum bônus de EXP, matei o rato e ganhei 37 EXP.
Como bônus, ganhe 112 EXP.
Fique feliz usando o script!

exp_potion.xml
XML:
<?xml versão="1.0" oficial="UTF-8"?>
<mod name="Sistema de Poção de Experiência" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
    <config nome="exp_potion_config"><![CDATA[
        configuração = {
            poções = {
                [6541] = {needLevel = 10, taxa = 3,0, duração = 1800},
                [6542] = {needLevel = 20, taxa = 5,0, duração = 1800},
                [6543] = {needLevel = 30, taxa = 7,0, duração = 1800},
                [6544] = {needLevel = 40, taxa = 9,0, duração = 1800},
                [6545] = {needLevel = 50, taxa = 11,0, duração = 1800},
                [2328] = {needLevel = 55, taxa = 13,0, duração = 1800}
            },
            exp_total_de_armazenamento = 30001,
            tempo_de_exp_de_armazenamento_final = 30000
        }
    ]]></config>
 
    <ação itemid="6541" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
        itemId local = item.itemid
        poção local = config.potions[itemId]
 
        não é para poção então
            retornar falso
        fim
 
        se getPlayerLevel(cid) < potion.needLevel então
            doPlayerSendCancel(cid, ('Você precisa ser o nível %d+ para usar esta poção.'):format(potion.needLevel))
            retornar verdadeiro
        fim
 
        ágora local = os.time()
        local currentExpEnd = obterPlayerStorageValue(cid, config.storage_exp_end)
    
        se currentExpEnd > agora então
            timeLeft local = currentExpEnd - agora
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativa! Espere %s para usar outra poção.'):format(string.diff(timeLeft, true)))
            retornar verdadeiro
        fim
    
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, poção.taxa)
        doSendMagicEffect(obterPosCoisa(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            poção.taxa * 100, string.diff(poção.duração, verdadeiro)
        ))
    
        setPlayerStorageValue(cid, config.storage_exp_end, agora + poção.duração)
        addEvent(expPotionEnd, poção.duração * 1000, cid)
    
        retornar verdadeiro
    ]]></ação>
 
    <ação itemid="6542" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
        itemId local = item.itemid
        poção local = config.potions[itemId]
 
        não é para poção então
            retornar falso
        fim
 
        se getPlayerLevel(cid) < potion.needLevel então
            doPlayerSendCancel(cid, ('Você precisa ser o nível %d+ para usar esta poção.'):format(potion.needLevel))
            retornar verdadeiro
        fim
 
        ágora local = os.time()
        local currentExpEnd = obterPlayerStorageValue(cid, config.storage_exp_end)
    
        se currentExpEnd > agora então
            timeLeft local = currentExpEnd - agora
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativa! Espere %s para usar outra poção.'):format(string.diff(timeLeft, true)))
            retornar verdadeiro
        fim
    
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, poção.taxa)
        doSendMagicEffect(obterPosCoisa(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            poção.taxa * 100, string.diff(poção.duração, verdadeiro)
        ))
    
        setPlayerStorageValue(cid, config.storage_exp_end, agora + poção.duração)
        addEvent(expPotionEnd, poção.duração * 1000, cid)
    
        retornar verdadeiro
    ]]></ação>
 
    <ação itemid="6543" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
        itemId local = item.itemid
        poção local = config.potions[itemId]
 
        não é para poção então
            retornar falso
        fim
 
        se getPlayerLevel(cid) < potion.needLevel então
            doPlayerSendCancel(cid, ('Você precisa ser o nível %d+ para usar esta poção.'):format(potion.needLevel))
            retornar verdadeiro
        fim
 
        ágora local = os.time()
        local currentExpEnd = obterPlayerStorageValue(cid, config.storage_exp_end)
    
        se currentExpEnd > agora então
            timeLeft local = currentExpEnd - agora
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativa! Espere %s para usar outra poção.'):format(string.diff(timeLeft, true)))
            retornar verdadeiro
        fim
    
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, poção.taxa)
        doSendMagicEffect(obterPosCoisa(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            poção.taxa * 100, string.diff(poção.duração, verdadeiro)
        ))
    
        setPlayerStorageValue(cid, config.storage_exp_end, agora + poção.duração)
        addEvent(expPotionEnd, poção.duração * 1000, cid)
    
        retornar verdadeiro
    ]]></ação>
 
    <ação itemid="6544" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
        itemId local = item.itemid
        poção local = config.potions[itemId]
 
        não é para poção então
            retornar falso
        fim
 
        se getPlayerLevel(cid) < potion.needLevel então
            doPlayerSendCancel(cid, ('Você precisa ser o nível %d+ para usar esta poção.'):format(potion.needLevel))
            retornar verdadeiro
        fim
 
        ágora local = os.time()
        local currentExpEnd = obterPlayerStorageValue(cid, config.storage_exp_end)
    
        se currentExpEnd > agora então
            timeLeft local = currentExpEnd - agora
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativa! Espere %s para usar outra poção.'):format(string.diff(timeLeft, true)))
            retornar verdadeiro
        fim
    
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, poção.taxa)
        doSendMagicEffect(obterPosCoisa(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            poção.taxa * 100, string.diff(poção.duração, verdadeiro)
        ))
    
        setPlayerStorageValue(cid, config.storage_exp_end, agora + poção.duração)
        addEvent(expPotionEnd, poção.duração * 1000, cid)
    
        retornar verdadeiro
    ]]></ação>
 
    <ação itemid="6545" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
        itemId local = item.itemid
        poção local = config.potions[itemId]
 
        não é para poção então
            retornar falso
        fim
 
        se getPlayerLevel(cid) < potion.needLevel então
            doPlayerSendCancel(cid, ('Você precisa ser o nível %d+ para usar esta poção.'):format(potion.needLevel))
            retornar verdadeiro
        fim
 
        ágora local = os.time()
        local currentExpEnd = obterPlayerStorageValue(cid, config.storage_exp_end)
    
        se currentExpEnd > agora então
            timeLeft local = currentExpEnd - agora
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativa! Espere %s para usar outra poção.'):format(string.diff(timeLeft, true)))
            retornar verdadeiro
        fim
    
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, poção.taxa)
        doSendMagicEffect(obterPosCoisa(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            poção.taxa * 100, string.diff(poção.duração, verdadeiro)
        ))
    
        setPlayerStorageValue(cid, config.storage_exp_end, agora + poção.duração)
        addEvent(expPotionEnd, poção.duração * 1000, cid)
    
        retornar verdadeiro
    ]]></ação>
 
    <ação itemid="2328" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
        itemId local = item.itemid
        poção local = config.potions[itemId]
 
        não é para poção então
            retornar falso
        fim
 
        se getPlayerLevel(cid) < potion.needLevel então
            doPlayerSendCancel(cid, ('Você precisa ser o nível %d+ para usar esta poção.'):format(potion.needLevel))
            retornar verdadeiro
        fim
 
        ágora local = os.time()
        local currentExpEnd = obterPlayerStorageValue(cid, config.storage_exp_end)
    
        se currentExpEnd > agora então
            timeLeft local = currentExpEnd - agora
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativa! Espere %s para usar outra poção.'):format(string.diff(timeLeft, true)))
            retornar verdadeiro
        fim
    
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, poção.taxa)
        doSendMagicEffect(obterPosCoisa(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            poção.taxa * 100, string.diff(poção.duração, verdadeiro)
        ))
    
        setPlayerStorageValue(cid, config.storage_exp_end, agora + poção.duração)
        addEvent(expPotionEnd, poção.duração * 1000, cid)
    
        retornar verdadeiro
    ]]></ação>
 
    <tipo de evento="login" nome="ExpPotionLogin" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
    
        ágora local = os.time()
        expEnd local = obterValorDeArmazenamentoDoJogador(cid, config.storage_exp_end)
    
        se expEnd <= agora então
            setPlayerStorageValue(cid, config.storage_exp_end, 0)
            doPlayerSetExperienceRate(cid, 1)
        outro
            hora localEsquerda = expEnd - agora
            doPlayerSetExperienceRate(cid, 3)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Bônus de experiência ativa! Tempo restante: %s'):format(string.diff(timeLeft, true)))
            addEvent(expPotionEnd, tempo Restante * 1000, cid)
        fim
    ]]></evento>
 
    <tipo de evento="logout" nome="ExpPotionLogout" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
    
        expEnd local = obterValorDeArmazenamentoDoJogador(cid, config.storage_exp_end)
        se expEnd > 0 então
            setPlayerStorageValue(cid, config.storage_exp_end, 0)
            doPlayerSetExperienceRate(cid, 1)
        fim
    ]]></evento>
 
    <talkaction palavras="/expcombo" evento="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local str = 'Sistema de Poção de Experiência:\n'
 
        ágora local = os.time()
        expEnd local = obterValorDeArmazenamentoDoJogador(cid, config.storage_exp_end)
    
        se expEnd > agora então
            str = str .. ('\nBônus ativo: +300%% de experiência')
            str = str .. ('\nTempo restante: %s'):format(string.diff(expEnd - now, true))
        outro
            str = str .. '\nNenhum bônus ativo'
        fim
    
        str = str .. '\n\nPoções disponíveis:'
        para itemId, poção em pares (config.potions) faça
            str = str .. ('\n%s - +%d%% (Nível %d+)'):format(getItemInfo(itemId).name, potion.rate * 100, potion.needLevel)
        fim
 
        doPlayerSendTextMessage(cid, DESCRIÇÃO_DE_INFO_DA_MENSAGEM,str)
        retornar verdadeiro
    ]]></talkaction>
 
    <script nome="expPotionEnd" evento="buffer"><![CDATA[
        função expPotionEnd(cid)
            se isPlayer(cid) então
                doPlayerSetExperienceRate(cid, 1)
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Seu bônus de experiência expirou!')
            fim
        fim
    ]]></script>
 
    <item id="6541" article="a" name="poção de experiência nível 10" override="yes"/>
    <item id="6542" article="a" name="poção de experiência nível 20" override="yes"/>
    <item id="6543" article="a" name="poção de experiência nível 30" override="yes"/>
    <item id="6544" article="a" name="poção de experiência nível 40" override="yes"/>
    <item id="6545" article="a" name="poção de experiência nível 50" override="yes"/>
    <item id="2328" article="a" name="poção de experiência nível 55" override="yes"/>
</mod> 
[/QUOTE]










Aqui não funcionou, deu um erro enorme 
Aqui não funcionou, deu um erro enorme!
 
@

pisquila

I had to download TFS 0.x to carefully fix the script...

Without any EXP bonus, I killed the rat and got 37 EXP.
With the bonus, I got 112 EXP.
Be happy use the script!

exp_potion.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Experience Potion System" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
    <config name="exp_potion_config"><![CDATA[
        config = {
            potions = {
                [6541] = {needLevel = 10, rate = 3.0, duration = 1800},
                [6542] = {needLevel = 20, rate = 5.0, duration = 1800},
                [6543] = {needLevel = 30, rate = 7.0, duration = 1800},
                [6544] = {needLevel = 40, rate = 9.0, duration = 1800},
                [6545] = {needLevel = 50, rate = 11.0, duration = 1800},
                [2328] = {needLevel = 55, rate = 13.0, duration = 1800}
            },
            storage_total_exp = 30001,
            storage_exp_end = 30000
        }
    ]]></config>
 
    <action itemid="6541" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local now = os.time()
        local currentExpEnd = getPlayerStorageValue(cid, config.storage_exp_end)
       
        if currentExpEnd > now then
            local timeLeft = currentExpEnd - now
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativo! Aguarde %s para usar outra potion.'):format(string.diff(timeLeft, true)))
            return true
        end
       
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, potion.rate)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
       
        setPlayerStorageValue(cid, config.storage_exp_end, now + potion.duration)
        addEvent(expPotionEnd, potion.duration * 1000, cid)
       
        return true
    ]]></action>
 
    <action itemid="6542" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local now = os.time()
        local currentExpEnd = getPlayerStorageValue(cid, config.storage_exp_end)
       
        if currentExpEnd > now then
            local timeLeft = currentExpEnd - now
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativo! Aguarde %s para usar outra potion.'):format(string.diff(timeLeft, true)))
            return true
        end
       
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, potion.rate)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
       
        setPlayerStorageValue(cid, config.storage_exp_end, now + potion.duration)
        addEvent(expPotionEnd, potion.duration * 1000, cid)
       
        return true
    ]]></action>
 
    <action itemid="6543" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local now = os.time()
        local currentExpEnd = getPlayerStorageValue(cid, config.storage_exp_end)
       
        if currentExpEnd > now then
            local timeLeft = currentExpEnd - now
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativo! Aguarde %s para usar outra potion.'):format(string.diff(timeLeft, true)))
            return true
        end
       
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, potion.rate)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
       
        setPlayerStorageValue(cid, config.storage_exp_end, now + potion.duration)
        addEvent(expPotionEnd, potion.duration * 1000, cid)
       
        return true
    ]]></action>
 
    <action itemid="6544" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local now = os.time()
        local currentExpEnd = getPlayerStorageValue(cid, config.storage_exp_end)
       
        if currentExpEnd > now then
            local timeLeft = currentExpEnd - now
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativo! Aguarde %s para usar outra potion.'):format(string.diff(timeLeft, true)))
            return true
        end
       
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, potion.rate)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
       
        setPlayerStorageValue(cid, config.storage_exp_end, now + potion.duration)
        addEvent(expPotionEnd, potion.duration * 1000, cid)
       
        return true
    ]]></action>
 
    <action itemid="6545" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local now = os.time()
        local currentExpEnd = getPlayerStorageValue(cid, config.storage_exp_end)
       
        if currentExpEnd > now then
            local timeLeft = currentExpEnd - now
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativo! Aguarde %s para usar outra potion.'):format(string.diff(timeLeft, true)))
            return true
        end
       
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, potion.rate)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
       
        setPlayerStorageValue(cid, config.storage_exp_end, now + potion.duration)
        addEvent(expPotionEnd, potion.duration * 1000, cid)
       
        return true
    ]]></action>
 
    <action itemid="2328" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local itemId = item.itemid
        local potion = config.potions[itemId]
 
        if not potion then
            return false
        end
 
        if getPlayerLevel(cid) < potion.needLevel then
            doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
            return true
        end
 
        local now = os.time()
        local currentExpEnd = getPlayerStorageValue(cid, config.storage_exp_end)
       
        if currentExpEnd > now then
            local timeLeft = currentExpEnd - now
            doPlayerSendCancel(cid, ('Você já tem um bônus de experiência ativo! Aguarde %s para usar outra potion.'):format(string.diff(timeLeft, true)))
            return true
        end
       
        doRemoveItem(item.uid, 1)
        doPlayerSetExperienceRate(cid, potion.rate)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format(
            potion.rate * 100, string.diff(potion.duration, true)
        ))
       
        setPlayerStorageValue(cid, config.storage_exp_end, now + potion.duration)
        addEvent(expPotionEnd, potion.duration * 1000, cid)
       
        return true
    ]]></action>
 
    <event type="login" name="ExpPotionLogin" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
       
        local now = os.time()
        local expEnd = getPlayerStorageValue(cid, config.storage_exp_end)
       
        if expEnd <= now then
            setPlayerStorageValue(cid, config.storage_exp_end, 0)
            doPlayerSetExperienceRate(cid, 1)
        else
            local timeLeft = expEnd - now
            doPlayerSetExperienceRate(cid, 3)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Bônus de experiência ativo! Tempo restante: %s'):format(string.diff(timeLeft, true)))
            addEvent(expPotionEnd, timeLeft * 1000, cid)
        end
    ]]></event>
 
    <event type="logout" name="ExpPotionLogout" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
       
        local expEnd = getPlayerStorageValue(cid, config.storage_exp_end)
        if expEnd > 0 then
            setPlayerStorageValue(cid, config.storage_exp_end, 0)
            doPlayerSetExperienceRate(cid, 1)
        end
    ]]></event>
 
    <talkaction words="/expcombo" event="buffer"><![CDATA[
        domodlib('exp_potion_config')
        local str = 'Experience Potion System:\n'
 
        local now = os.time()
        local expEnd = getPlayerStorageValue(cid, config.storage_exp_end)
       
        if expEnd > now then
            str = str .. ('\nBônus ativo: +300%% de experiência')
            str = str .. ('\nTempo restante: %s'):format(string.diff(expEnd - now, true))
        else
            str = str .. '\nNenhum bônus ativo'
        end
       
        str = str .. '\n\nPotions disponíveis:'
        for itemId, potion in pairs(config.potions) do
            str = str .. ('\n%s - +%d%% (Level %d+)'):format(getItemInfo(itemId).name, potion.rate * 100, potion.needLevel)
        end
 
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
        return true
    ]]></talkaction>
 
    <script name="expPotionEnd" event="buffer"><![CDATA[
        function expPotionEnd(cid)
            if isPlayer(cid) then
                doPlayerSetExperienceRate(cid, 1)
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Seu bônus de experiência expirou!')
            end
        end
    ]]></script>
 
    <item id="6541" article="a" name="experience potion level 10" override="yes"/>
    <item id="6542" article="a" name="experience potion level 20" override="yes"/>
    <item id="6543" article="a" name="experience potion level 30" override="yes"/>
    <item id="6544" article="a" name="experience potion level 40" override="yes"/>
    <item id="6545" article="a" name="experience potion level 50" override="yes"/>
    <item id="2328" article="a" name="experience potion level 55" override="yes"/>
</mod>

Na questao do bonus de exp, esta funcioando normal. porem da esse error no console, e normal ?
Uso a tfs 0.4 / 860 / 3996 nvs




[17:50:03.538] [Error - Action Interface]
[17:50:03.540] local cid = 268452082
[17:50:03.542] local item = {
[17:50:03.545] uid = 70030,
[17:50:03.547] itemid = 6541,
[17:50:03.549] type = 72,
[17:50:03.550] actionid = 0
[17:50:03.552] }
[17:50:03.554] local fromPosition = {
[17:50:03.556] x = 65535,
[17:50:03.557] y = 64,
[17:50:03.561] z = 3,
[17:50:03.563] stackpos = 3
[17:50:03.565] }
[17:50:03.566] local itemEx = {
[17:50:03.568] uid = 70030,
[17:50:03.570] itemid = 6541,
[17:50:03.571] type = 72,
[17:50:03.573] actionid = 0
[17:50:03.577] }
[17:50:03.579] local toPosition = {
[17:50:03.581] x = 65535,
[17:50:03.582] y = 64,
[17:50:03.584] z = 3,
[17:50:03.586] stackpos = 3
[17:50:03.587] }
[17:50:03.589] domodlib('exp_potion_config')
[17:50:03.593] local itemId = item.itemid
[17:50:03.595] local potion = config.potions[itemId]
[17:50:03.596]
[17:50:03.598] if not potion then
[17:50:03.599] return false
[17:50:03.601] end
[17:50:03.603]
[17:50:03.605] if getPlayerLevel(cid) < potion.needLevel then
[17:50:03.608] doPlayerSendCancel(cid, ('Voce precisa ser level %d+ para usar esta potion.'):format(potion.needLevel))
[17:50:03.610] return true
[17:50:03.612] end
[17:50:03.614]
[17:50:03.615] local now = os.time()
[17:50:03.617] local currentExpEnd = getPlayerStorageValue(cid, config.storage_exp_end)
[17:50:03.619]
[17:50:03.623] if currentExpEnd > now then
[17:50:03.625] local timeLeft = currentExpEnd - now
[17:50:03.626] doPlayerSendCancel(cid, ('Voce ja tem um bonus de experiencia ativo! Aguarde %s para usar outra potion.'):format(string.diff(timeLeft, true)))
[17:50:03.628] return true
[17:50:03.630] end
[17:50:03.631]
[17:50:03.633] doRemoveItem(item.uid, 1)
[17:50:03.635] doPlayerSetExperienceRate(cid, potion.rate)
[17:50:03.640] doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
[17:50:03.641] doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora Voce tem +%d%% de experiencia por %s.'):format(
[17:50:03.643] potion.rate * 100, string.diff(potion.duration, true)
[17:50:03.645] ))
[17:50:03.647]
[17:50:03.648] setPlayerStorageValue(cid, config.storage_exp_end, now + potion.duration)
[17:50:03.650] addEvent(expPotionEnd, potion.duration * 1000, cid)
[17:50:03.654]
[17:50:03.656] return true
[17:50:03.658]
[17:50:03.660] Description:
[17:50:03.661] [string "LuaInterface::loadBuffer"]:52: attempt to call field 'diff' (a nil value)
 
Back
Top