local exhaust, events = {}, {}
local teleportPos = { x = 0, y = 0, z = 0 }
local exhaustionDelay = 1000
local eventDelay = 1000
function onUse(cid, item, fromPosition, target, toPosition)
if target.itemid == 2160 then
local exhaustTime = exhaust[getPlayerGUID(cid)] or 0
if exhaustTime <= os.time() then
local eventId = addEvent(function(cid)
if isPlayer(cid) then
doTeleportThing(cid, teleportPos, false)
doSendMagicEffect(teleportPos, CONST_ME_TELEPORT)
end
end, eventDelay, cid)
stopEvent(events[getPlayerGUID(cid)] or 0)
events[getPlayerGUID(cid)] = eventId
exhaust[getPlayerGUID(cid)] = os.time() +exhaustionDelay
else
doPlayerSendCancel(cid, "You are exhausted.")
end
end
return true
end