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

Exhaustion function

KylerXX

Active Member
Joined
Jun 24, 2010
Messages
439
Reaction score
30
Hello guys:)
I dont know if this script is already posted on this forum :S this is exhaustion script, this is functions:
add Function
addExhaust(cid, seconds, interval)
check Function
isExh(cid)
Here are the codes:
add Function
Lua:
function addExhaust(cid, seconds, interval)
local storage = 90099 -- storage using exhaustion, needs only 1
if getPlayerStorageValue(cid, storage) == -1 then
doPlayerSendCancel(cid, "You are exhausted.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
addEvent(setPlayerStorageValue, seconds, cid, storage, 2)
addEvent(setPlayerStorageValue, seconds+interval, cid, storage, -1)
end
end

check Function
Lua:
function isExh(cid) 
local storage = 90099 -- storage using exhaustion, needs only 1
if getPlayerStorageValue(cid, storage) == -1 then
return true
end
end

Example:
Lua:
if isExh(cid) then
addExhaust(cid,5000, 1000)
else
-- execution
end


:thumbup:
 
don't forget TFS has it by default (data/lib/034-exhaustion.lua)
Lua:
exhaustion =
{
    check = function (cid, storage)
        if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        return getPlayerStorageValue(cid, storage) >= os.time(t)
    end,

    get = function (cid, storage)
        if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        local exhaust = getPlayerStorageValue(cid, storage)
        if(exhaust > 0) then
            local left = exhaust - os.time(t)
            if(left >= 0) then
                return left
            end
        end

        return false
    end,

    set = function (cid, storage, time)
        setPlayerStorageValue(cid, storage, os.time(t) + time)
    end,

    make = function (cid, storage, time)
        local exhaust = exhaustion.get(cid, storage)
        if(not exhaust) then
            exhaustion.set(cid, storage, time)
            return true
        end

        return false
    end
}
 
but I made this exhaustion mode why in many scripts I need to put exhaustion (talkaction,action, etc..)

but thanks xdd
 
Yes, TFS exhaustion functions work for any script ^_^
 
Back
Top