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

Lua Double EXP ITEM tfs 0.3.6

Vitich

Member
Joined
Nov 28, 2012
Messages
266
Reaction score
11
Hi, I got this script, but got a problem. When player logout or die, double exp disabled and can't use more items to get double exp.

Lua:
local config = {
    rate = 2,
    time = 1, -- Hours of Exp Time
    storage = 20014
}
local function endExpRate(cid)
    if isPlayer(cid) == TRUE then
        doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
        setPlayerStorageValue(cid, config.storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getPlayerStorageValue(cid, config.storage) < 0) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have experience rate x2 It will last for ".. config.time .." hours.")
        doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
        setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600)
        addEvent(endExpRate, config.time * 3600 * 1000, cid)
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have extra experience time left.")
    end
    return TRUE
end


19:26 You still have extra experience time left. (it never disabled if i logout/die util double exp is active)

How can I fix that?

Thank you all!
 
Solution
I tested it.

Use scroll = double exp, correctly.
Logout, Login = double exp, working.
after 1 hour = double exp end working.

But.... 02:39 You still have extra experience time left.

try this one

Code:
local config = {
    rate = 2,
    time = 1, -- Hours of Exp Time
    storage = 20014
}
local function endExpRate(cid)
    if isPlayer(cid) == TRUE then
        doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
        setPlayerStorageValue(cid, config.storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, config.storage) < os.time() then...
what ur problem??
@heba hey i tested this script in my server tfs 0.3.6 and i have a problem, when player log out and log in, script doesnt reset exp stage, so player still have a boost, but if he relog after more than 1 min, exp stage back to the normal (for tested i set 1min boost) Can you help me with it?

@edit


I try to do so that after logging out time stops for boost, and after logging in so that the player has as much time as he has left
use this script in login
Lua:
local config = {
    rate = 2, -- 4x More Experience
    storage = 20014
}
local function endExpRate(cid)
    if isPlayer(cid) == TRUE then
        doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
        setPlayerStorageValue(cid, config.storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
end
function onLogin(cid)
    local str = getPlayerStorageValue(cid, config.storage)
    if(str >= 0 and (str - os.time()) > 0) then
        doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your extra exp rate will expire at: " .. os.date("%X", str))
        addEvent(endExpRate, (str - os.time()) * 1000, cid)
    else
        doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
        setPlayerStorageValue(cid, config.storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your exp rate is 1x now")

    end
    return TRUE
end
 
Last edited:
try this one

Code:
local config = {
    rate = 2,
    time = 1, -- Hours of Exp Time
    storage = 20014
}
local function endExpRate(cid)
    if isPlayer(cid) == TRUE then
        doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
        setPlayerStorageValue(cid, config.storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, config.storage) < os.time() then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have experience rate x2 It will last for ".. config.time .." hours.")
        doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
        setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600)
        addEvent(endExpRate, config.time * 3600 * 1000, cid)
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have extra experience time left.")
    end
    return TRUE
end

Hi @heba thanks for the script :D, how can I set a range of level to use the item?
example-
Lua:
if getPlayerStorageValue(cid, config.storage) < os.time()  and getPlayerLevel(player) >= 80, and getPlayerLevel(player) < 400
to make the item be used only at certain stages, or making one type of scroll for each stage of exp

edit.. guess something like this should work didn't test yet

Lua:
local config = {
    rate = 2,
    time = 1, -- Hours of Exp Time
    minimumLevel = 400,
    maximumLevel = 99999,
    storage = 20014
}
local function endExpRate(cid)
    if isPlayer(cid) == TRUE then
        doPlayerSetRate(cid, SKILL__LEVEL, 3) -- config.lua rate
        setPlayerStorageValue(cid, config.storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, config.storage) < os.time() then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have experience rate x2 It will last for ".. config.time .." hours.")
        doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
        setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600)
        addEvent(endExpRate, config.time * 3600 * 1000, cid)
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have extra experience time left.")
    end
    return TRUE
end

 if level < config.minimumLevel then
        doPlayerSendCancel(cid, "You need to be at least "..config.minimumLevel.." to use a scroll.")
        return FALSE
    end
    
if level >= config.maximumLevel then
        doPlayerSendCancel(cid, "Your level is too high for using a scroll.")
        return FALSE
    end
 
Last edited:
i've got a problem, i log my char and when i come back shows 10 min left, but im here for 20 min and exp are 2x
 
Back
Top