-- By Colandus LEAVE CREDITS
local countdown = 60
local name = "Your Temple"
local action = {}
local function teleport(p)
local cid, count = unpack(p)
if(isPlayer(cid) == TRUE) then
local cancelled = not action[cid]
local playerPos = getCreaturePosition(cid)
if(not cancelled) then
if(getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid, 21, "Teleport cancelled because of being in a fight!")
cancelled = true
elseif(count > 0) then
doCreatureSay(cid, "Teleporting in " .. count .. " seconds.", TALKTYPE_ORANGE_1)
doSendAnimatedText(playerPos, "Teleport", TEXTCOLOR_RED)
doSendMagicEffect(playerPos, CONST_ME_FIREATTACK)
addEvent(teleport, 1000, {cid, count - 1})
else
doTeleportThing(cid, getPlayerMasterPos(cid))
doPlayerSendTextMessage(cid, 21, "Teleported to the " .. name .. ".")
doSendMagicEffect(playerPos, CONST_ME_ASSASSIN)
local playerPos = getCreaturePosition(cid)
doSendMagicEffect(playerPos, CONST_ME_FIREATTACK)
doSendMagicEffect(playerPos, CONST_ME_FIREAREA)
action[cid] = false
end
end
if(cancelled) then
doSendAnimatedText(playerPos, "Cancelled", TEXTCOLOR_RED)
action[cid] = false
end
end
end
function onUse(cid, item, ppos, frompos, item2, topos)
local countdown = countdown * (isPremium(cid) == TRUE and 0.25 or 1) -- remove this line if you don't want premium multiplier
if(getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot use a teleport scroll when you are in a fight.")
elseif(action[cid]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have cancelled the teleport.")
action[cid] = false
return TRUE
elseif(isExhausted(cid, 9143, countdown * 4) == 1) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "The power of this scroll is too strong to be executed this fast.")
else
action[cid] = true
teleport({cid, countdown})
setExhaust(cid, 9143)
end
if(action[cid] == false) then
doSendMagicEffect(frompos, CONST_ME_POFF)
end
return TRUE
end