local config = {
storages = {82001, 82002, 82003},
templeRange = {fromPos = {x = 90, y = 90, z = 7}, toPos = {x = 110, y = 120, z = 7}},
templePosition = {x = 95, y = 115, z = 7},
exhauststorage = 87538,
exhausttime = 10
}
local function doTeleportPlayer(cid, pos)
if isPlayer(cid) then
if pos ~= nil then
doTeleportThing(cid, pos)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You've been teleported back.")
else
doTeleportThing(cid, config.templePosition)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You've been teleported to the temple, use it again to go back.")
end
exhaustion.set(cid, config.exhauststorage, config.exhausttime)
end
return true
end
local function doSendEffects(cid, c)
local pos = getPlayerPosition(cid)
doSendAnimatedText(pos, 10-c, math.random(200))
local effects = {
{x = pos.x - 1, y = pos.y - 1, z = pos.z},
{x = pos.x, y = pos.y - 1, z = pos.z},
{x = pos.x + 1, y = pos.y - 1, z = pos.z},
{x = pos.x + 1, y = pos.y, z = pos.z},
{x = pos.x + 1, y = pos.y + 1, z = pos.z},
{x = pos.x, y = pos.y + 1, z = pos.z},
{x = pos.x - 1, y = pos.y + 1, z = pos.z},
{x = pos.x - 1, y = pos.y, z = pos.z}
}
for x = 1, 8 do
ex = x+1 > 8 and 1 or x+1
if math.mod(c, 2) == 0 or c == 0 then
doSendDistanceShoot(effects[x], effects[ex], (effects[x].x ~= pos.x and effects[x].y ~= pos.y) and CONST_ANI_ENERGY or CONST_ANI_ENERGYBALL)
else
doSendDistanceShoot(effects[x], effects[ex], (effects[x].x ~= pos.x and effects[x].y ~= pos.y) and CONST_ANI_ENERGYBALL or CONST_ANI_ENERGY)
end
end
return true
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if exhaustion.check(cid, config.exhauststorage) then
return doPlayerSendCancel(cid, "You need to wait "..exhaustion.get(cid, config.exhauststorage).." seconds before you can use it again.")
end
local s, pos = {}, getPlayerPosition(cid)
for x = 1, 3 do
table.insert(s, getPlayerStorageValue(cid, config.storages[x]))
end
if isInRange(pos, config.templeRange.fromPos, config.templeRange.toPos) then
if getTilePzInfo(pos) then
if s[1] > 0 then
addEvent(doTeleportPlayer, 10 * 1000, cid, {x = s[1], y = s[2], z = s[3]})
for c = 0, 9 do
addEvent(doSendEffects, c * 1000, cid, c)
end
exhaustion.set(cid, config.exhauststorage, config.exhausttime)
return true
else
doPlayerSendCancel(cid, "You have no position saved yet.")
end
else
doPlayerSendCancel(cid, "Use this in pz.")
end
doSendMagicEffect(pos, CONST_ME_POFF)
else
if getCreatureCondition(cid, CONDITION_INFIGHT) then
doPlayerSendCancel(cid, "You can't use this when you're in a fight.")
doSendMagicEffect(pos, CONST_ME_POFF)
return true
end
local q = {pos.x, pos.y, pos.z}
for x = 1, 3 do
setPlayerStorageValue(cid, config.storages[x], q[x])
end
addEvent(doTeleportPlayer, 10 * 1000, cid)
exhaustion.set(cid, config.exhauststorage, config.exhausttime)
for c = 0, 9 do
addEvent(doSendEffects, c * 1000, cid, c)
end
end
return true
end