• 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+ Can someone make it work

liqeen

Active Member
Joined
Nov 26, 2014
Messages
151
Solutions
1
Reaction score
30
Location
Poland
LUA:
local config = {
    level = 50,
    maxTimes = 1,
    timeToWait = {1, 'day'},
    maxPlayers = 1,
    room = {fromPos = Position(1064, 1064, 7), toPos = Position(1069, 1069, 7)},
    newPos = Position(1066, 1066, 7),
    stone = {id = 1304, pos = Position(1059, 1065, 7)},
    timeToKick = {0.3, 'min'},
    kickPos = Position(1060, 1070, 7),
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:hasExhaustion(84309) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end
    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, -1)
    end
    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    if player:getLevel() < config.level then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF
        )
        return true
    end
    local max_times = player:getStorageValue(84310) > 0 and player:getStorageValue(84310) or 0
    if (max_times + 1) == config.maxTimes then
        player:setStorageValue(84309, mathtime(config.timeToWait) + os.time())
    end
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if stone then
        stone:getPosition():sendMagicEffect(CONST_ME_POFF)
        stone:remove()
    end
    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    player:setStorageValue(84310, math.max(0, max_times) + 1)
    addEvent(kickFromArea, mathtime(config.timeToKick) * 1000, player.uid)
    return true
end

function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end

function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end

function kickFromArea(cid)
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if not stone then
        Game.createItem(config.stone.id, 1, config.stone.pos)
    end
    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos) then
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end

The problem is with value maxTimes, it does not work.. Player still can use the stone no matter how much times he already used him.: s Can someone make it work?

Im using this also
Player.setExhaustion, Player.getExhaustion [TFS 1.0] (https://otland.net/threads/player-setexhaustion-player-getexhaustion-tfs-1-0.224233/)
 
Last edited by a moderator:
Solution
Ok I tested it with debug version and it looks like this :
Code:
Using stone on character Ek Tester - whose storage 84310 is on value -1.
Checking if that value is equal to config.maxTimes (2.
It is not.
Storage 84310 was -1, so we set it to the default now -> 0.
Checking if player has any exhaustion set to storage 84309 (which is on value: -1).
Stone used.
Player's storage 84310 is currently on value:0.
Increasing it by +1 at the moment...
Script executed.
-------------

Using stone on character Ek Tester - whose storage 84310 is on value 1.
Checking if that value is equal to config.maxTimes (2.
It is not.
Checking if player has any exhaustion set to storage 84309 (which is on value: -1).
Stone used.
Player's storage 84310 is currently...
LUA:
local config = {
    level = 50,
    maxTimes = 2,
    timeToWait = {1, 'day'},
    maxPlayers = 1,
    room = {fromPos = Position(1064, 1064, 7), toPos = Position(1069, 1069, 7)},
    newPos = Position(1066, 1066, 7),
    stone = {id = 1304, pos = Position(1059, 1065, 7)},
    timeToKick = {0.3, 'min'},
    kickPos = Position(1060, 1070, 7),
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    -- Check if we have reached max times.
    -- If yes, set 'times used' counter to 0; set exhaustion to timeToWait --> After that, the exhaustion check will happen and prevent the script from executing.
    -- If not, increase 'times used' counter by 1 at the end of the script when we are sure the player got to use it. In case it is on -1 (default, set it to 0 once). Easier to work with 0 than -1.
    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, 0)
         player:setStorageValue(84309, mathtime(config.timeToWait) + os.time())
    else
        if player:getStorageValue(84310) == -1 then 
            player:setStorageValue(84310, 0) 
        end
     end
     
    if player:hasExhaustion(84309) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end
    
    if player:getLevel() < config.level then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    
    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if stone then
        stone:getPosition():sendMagicEffect(CONST_ME_POFF)
        stone:remove()
    end
    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    addEvent(kickFromArea, mathtime(config.timeToKick) * 1000, player.uid)
     player:setStorageValue(84310, player:getStorageValue(84310)+1)
    return true
end

function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end

function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end

function kickFromArea(cid)
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if not stone then
        Game.createItem(config.stone.id, 1, config.stone.pos)
    end
    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos) then
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end

Reset your character's 84310 storage to -1 and try that, check the changes on lines 13-25.
 
LUA:
local config = {
    level = 50,
    maxTimes = 2,
    timeToWait = {1, 'day'},
    maxPlayers = 1,
    room = {fromPos = Position(1064, 1064, 7), toPos = Position(1069, 1069, 7)},
    newPos = Position(1066, 1066, 7),
    stone = {id = 1304, pos = Position(1059, 1065, 7)},
    timeToKick = {0.3, 'min'},
    kickPos = Position(1060, 1070, 7),
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    -- Check if we have reached max times.
    -- If yes, set 'times used' counter to 0; set exhaustion to timeToWait --> After that, the exhaustion check will happen and prevent the script from executing.
    -- If not, increase 'times used' counter by 1 at the end of the script when we are sure the player got to use it. In case it is on -1 (default, set it to 0 once). Easier to work with 0 than -1.
    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, 0)
         player:setStorageValue(84309, mathtime(config.timeToWait) + os.time())
    else
        if player:getStorageValue(84310) == -1 then
            player:setStorageValue(84310, 0)
        end
     end
    
    if player:hasExhaustion(84309) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end
   
    if player:getLevel() < config.level then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
   
    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if stone then
        stone:getPosition():sendMagicEffect(CONST_ME_POFF)
        stone:remove()
    end
    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    addEvent(kickFromArea, mathtime(config.timeToKick) * 1000, player.uid)
     player:setStorageValue(84310, player:getStorageValue(84310)+1)
    return true
end

function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end

function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end

function kickFromArea(cid)
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if not stone then
        Game.createItem(config.stone.id, 1, config.stone.pos)
    end
    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos) then
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end

Reset your character's 84310 storage to -1 and try that, check the changes on lines 13-25.
I can't get it, which of these values i should set to -1?
Code:
    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, 0)
         player:setStorageValue(84309, mathtime(config.timeToWait) + os.time())
    else
        if player:getStorageValue(84310) == -1 then
            player:setStorageValue(84310, 0)
        end
     end
 
I can't get it, which of these values i should set to -1?
Code:
    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, 0)
         player:setStorageValue(84309, mathtime(config.timeToWait) + os.time())
    else
        if player:getStorageValue(84310) == -1 then
            player:setStorageValue(84310, 0)
        end
     end

Don't change anything in the edited script, I meant on your character that you're testing with, reset that storage to default (-1) so you can test properly in case it was set to something else during your previous testing. You can use the command /storage <charname> <storage> <value>
 
Don't change anything in the edited script, I meant on your character that you're testing with, reset that storage to default (-1) so you can test properly in case it was set to something else during your previous testing. You can use the command /storage <charname> <storage> <value>
Ok I did that :
/storage liqeen 84310 -1
And also created a new character but it still does not work, I mean characters can still abuse the stone.
 
Ok I did that :
/storage liqeen 84310 -1
And also created a new character but it still does not work, I mean characters can still abuse the stone.

I haven't tested it since I have no 1.x server to run atm, but unless I'm blind, this should work.
Have you reloaded the script?
Also, make sure that you are not using it on a character that is not affected by exhaustion. Don't know how it is on your distro, but on some distros, GMs and other high-ranking roles are not affected by hasExhaustion/setExhaustion.

Furthermore, you can use this debug version of the script that will print stuff to your console to figure out what's going wrong.
For testing purposes, I have changed timeToWait and maxTimes variables to different values.

LUA:
local config = {
    level = 50,
    maxTimes = 2,
    timeToWait = 60*60*24,
    maxPlayers = 1,
    room = {fromPos = Position(1064, 1064, 7), toPos = Position(1069, 1069, 7)},
    newPos = Position(1066, 1066, 7),
    stone = {id = 1304, pos = Position(1059, 1065, 7)},
    timeToKick = {0.3, 'min'},
    kickPos = Position(1060, 1070, 7),
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    -- Check if we have reached max times.
    -- If yes, set 'times used' counter to 0; set exhaustion to timeToWait --> After that, the exhaustion check will happen and prevent the script from executing.
    -- If not, increase 'times used' counter by 1 at the end of the script when we are sure the player got to use it. In case it is on -1 (default, set it to 0 once). Easier to work with 0 than -1.

    print("Using stone on character " .. player:getName() .. " - whose storage 84310 is on value " .. player:getStorageValue(84310) .. ".")
    print("Checking if that value is equal to config.maxTimes (" ..config.maxTimes.. ".")
    if player:getStorageValue(84310) == config.maxTimes then
        print("It is. Resetting 84310 to 0. Setting exhaustion.")
        player:setStorageValue(84310, 0)
        player:setStorageValue(84309, config.timeToWait + os.time())
    else
        print("It is not.")
        if player:getStorageValue(84310) == -1 then
                print("Storage 84310 was -1, so we set it to the default now -> 0.")
            player:setStorageValue(84310, 0)
        end
    end
    
     print("Checking if player has any exhaustion set to storage 84309 (which is on value: " .. player:getStorageValue(84309) ..").")
    if player:hasExhaustion(84309) then
         print("Player had an exhaustion set on storage 84309. Do not allow the use of stone.\nScript terminated.")   
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end
    
    if player:getLevel() < config.level then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    
    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if stone then
        stone:getPosition():sendMagicEffect(CONST_ME_POFF)
        stone:remove()
    end
    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    addEvent(kickFromArea, mathtime(config.timeToKick) * 1000, player.uid)
    
     print("Stone used.\nPlayer's storage 84310 is currently on value:" .. player:getStorageValue(84310) .. ".\nIncreasing it by +1 at the moment...")   
    player:setStorageValue(84310, player:getStorageValue(84310)+1)
     print("Script executed.\n-------------\n")
    return true
end

function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end

function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end

function kickFromArea(cid)
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if not stone then
        Game.createItem(config.stone.id, 1, config.stone.pos)
    end
    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos) then
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end
 
I haven't tested it since I have no 1.x server to run atm, but unless I'm blind, this should work.
Have you reloaded the script?
Also, make sure that you are not using it on a character that is not affected by exhaustion. Don't know how it is on your distro, but on some distros, GMs and other high-ranking roles are not affected by hasExhaustion/setExhaustion.

Furthermore, you can use this debug version of the script that will print stuff to your console to figure out what's going wrong.
For testing purposes, I have changed timeToWait and maxTimes variables to different values.

LUA:
local config = {
    level = 50,
    maxTimes = 2,
    timeToWait = 60*60*24,
    maxPlayers = 1,
    room = {fromPos = Position(1064, 1064, 7), toPos = Position(1069, 1069, 7)},
    newPos = Position(1066, 1066, 7),
    stone = {id = 1304, pos = Position(1059, 1065, 7)},
    timeToKick = {0.3, 'min'},
    kickPos = Position(1060, 1070, 7),
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    -- Check if we have reached max times.
    -- If yes, set 'times used' counter to 0; set exhaustion to timeToWait --> After that, the exhaustion check will happen and prevent the script from executing.
    -- If not, increase 'times used' counter by 1 at the end of the script when we are sure the player got to use it. In case it is on -1 (default, set it to 0 once). Easier to work with 0 than -1.

    print("Using stone on character " .. player:getName() .. " - whose storage 84310 is on value " .. player:getStorageValue(84310) .. ".")
    print("Checking if that value is equal to config.maxTimes (" ..config.maxTimes.. ".")
    if player:getStorageValue(84310) == config.maxTimes then
        print("It is. Resetting 84310 to 0. Setting exhaustion.")
        player:setStorageValue(84310, 0)
        player:setStorageValue(84309, config.timeToWait + os.time())
    else
        print("It is not.")
        if player:getStorageValue(84310) == -1 then
                print("Storage 84310 was -1, so we set it to the default now -> 0.")
            player:setStorageValue(84310, 0)
        end
    end
   
     print("Checking if player has any exhaustion set to storage 84309 (which is on value: " .. player:getStorageValue(84309) ..").")
    if player:hasExhaustion(84309) then
         print("Player had an exhaustion set on storage 84309. Do not allow the use of stone.\nScript terminated.")  
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end
   
    if player:getLevel() < config.level then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
   
    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if stone then
        stone:getPosition():sendMagicEffect(CONST_ME_POFF)
        stone:remove()
    end
    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    addEvent(kickFromArea, mathtime(config.timeToKick) * 1000, player.uid)
   
     print("Stone used.\nPlayer's storage 84310 is currently on value:" .. player:getStorageValue(84310) .. ".\nIncreasing it by +1 at the moment...")  
    player:setStorageValue(84310, player:getStorageValue(84310)+1)
     print("Script executed.\n-------------\n")
    return true
end

function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end

function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end

function kickFromArea(cid)
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if not stone then
        Game.createItem(config.stone.id, 1, config.stone.pos)
    end
    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos) then
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end
Ok I tested it with debug version and it looks like this :
Code:
Using stone on character Ek Tester - whose storage 84310 is on value -1.
Checking if that value is equal to config.maxTimes (2.
It is not.
Storage 84310 was -1, so we set it to the default now -> 0.
Checking if player has any exhaustion set to storage 84309 (which is on value: -1).
Stone used.
Player's storage 84310 is currently on value:0.
Increasing it by +1 at the moment...
Script executed.
-------------

Using stone on character Ek Tester - whose storage 84310 is on value 1.
Checking if that value is equal to config.maxTimes (2.
It is not.
Checking if player has any exhaustion set to storage 84309 (which is on value: -1).
Stone used.
Player's storage 84310 is currently on value:1.
Increasing it by +1 at the moment...
Script executed.
-------------

Using stone on character Ek Tester - whose storage 84310 is on value 2.
Checking if that value is equal to config.maxTimes (2.
It is. Resetting 84310 to 0. Setting exhaustion.
Checking if player has any exhaustion set to storage 84309 (which is on value: 1547494189).
Stone used.
Player's storage 84310 is currently on value:0.
Increasing it by +1 at the moment...
Script executed.
-------------

Using stone on character Ek Tester - whose storage 84310 is on value 1.
Checking if that value is equal to config.maxTimes (2.
It is not.
Checking if player has any exhaustion set to storage 84309 (which is on value: 1547494189).
Stone used.
Player's storage 84310 is currently on value:1.
Increasing it by +1 at the moment...
Script executed.
-------------
 
Ok I tested it with debug version and it looks like this :
Code:
Using stone on character Ek Tester - whose storage 84310 is on value -1.
Checking if that value is equal to config.maxTimes (2.
It is not.
Storage 84310 was -1, so we set it to the default now -> 0.
Checking if player has any exhaustion set to storage 84309 (which is on value: -1).
Stone used.
Player's storage 84310 is currently on value:0.
Increasing it by +1 at the moment...
Script executed.
-------------

Using stone on character Ek Tester - whose storage 84310 is on value 1.
Checking if that value is equal to config.maxTimes (2.
It is not.
Checking if player has any exhaustion set to storage 84309 (which is on value: -1).
Stone used.
Player's storage 84310 is currently on value:1.
Increasing it by +1 at the moment...
Script executed.
-------------

Using stone on character Ek Tester - whose storage 84310 is on value 2.
Checking if that value is equal to config.maxTimes (2.
It is. Resetting 84310 to 0. Setting exhaustion.
Checking if player has any exhaustion set to storage 84309 (which is on value: 1547494189).
Stone used.
Player's storage 84310 is currently on value:0.
Increasing it by +1 at the moment...
Script executed.
-------------

Using stone on character Ek Tester - whose storage 84310 is on value 1.
Checking if that value is equal to config.maxTimes (2.
It is not.
Checking if player has any exhaustion set to storage 84309 (which is on value: 1547494189).
Stone used.
Player's storage 84310 is currently on value:1.
Increasing it by +1 at the moment...
Script executed.
-------------

Well there is your problem, in the last entry you can see that the exhaustion time has been properly set to 1547494189 (timestamp), however, when your hasExhaustion check is done, it seems not to do anything about this.

I suggest trying to replace
LUA:
if player:hasExhaustion(84309) then
with
LUA:
if os.time() < player:getStorageValue(84309) then

And see if that works for you
 
Last edited:
Solution
Well there is your problem, in the last entry you can see that the exhaustion time has been properly set to 1547494189 (timestamp), however, when your hasExhaustion check is done, it seems not to do anything about this.

I suggest trying to replace
LUA:
if player:hasExhaustion(84309) then
with
LUA:
os.time() < player:getStorageValue(84309)

And see if that works for you
Now it works perfect, thanks for your time ; D
 
Back
Top