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 =...
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
this is a movement scriptNice, but do you know how to make an simple action to put on teleport?
it's not event="onStepIn" it's event="StepIn"i've tryied but... [Warning - Event::checkScript] Event onStepIn not found.
try using thisOk, solved but..
TFS crashes when i try to pass 2x to test.
TFS 1.3~
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
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