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

Lua IN NEED OF: lua check storage time left

marek12

Available for sprite works
Joined
Apr 8, 2020
Messages
398
Solutions
4
Reaction score
395
Hi there, does anyone know/got script that will show remaining storage time?
I am using experience scroll that rises exp stage by 25% for 1 hour.
It would be really nice to have a command that will tell players how much bonus exp time they got left.

here's the script:
LUA:
local config = {
    rate = 1.25,
    storage = 1000,
    expstorage = 1100,
    register = 1200,
    time = 3600,
}

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 == 9004
        doCreatureSay(cid, "Your extra experience rate has been activated! Your experience rate is now: " .. config.rate .. "x higher than normal.", TALKTYPE_ORANGE_1, true, cid)
        setPlayerStorageValue(cid, config.storage, os.time()+config.time)
        doPlayerSetExperienceRate(cid, rates[SKILL__LEVEL]*config.rate)
        doRemoveItem(item.uid,1)
        registerCreatureEvent(cid, "ExpStage")
    else
        doCreatureSay(cid, "You must wait until your extra experience rate expire to use another one!", 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 back to normal.", 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 activated! It is: " .. config.rate .. "x higher than normal.", 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

Using TFS 0.4

Thanks ! :)
 
Solution
B
Something like that will work (untested), obviously if you put this in another file make sure to add the same config data.
LUA:
if getPlayerStorageValue(cid, config.register) == 1 then
     local remaining = getPlayerStorageValue(cid, config.storage) - os.time()
     doCreatureSay(cid, "You have " .. remaining .. " seconds remaining until your extra experience expires.", TALKTYPE_ORANGE_1, true, cid)
end
return true
Something like that will work (untested), obviously if you put this in another file make sure to add the same config data.
LUA:
if getPlayerStorageValue(cid, config.register) == 1 then
     local remaining = getPlayerStorageValue(cid, config.storage) - os.time()
     doCreatureSay(cid, "You have " .. remaining .. " seconds remaining until your extra experience expires.", TALKTYPE_ORANGE_1, true, cid)
end
return true
 
Solution
unfortunately doesnt work :/ no errors in console as well. Tried to modify it but still nothing is helping
 
made a lua file in talkaction, put that into talkaction.xml and executing ingame
Post automatically merged:

changed config.register and config.storage to the right storages as well
Post automatically merged:

also added functionOnSay
Post automatically merged:

okay. sorry. my bad. it is working, but it is scripted that only will show msg when exp scroll is used. Just noticed that
Post automatically merged:

Something like that will work (untested), obviously if you put this in another file make sure to add the same config data.
LUA:
if getPlayerStorageValue(cid, config.register) == 1 then
     local remaining = getPlayerStorageValue(cid, config.storage) - os.time()
     doCreatureSay(cid, "You have " .. remaining .. " seconds remaining until your extra experience expires.", TALKTYPE_ORANGE_1, true, cid)
end
return true
Thanks for that. I had to modify that a little but it is working perfectly!
 
Last edited:
Awesome, glad you got it working! Yeah you can add an else statement to notify the player that they don't have active exp if necessary
 
LUA:
if player:getStorageValue(somethingHere) < os.time() then
-- set storage to os.time() + cooldown
-- do something
else
-- still on cooldown (exhausted)
local cooldown = player:getStorageValue(somethingHere) - os.time()
print(cooldown)
end
 
Back
Top