• 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 0.X Help With a Exhaustion "lever"

juansanchez

Intermediate OT User
Joined
Apr 2, 2015
Messages
217
Reaction score
129
Hey everyone, i'm trying to learn how to script myself so i don't have to always ask for a new script when i need one.
So today i was working on this script that is supposed to:

-Check player level or reset.
-Check if the player has used the "lever" before the time.
-Check if there's a player inside the arena already.


If all the requirements are met, the player should teleport inside the arena, a boss should Spawn, and the player should recive a storage so can't use the lever again in X amount of time.
Everything is working fine, except the Storage. I can't seem to give the player a storage so he can't use the lever again, and i couldn't figure out what i did wrong. If anyone can help me i would appreciate it.

I'm using TFS 0.3.7


Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local from, to = {x = 608, y = 172, z = 8}, {x = 621, y = 181, z = 8}
local newPos = {x = 614, y = 177, z = 8}
local time = 20
local reset = 50
local storage = 10123

    if getPlayerReset(cid) < reset then
        return doPlayerSendTextMessage(cid,20, 'Voce precisa de '.. reset ..' resets ou mais.') -- Checks if the player has level to use the lever.
    elseif (exhaustion.check(cid, storage) == TRUE) then
        doPlayerSendTextMessage(cid,20, 'Voce precisa esperar pra puxar a alavanca.') -- Checks if the player has already used the lever.
        return false
    else
        for x = from.x, to.x do
            for y = from.y, to.y do
                local creature = getTopCreature({x = x, y = y, z = from.z})
                if isPlayer(creature.uid) and creature.uid ~= 0 then
                    doSendMagicEffect(getCreaturePosition(cid), 2)
                    doPlayerSendTextMessage(cid,20,"Ja existe um jogador dentro da quest. Aguarde sua vez.") -- Checks if there is someone inside already.
                    return true
                end
            end
        end
    doTeleportThing(cid, newPos)
    exhaustion.set(cid, storage, time)
    doSummonCreature("Deus", {x=614, y=178, z=8})
    return true
    end
end
 
try changing time to higher value. like 60000
that could be time in miliseconds so in this case it will be 1 minute exhaust
 
try replace line 11 to
elseif getPlayerStorageValue(cid, storage) == TRUE then
Also didn't work

@Edit

So i managed to fix it. I just changed exhaustion.check and exhaustion.set for getPlayerStorageValue and setPlayerStorageValue.

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local from, to = {x = 608, y = 172, z = 8}, {x = 621, y = 181, z = 8}
local newPos = {x = 614, y = 177, z = 8}
local cooldown = 20
local reset = 1
local storage = 10123
local k = Deus

    if getPlayerReset(cid) < reset then
        doSendMagicEffect(getCreaturePosition(cid), 2)
        return doPlayerSendTextMessage(cid,20, 'Voce precisa de '.. reset ..' resets ou mais.') -- Checks if the player has level to use the lever.
    elseif getPlayerStorageValue(cid, storage) >= os.time() then
        doPlayerSendTextMessage(cid,20, 'Voce precisa esperar 20 horas por tentativa. Faltam: ' .. getPlayerStorageValue(cid, storage) - os.time()..' segundos pra tentar novamente.') -- Checks if the player has already used the lever.
        doSendMagicEffect(getCreaturePosition(cid), 2)
        return false
    else
        for x = from.x, to.x do
            for y = from.y, to.y do
                local creature = getTopCreature({x = x, y = y, z = from.z})
                if isPlayer(creature.uid) and creature.uid ~= 0 then
                    doSendMagicEffect(getCreaturePosition(cid), 2)
                    doPlayerSendTextMessage(cid,20,"Ja existe um jogador dentro da quest. Aguarde sua vez.") -- Checks if there is someone inside already.
                    return true
                end
            end
        end
    if isInArray(k, getCreatureByName(cid)) then
        doRemoveCreature(k,cid)
    end
    doTeleportThing(cid, newPos)
    setPlayerStorageValue(cid, storage, os.time() + cooldown)
    doSummonCreature("Deus", {x=614, y=178, z=8})
    return true
    end
end
 
Last edited:
Back
Top