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

TFS 1.3 Storage time check

Musaab

NoxOts
Premium User
Joined
May 13, 2010
Messages
177
Reaction score
74
Location
Sweden
Hey!

So i have a exp scroll that uses storage
Script below for to check how long time the +exp scroll has left.

Lua:
function onSay(cid, words, param)
    local player = Player(cid)

    local remaining = getPlayerStorageValue(cid, 9997) - os.time()
if remaining <= 0 then
        player:sendCancelMessage("You do not have any experience boosts active!")
    else
        
     doCreatureSay(cid, "You have " .. remaining .. " seconds remaining until your extra experience expires.", TALKTYPE_ORANGE_1, true, cid)
    end
    return false
end

First off i would like it to change from seconds to minutes instead since its for 1 hour.
Other then that the script works just fine. Its just showing seconds instead of minutes.



Second issue i have is that i got a global exp booster.

i tried to apply same script above to this other global exp boost also without any success.
Ofc i changed the storage to the storage used by global booster but when i use command to check if any global exp booster is active it says that there is none active.

Global exp boost script

Code:
_GLOBAL_EXP_BOOST_RATE = 0.5 --- rate 2.0 mean 2x exp
_GLOBAL_EXP_BOOST_STORAGE = 66574 --- storage
_GLOBAL_EXP_BOOST_TIME = 1 --- how many hours


local cfg = {
_useEffect = true,
effect = 28
}

function endGlobalExpRate(cid)
        setGlobalStorageValue(cid, _GLOBAL_EXP_BOOST_STORAGE, -1)
end

function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local player = Player(cid)

if getGlobalStorageValue(_GLOBAL_EXP_BOOST_STORAGE) > 0 then
player:say('Global Exp boost is activated you cant use this scroll at this moment.', TALKTYPE_MONSTER_SAY)
return true
end

if getGlobalStorageValue(_GLOBAL_EXP_BOOST_STORAGE) < os.time() then
setGlobalStorageValue(_GLOBAL_EXP_BOOST_STORAGE, os.time() + _GLOBAL_EXP_BOOST_TIME * 3600)
addEvent(endGlobalExpRate, _GLOBAL_EXP_BOOST_TIME * 3600 * 1000, cid.uid)
broadcastMessage(player:getName() .. " have activated the global exp boost. You will gain + 50% exp rate for 1 hour. Happy Hunting!" , MESSAGE_STATUS_WARNING)
Item(item.uid):remove(1)
if (cfg._useEffect) then
player:getPosition():sendMagicEffect(cfg.effect)
end
end

return true
end
 

kamilcioo

Veteran OT User
Joined
Jul 25, 2008
Messages
952
Solutions
1
Reaction score
277
So thats fixed! Thank u!

Anyone knows how to convert the seconds to minutes?
Easily. One minute is 60 seconds.
1 minute = 60 seconds.
Lua:
Local isMinutes = remaining > 60
(isMinutes and math.floor((remaining / 60)) or remaining) .. " " .. (isMinutes and "minutes" or "seconds)
Its easy to add check also to print minute instead of minutes if there is one left. I think u will get the pointy.
 
Top