local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
local config = {
time_back = 10 --in seconds
storageX = 11111,
storageY = 11112,
storageZ = 11113,
position = {x = 1500, y = 1500, z = 7}
}
function onCastSpell(cid, var)
local target = variantToNumber(var)
if isPlayer(target) then
doCombat(cid, combat, var)
setPlayerStorageValue(cid, config.storageX, getPlayerPosition(cid).x)
setPlayerStorageValue(cid, config.storageY, getPlayerPosition(cid).y)
setPlayerStorageValue(cid, config.storageZ, getPlayerPosition(cid).z)
setPlayerStorageValue(target, config.storageX, getPlayerPosition(target).x)
setPlayerStorageValue(target, config.storageY, getPlayerPosition(target).y)
setPlayerStorageValue(target, config.storageZ, getPlayerPosition(target).z)
doTeleportThing(cid, config.position)
doTeleportThing(target, config.position)
doSendMagicEffect(getCreaturePosition(target), CONST_ME_TELEPORT)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
return addEvent(teleportBack, config.time_back * 1000, cid, target)
end
end
function teleportBack(cid, target)
if isPlayer(cid) and isPlayer(target) then
POS1 = {x = getPlayerStorageValue(cid, config.storageX), y = getPlayerStorageValue(cid, config.storageY), z = getPlayerStorageValue(cid, config.storageZ)}
POS2 = {x = getPlayerStorageValue(target, config.storageX), y = getPlayerStorageValue(target, config.storageY), z = getPlayerStorageValue(target, config.storageZ)}
doTeleportThing(cid, POS1)
doTeleportThing(cid, POS2)
doSendMagicEffect(getCreaturePosition(target), CONST_ME_TELEPORT)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
end
end