• 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.X+ Attempt to index global 'exhaustion' Potion problem

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
993
Solutions
5
Reaction score
55
Untitled.png

TFS 1.2
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
ITEM = 12779
local storage = 50000
local wait = 1.5
local pos1 = {x = getPlayerPosition(cid).x + 1, y = getPlayerPosition(cid).y + 0, z = getPlayerPosition(cid).z}
if fromPosition.x ~= CONTAINER_POSITION and exhaustion.get(cid, storage) == FALSE then
REG_HEALTH = 20000
REG_MANA = 20000
doPlayerAddMana(cid, REG_MANA)
doCreatureAddHealth(cid, REG_HEALTH)
doCreatureSay(cid, 'Heal!', TALKTYPE_ORANGE_1)
doSendMagicEffect(pos1, 115)
doRemoveItem(item.uid, 1)
exhaustion.set(cid, storage, wait)
elseif item.itemid == ITEM and exhaustion.get(cid, storage) == FALSE then
REG_HEALTH = 20000
REG_MANA = 20000
doPlayerAddMana(cid, REG_MANA)
doCreatureAddHealth(cid, REG_HEALTH)
doCreatureSay(cid, 'Heal!', TALKTYPE_ORANGE_1)
doSendMagicEffect(pos1, 115)
doRemoveItem(item.uid,1)
exhaustion.set(cid, storage, wait)
else
doPlayerSendCancel(cid, "You are exhausted.")
end
return TRUE
end
 
Solution
Untitled.png

add in your global.lua
Code:
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, flag)
        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...
Untitled.png

add in your global.lua
Code:
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, flag)
        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
}
 
Solution
Back
Top