Hi guys, I am trying to make a spell that teleports the user next to the target. I have this script:
However, this script teleports me on the spot of my target, which gets problematic/OP in PVP..
How can I add so that the user teleports next to the target IF possible and if there is no free square around them then the teleport doesn't work?
Lua:
local config = {
effect = 65, --effect
}
function onCastSpell(cid, var)
local target = variantToNumber(var)
local playerPos = getThingPos(target)
local position = Position(playerPos.x,playerPos.y,playerPos.z)
if isCreature(cid) and isCreature(target) then
--local lookingDirection = getCreatureLookDirection(target)
--print(lookingDirection)
doSendMagicEffect(getThingPos(cid), config.effect)
doTeleportThing(cid, position)
doSendMagicEffect(getThingPos(cid), config.effect)
end
return true
end
However, this script teleports me on the spot of my target, which gets problematic/OP in PVP..
How can I add so that the user teleports next to the target IF possible and if there is no free square around them then the teleport doesn't work?