This code is not creating the effects . When I pull the table values returns 7 equal positions but were to be different . Help me, please
Code:
local distancia_teleport7 = 7
local efeito_teleport7 = 12
function onCastSpell(cid, var)
local teleport_pos7 = getPosByDir(getCreaturePosition(cid), getCreatureLookDirection(cid), distancia_teleport7)
local player_pos_inicial = getCreaturePosition(cid)
if player_pos_inicial.x ~= teleport_pos7.x then
if player_pos_inicial.x < teleport_pos7.x then
soma = 1
else
soma = -1
end
for i=1,distancia_teleport7 do
player_pos_inicial.x = player_pos_inicial.x + soma
if isWalkable(player_pos_inicial) then
table.insert(tabela_pos_ok,player_pos_inicial)
else
break
end
end
elseif player_pos_inicial.y ~= teleport_pos7.y then
if player_pos_inicial.y < teleport_pos7.y then
soma = 1
else
soma = -1
end
for i=1,distancia_teleport7 do
player_pos_inicial.y = player_pos_inicial.y + soma
if isWalkable(player_pos_inicial) then
table.insert(tabela_pos_ok,player_pos_inicial)
else
break
end
end
end
for i = 1,#tabela_pos_ok do
doSendMagicEffect(tabela_pos_ok[i], efeito_teleport7)
end
doTeleportThing(cid, tabela_pos_ok[#tabela_pos_ok])
return true
end