local tprune = Action()
local tprunePlayers = {} -- don't change that
local tpruneExhaust = 5
tprune:id(2263)
tprune:allowFarUse(true)
tprune:checkFloor(true)
function tprune.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local errMsg = "" -- don't change that
time, cid = os.time(), player:getId()
if tprunePlayers[cid] and time < tprunePlayers[cid] then
errMsg = "You are exhausted."
end
local tile = Tile(toPosition)
if errMsg == "" and not tile then
errMsg = "Tile not found."
end
if errMsg == "" and not tile:isWalkable() then
errMsg = "Tile is not walkable."
end
if errMsg == "" and tile:hasFlag(TILESTATE_PROTECTIONZONE) and player:isPzLocked() then
errMsg = RETURNVALUE_PLAYERISPZLOCKED
end
if errMsg ~= "" then
player:sendCancelMessage(errMsg)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
player:teleportTo(toPosition)
tprunePlayers[cid] = time + tpruneExhaust
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return true
end
tprune:register()