Syryniss
Member
- Joined
- Feb 13, 2014
- Messages
- 206
- Reaction score
- 20
Hi. I wanted to make an 1x1 area spell which teleports all players in range to some place and then teleport them back after a while. I made script that was working, but was teleporting all players to 1 spot and I wanted to improve it, so teleported players are in the same distance from caster as they were before teleport. I hope you got what I mean, anyway after this change it stopped working, it teleports only caster. I know I made mistake somewhere in onCastSpell function, but I don't know where, so if anyone could help me, here it is :
Code:
local function doTeleportBack(cid, tid, pPos, pos)
if isPlayer(cid) then
doTeleportThing(cid, pos, false)
end
if isPlayer(tid) then
doTeleportThing(tid, pPos, false)
end
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
doSendMagicEffect(pPos, CONST_ME_POFF)
return true
end
function onCastSpell(cid, var)
local area1 = { x=1100, y=44, z=7 }
local pos = getCreaturePosition(cid)
for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1, false)) do
if(isPlayer(tid) and getPlayerAccess(tid) <= 1) then
local pPos = getCreaturePosition(tid)
if pPos == { x=pos.x, y=pos.y + 1, z=pos.z } then
doTeleportThing(tid, { x=area1.x, y=area1.y + 1, z=area1.z }, false)
elseif pPos == { x=pos.x, y=pos.y - 1, z=pos.z } then
doTeleportThing(tid, { x=area1.x, y=area1.y - 1, z=area1.z }, false)
elseif pPos == { x=pos.x + 1, y=pos.y , z=pos.z } then
doTeleportThing(tid, { x=area1.x + 1, y=area1.y, z=area1.z }, false)
elseif pPos == { x=pos.x - 1, y=pos.y , z=pos.z } then
doTeleportThing(tid, { x=area1.x - 1, y=area1.y, z=area1.z }, false)
elseif pPos == { x=pos.x + 1, y=pos.y + 1, z=pos.z } then
doTeleportThing(tid, { x=area1.x + 1, y=area1.y + 1, z=area1.z }, false)
elseif pPos == { x=pos.x - 1, y=pos.y - 1, z=pos.z } then
doTeleportThing(tid, { x=area1.x - 1, y=area1.y - 1, z=area1.z }, false)
elseif pPos == { x=pos.x - 1, y=pos.y + 1, z=pos.z } then
doTeleportThing(tid, { x=area1.x - 1, y=area1.y + 1, z=area1.z }, false)
elseif pPos == { x=pos.x + 1, y=pos.y - 1, z=pos.z } then
doTeleportThing(tid, { x=area1.x + 1, y=area1.y - 1, z=area1.z }, false)
end
doTeleportThing(cid, area1, false)
addEvent(doTeleportBack, 4 * 1000, cid, tid, pPos, pos)
end
end
return true
end
Last edited: