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

Solved Something on storage

Mera Mero

Guess Who?
Joined
Dec 27, 2014
Messages
417
Reaction score
86
hi ,otlanders i've got script of double exp for Period of time but time isn't working with offline players i mean if that player goes to log the time stop till he is get on :S may you help me ?!
Code:
local config = {
    rate = 1.5, -- 4x More Experience
    time = 1, -- Hours of Exp Time
    storage = 20012
}
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, "Your extra experience rate is now: " .. config.rate .. ". 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
i need this script to work while online and offline
 
The reason your script does not work is because you are using addEvent.
When the player logs off
Code:
local function endExpRate(cid)
if isPlayer(cid) == TRUE then
The server can no longer find that cid and thus that script is finished.
Even if said player was to log back in before function endExpRate was executed, once the player logs back in he will have a different cid assigned to him so function endExpRate(cid) still would not be able to find said player.

The thread @Limos posted contains some code you can put into onLogin to recalculate that addEvent for you so it will work properly. Specifically, this post in that thread: http://otland.net/threads/amulet-of-experience-stage.58109/#post-593427
 
You can remove the prestige functions yourself its what i used on my server.
Code:
local config = { 
    rate = 4,
    storage = 1000,
    expstorage = 1100,
    register = 1200,
    time = 14400,
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerPrestigeP(cid) < 5 then 
        doPlayerSendTextMessage(cid,19, "You need 5 prestige point to buy this.")
    elseif getPlayerPrestigeP (cid) >= 5 and getPlayerStorageValue(cid, config.storage) <= 0 then
        local rates = getPlayerRates(cid)
        setPlayerStorageValue(cid, config.expstorage, rates[SKILL__LEVEL])
        setPlayerStorageValue(cid, config.register, 1)
        itemEx=itemid == 9004
        doCreatureSay(cid, "Your extra experience rate has been activated! It now is: " .. config.rate .. "x added to your former experience rate.", TALKTYPE_ORANGE_1, true, cid)
        setPlayerStorageValue(cid, config.storage, os.time()+config.time)
        doPlayerSetExperienceRate(cid, rates[SKILL__LEVEL]*config.rate)
        doRemovePrestigep(cid, 5)
        registerCreatureEvent(cid, "ExpStage")
    else
        doCreatureSay(cid, "You must finish first exp condition to start other exp condition !", TALKTYPE_ORANGE_1, true, cid)
    end
return true
end
function onThink(cid, interval)
    if getPlayerStorageValue(cid, config.register) == 1 then
        if getPlayerStorageValue(cid, config.storage) <= os.time() then
            doCreatureSay(cid, "Your extra experience rate has finished! It is now normaly experience rate.", TALKTYPE_ORANGE_1, true, cid)
            setPlayerStorageValue(cid, config.storage, 0)
            setPlayerStorageValue(cid, config.register, 0)
            local oldexp = getPlayerStorageValue(cid, config.expstorage)
            doPlayerSetExperienceRate(cid, oldexp)
            unregisterCreatureEvent(cid, "ExpStage")
        end
    end
return true
end
function onLogin(cid)
    if getPlayerStorageValue(cid, config.register) == 1 then
        registerCreatureEvent(cid, "ExpStage")
        local rates = getPlayerRates(cid)
        doCreatureSay(cid, "Your extra experience rate is still here! It is: " .. config.rate .. "x added to your former experience rate.", TALKTYPE_ORANGE_1, true, cid)
        if getPlayerStorageValue(cid, config.storage) > os.time() then
        local oldexp = getPlayerStorageValue(cid, config.expstorage)
        doPlayerSetExperienceRate(cid, oldexp+config.rate)
        end
    end  
return true
end
 
Thanks for @RosOT he helped me by Team viewer
but i found error when my exp time gone
Code:
[14/02/2015 14:58:39] [Error - CreatureScript Interface]
[14/02/2015 14:58:39] mods/scripts/2xexp.lua:onThink
[14/02/2015 14:58:39] Description:
[14/02/2015 14:58:39] mods/scripts/2xexp.lua:33: attempt to call global 'unregisterCreatureEvent' (a nil value)
[14/02/2015 14:58:39] stack traceback:
[14/02/2015 14:58:39]     mods/scripts/2xexp.lua:33: in function <mods/scripts/2xexp.lua:25>
mod script
Code:
local config = {
    rate = 1.5,
    storage = 40000,
    expstorage = 41000,
    register = 1200,
    time = 20,
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, config.storage) <= 0 then
        local rates = getPlayerRates(cid)
        setPlayerStorageValue(cid, config.expstorage, rates[SKILL__LEVEL])
        setPlayerStorageValue(cid, config.register, 1)
        itemEx=itemid == 6527
        doRemoveItem(item.uid, 1)
        doCreatureSay(cid, "Your extra experience rate has been activated! It now is: " .. config.rate .. "x added to your former experience rate.", TALKTYPE_ORANGE_1, true, cid)
        setPlayerStorageValue(cid, config.storage, os.time()+config.time)
        doPlayerSetExperienceRate(cid, rates[SKILL__LEVEL]*config.rate)
        registerCreatureEvent(cid, "ExpStage")
    else
        doCreatureSay(cid, "You must finish first exp condition to start other exp condition !", TALKTYPE_ORANGE_1, true, cid)
    end
return true
end
function onThink(cid, interval)
    if getPlayerStorageValue(cid, config.register) == 1 then
        if getPlayerStorageValue(cid, config.storage) <= os.time() then
            doCreatureSay(cid, "Your extra experience rate has finished! It is now normaly experience rate.", TALKTYPE_ORANGE_1, true, cid)
            setPlayerStorageValue(cid, config.storage, 0)
            setPlayerStorageValue(cid, config.register, 0)
            local oldexp = getPlayerStorageValue(cid, config.expstorage)
            doPlayerSetExperienceRate(cid, oldexp)
            unregisterCreatureEvent(cid, "ExpStage")
        end
    end
return true
end
function onLogin(cid)
    if getPlayerStorageValue(cid, config.register) == 1 then
        registerCreatureEvent(cid, "ExpStage")
        local rates = getPlayerRates(cid)
        doCreatureSay(cid, "Your extra experience rate is still here! It is: " .. config.rate .. "x added to your former experience rate.", TALKTYPE_ORANGE_1, true, cid)
        if getPlayerStorageValue(cid, config.storage) > os.time() then
        local oldexp = getPlayerStorageValue(cid, config.expstorage)
        doPlayerSetExperienceRate(cid, oldexp+config.rate)
        end
    end 
return true
end

YO

bump
 
Last edited by a moderator:
Use the scripts from the link I posted, the script with unregisterCreatureEvent is for TFS 0.4, it does not work on TFS 0.3.6.
All you need is just the scripts I linked.
 
Use the scripts from the link I posted, the script with unregisterCreatureEvent is for TFS 0.4, it does not work on TFS 0.3.6.
All you need is just the scripts I linked.
but this script ,i used it before and it wasn't working with offline players :S i need time to remain if you are online or offline
 
Did you added the login creaturescript? So you have 2 scripts? 1 action script and 1 login creaturescript?
If you did, post how you added it in creaturescripts.xml and what happens.
 
Did you added the login creaturescript? So you have 2 scripts? 1 action script and 1 login creaturescript?
If you did, post how you added it in creaturescripts.xml and what happens.
i used only Action one didn't use creatureevent one i gonna use it and post errors if i get
 
Back
Top