-- Advanced Teleport Script // by Xampy --
function onUse(cid, item, frompos, item2, topos)
local temple = {x=1000, y=1000, z=7} -- Change this to where you want them to be teleported
local position = getPlayerPosition(cid)
local positionn = position
local exhausttime = 60 -- in seconds
local function removeTP()
local posTP = getTileItemById(positionn, 1387).uid
if posTP ~= nil then
doRemoveItem(posTP)
end
end
local function nineSeconds()
local posTP = getTileItemById(positionn, 1387).uid
if posTP ~= nil then
doSendAnimatedText(positionn, '9', TEXTCOLOR_RED)
end
end
local function eightSeconds()
local posTP = getTileItemById(positionn, 1387).uid
if posTP ~= nil then
doSendAnimatedText(positionn, '8', TEXTCOLOR_RED)
end
end
local function sevenSeconds()
local posTP = getTileItemById(positionn, 1387).uid
if posTP ~= nil then
doSendAnimatedText(positionn, '7', TEXTCOLOR_RED)
end
end
local function sixSeconds()
local posTP = getTileItemById(positionn, 1387).uid
if posTP ~= nil then
doSendAnimatedText(positionn, '6', TEXTCOLOR_RED)
end
end
local function fiveSeconds()
local posTP = getTileItemById(positionn, 1387).uid
if posTP ~= nil then
doSendAnimatedText(positionn, '5', TEXTCOLOR_RED)
end
end
local function fourSeconds()
local posTP = getTileItemById(positionn, 1387).uid
if posTP ~= nil then
doSendAnimatedText(positionn, '4', TEXTCOLOR_RED)
end
end
local function threeSeconds()
local posTP = getTileItemById(positionn, 1387).uid
if posTP ~= nil then
doSendAnimatedText(positionn, '3', TEXTCOLOR_RED)
end
end
local function twoSeconds()
local posTP = getTileItemById(positionn, 1387).uid
if posTP ~= nil then
doSendAnimatedText(positionn, '2', TEXTCOLOR_RED)
end
end
local function oneSecond()
local posTP = getTileItemById(positionn, 1387).uid
if posTP ~= nil then
doSendAnimatedText(positionn, '1', TEXTCOLOR_RED)
end
end
if getPlayerStorageValue(cid, 558555) > os.time() then
if (getPlayerStorageValue(cid, 558555) - os.time()) == 1 then
letter = ""
else
letter = "s"
end
doPlayerSendCancel(cid, 'You must wait ' .. getPlayerStorageValue(cid, 558555) - os.time() .. ' second' .. letter .. '.')
doSendMagicEffect(position, 2)
return TRUE
elseif getCreatureCondition(cid, CONDITION_EXHAUST) == FALSE and getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE then
if getTilePzInfo(getCreaturePosition(cid)) == FALSE then
doCreateTeleport(1387, temple, getClosestFreeTile(getCreaturePosition(cid), false, false))
setPlayerStorageValue(cid, 558555, os.time() + exhausttime)
doRemoveItem(item.uid, 1)
doSendAnimatedText(position, '10', TEXTCOLOR_RED)
addEvent(nineSeconds, 1000)
addEvent(eightSeconds, 2000)
addEvent(sevenSeconds, 3000)
addEvent(sixSeconds, 4000)
addEvent(fiveSeconds, 5000)
addEvent(fourSeconds, 6000)
addEvent(threeSeconds, 7000)
addEvent(twoSeconds, 8000)
addEvent(oneSecond, 9000)
addEvent(removeTP, 10000)
else
doPlayerSendCancel(cid, "You can't use this in a protection zone.")
end
else
doPlayerSendCancel(cid, 'You are in a fight!')
end
return TRUE
end