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

Lua Exhaustion on TP

liqeen

Active Member
Joined
Nov 26, 2014
Messages
149
Solutions
1
Reaction score
28
Location
Poland
Hello, i'm trying to made a script that will set exhaust on teleport cause it's annoying to dash from one to another
Lua:
local config = {
    cooldown = 3000, -- milliseconds for more precision
    storage = 99999 -- sample storage value
}
function onStepIn(creature, item, position, fromPosition)

    local player = creature:getPlayer()
    if not player or player:isInGhostMode() then
        return true
    end

   if player:getStorageValue(config.storage) <= os.mtime() then
        player:setStorageValue(config.storage, os.mtime() + config.cooldown)
        return true
    end
    player:sendCancelMessage("You cannot enter yet")
    return false
end
This is what I made so far but doesn't work, no errors in console.
Can somebody help me with that?
TFS 1.3
 
Last edited:
Solution
Hello, i'm trying to made a script that will set exhaust on teleport cause it's annoying to dash from one to another
Lua:
local config = {
    cooldown = 3000, -- milliseconds for more precision
    storage = 99999 -- sample storage value
}
function onStepIn(creature, item, position, fromPosition)

    local player = creature:getPlayer()
    if not player or player:isInGhostMode() then
        return true
    end

   if player:getStorageValue(config.storage) <= os.mtime() then
        player:setStorageValue(config.storage, os.mtime() + config.cooldown)
        return true
    end
    player:sendCancelMessage("You cannot enter yet")
    return false
end
This is what I made so far but doesn't work, no errors in console.
Can somebody...
Hello, i'm trying to made a script that will set exhaust on teleport cause it's annoying to dash from one to another
Lua:
local config = {
    cooldown = 3000, -- milliseconds for more precision
    storage = 99999 -- sample storage value
}
function onStepIn(creature, item, position, fromPosition)

    local player = creature:getPlayer()
    if not player or player:isInGhostMode() then
        return true
    end

   if player:getStorageValue(config.storage) <= os.mtime() then
        player:setStorageValue(config.storage, os.mtime() + config.cooldown)
        return true
    end
    player:sendCancelMessage("You cannot enter yet")
    return false
end
This is what I made so far but doesn't work, no errors in console.
Can somebody help me with that?
TFS 1.3
Lua:
local config = {
    cooldown = 3000, -- milliseconds for more precision
    storage = 99999 -- sample storage value
}

function onStepIn(creature, item, position, fromPosition)
   
    local player = creature:getPlayer()
    if not player or player:isInGhostMode() then
        return true
    end
   
    local currentTime = os.mtime()
    if currentTime <= player:getStorageValue(config.storage) then
        player:teleportTo(fromPosition)
        player:sendCancelMessage("You cannot enter yet.")
        return true
    end
   
    player:setStorageValue(config.storage, currentTime + config.cooldown)
    return true
end
Post automatically merged:

@liqeen Did it help?
 
Last edited:
Solution
Lua:
local config = {
    cooldown = 3000, -- milliseconds for more precision
    storage = 99999 -- sample storage value
}

function onStepIn(creature, item, position, fromPosition)
  
    local player = creature:getPlayer()
    if not player or player:isInGhostMode() then
        return true
    end
  
    local currentTime = os.mtime()
    if currentTime <= player:getStorageValue(config.storage) then
        player:teleportTo(fromPosition)
        player:sendCancelMessage("You cannot enter yet.")
        return true
    end
  
    player:setStorageValue(config.storage, currentTime + config.cooldown)
    return true
end
Post automatically merged:

@liqeen Did it help?
maybe someone can make a revscript for this ? :))

Thanks in advance!
 
maybe someone can make a revscript for this ? :))

Thanks in advance!
You don't need to change any of the function code for this to be converted into a revscript... especially when you are using the same parameters from the onStepIn.

Just use the correct template if you don't know them:
Revscriptsys (https://github.com/otland/forgottenserver/wiki/Revscriptsys#moveeventonStepIn)

Lua:
local config = {
    cooldown = 3000, -- milliseconds for more precision
    storage = 99999 -- sample storage value
}

--function onStepIn becomes a local variable calling a MoveEvent(). You then assign it an onStepIn function .
local moveevent = MoveEvent()
function moveevent.onStepIn(creature, item, position, fromPosition)
 
    local player = creature:getPlayer()
    if not player or player:isInGhostMode() then
        return true
    end
 
    local currentTime = os.mtime()
    if currentTime <= player:getStorageValue(config.storage) then
        player:teleportTo(fromPosition)
        player:sendCancelMessage("You cannot enter yet.")
        return true
    end
 
    player:setStorageValue(config.storage, currentTime + config.cooldown)
    return true
   
end

--this is similar to registering in the XML file. We add a trigger for the action id of 12345, and register it.
moveevent:aid(12345)
moveevent:register()
 
Back
Top