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

How to Add Exausted time on Teleport

myalitth

New Member
Joined
Jan 13, 2013
Messages
69
Reaction score
3
I have an teleport with id 8058

Have any way to restrict access of the same player on this teleport for 24 hours?

Like an Daily Teleport where some player only can enter one time per day.
 
Solution
had to set up my own 1.3 test environment
tested and works fine
Lua:
local cooldown_storage = 88346
local destination = Position(1043, 1021, 7)

function onStepIn(creature, item, toPosition, fromPosition)
    local player = Player(creature)
    if not player then
        creature:teleportTo(fromPosition, true)
        return false
    end
    local time_left = player:getStorageValue(cooldown_storage)
    if time_left > os.time() then
        time_left = time_left - os.time() -- get the difference in time so it shows properly in error message
        local hours = string.format("%02.f", math.floor(time_left / 3600))
        local mins = string.format("%02.f", math.floor(time_left / 60 - (hours * 60)))
        local secs =...
Lua:
local cooldown_storage = 88346

function onUse(creature, item, fromPosition, toPosition)
    local player = Player(creature)
    if not player then
        creature:teleportTo(fromPosition, true)
        return false
    end
    local time_left = player:getStorageValue(cooldown_storage)
    if time_left == -1 or time_left < os.time() then
        player:setStorageValue(cooldown_storage, os.time() + (24 * 60 * 60))
    else
        local hours = string.format("%02.f", math.floor(time_left / 3600))
        local mins = string.format("%02.f", math.floor(time_left / 60 - (hours * 60)))
        local secs = string.format("%02.f", math.floor(time_left  - hours * 3600 - mins * 60))
        local time_string = hours ..":".. mins ..":".. secs
        creature:teleportTo(fromPosition, true)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You need to wait until ".. time_string .. " to use this teleport again.")
    end
    return true
end
 
Yes my movements:
<movevent event="StepIn" actionid="13149" script="tpboss.lua"/>

and i trying to use your script on tpboss.lua.

:s
 
wait im retarded
change function onUse to function onStepIn
i wrote the parameters correctly for onStepIn i just swapped the function name in my brain when i was writing it on accident
 
Ok, solved but..
TFS crashes when i try to pass 2x to test.

TFS 1.3~
try using this
Lua:
local cooldown_storage = 88346

function onUse(creature, item, fromPosition, toPosition)
    local player = Player(creature)
    if not player then
        return false
    end
    local time_left = player:getStorageValue(cooldown_storage)
    if time_left > os.time() then
        local hours = string.format("%02.f", math.floor(time_left / 3600))
        local mins = string.format("%02.f", math.floor(time_left / 60 - (hours * 60)))
        local secs = string.format("%02.f", math.floor(time_left  - hours * 3600 - mins * 60))
        local time_string = hours ..":".. mins ..":".. secs
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You need to wait until ".. time_string .. " to use this teleport again.")
        return false
    end
    player:setStorageValue(cooldown_storage, os.time() + (24 * 60 * 60))
    return true
end
 
had to set up my own 1.3 test environment
tested and works fine
Lua:
local cooldown_storage = 88346
local destination = Position(1043, 1021, 7)

function onStepIn(creature, item, toPosition, fromPosition)
    local player = Player(creature)
    if not player then
        creature:teleportTo(fromPosition, true)
        return false
    end
    local time_left = player:getStorageValue(cooldown_storage)
    if time_left > os.time() then
        time_left = time_left - os.time() -- get the difference in time so it shows properly in error message
        local hours = string.format("%02.f", math.floor(time_left / 3600))
        local mins = string.format("%02.f", math.floor(time_left / 60 - (hours * 60)))
        local secs = string.format("%02.f", math.floor(time_left  - hours * 3600 - mins * 60))
        local time_string = hours ..":".. mins ..":".. secs
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You cannot enter this teleport yet. Time left: ".. time_string .. ".")
        player:teleportTo(fromPosition, true)
        return false
    end
    player:setStorageValue(cooldown_storage, os.time() + 3600)
    player:teleportTo(destination)
    return true
end
 
Solution
Back
Top