function onUse(cid, item, frompos, item2, topos)
local store = 23562 -- storage q salva o delay
local delay = 10 -- tempo em segundos de delay
local storage = 23563
local cidade = getPlayerTown(cid)
local pos = getTownTemplePosition(cidade)
if getPlayerStorageValue(cid, store) - os.time() >= 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, string.format("Aguarde %.2f minutos para usar novamente.", (getPlayerStorageValue(cid, store) - os.time()) / 60))
return true
end
if getCreatureCondition(cid, CONDITION_INFIGHT) then
doPlayerSendCancel(cid, 'Voce nao pode teleportar se estiver em battle.')
return true
end
doPlayerSendCancel(cid, "Teleportando!")
addEvent(function()
doSendMagicEffect(getPlayerPosition(cid), 1004)
doTeleportThing(cid, pos)
if getPlayerStorageValue(cid, 84929) >= 1 then -- torneio viktor
setPlayerStorageValue(cid, 84929, -1)
end
doRegainSpeed(cid)
doPlayerRemoveItem(cid, 2458, 1)
setPlayerStorageValue(cid, store, os.time() + delay)
end, delay * 1000)
return true
end