Azze19
Solo developer
- Joined
- Jul 4, 2014
- Messages
- 75
- Reaction score
- 23
I want to make an area directional spell, however, I want it to stop midway if the player moves; heres the script:
I figured that once you get the player's position the value is set, but I was wondering if there's a way to refresh that value so that the for can break if the player moves.
Also I'm having issues with the dealDamagePos on the second addEvent, if someone could help me figure this out it'll be a plus. Thanks!
local config = {
interval = 200,
}
function onSay(cid)
local player = Player(cid)
local playerPos = player:getPosition()
local playerDir = player:getDirection()
local cT = config
local posT = {}
if playerDir == 0 then
posT[1] = {x=playerPos.x+1 , y=playerPos.y-1, z=playerPos.z}
posT[2] = {x=playerPos.x , y=playerPos.y-1, z=playerPos.z}
posT[3] = {x=playerPos.x-1 , y=playerPos.y-1, z=playerPos.z}
posT[4] = {x=playerPos.x , y=playerPos.y-1, z=playerPos.z}
posT[5] = {x=playerPos.x+1 , y=playerPos.y-1, z=playerPos.z}
elseif playerDir == 1 then
posT[1] = {x=playerPos.x+1 , y=playerPos.y-1, z=playerPos.z}
posT[2] = {x=playerPos.x+1 , y=playerPos.y, z=playerPos.z}
posT[3] = {x=playerPos.x+1 , y=playerPos.y+1, z=playerPos.z}
posT[4] = {x=playerPos.x+1 , y=playerPos.y, z=playerPos.z}
posT[5] = {x=playerPos.x+1 , y=playerPos.y-1, z=playerPos.z}
elseif playerDir == 2 then
posT[1] = {x=playerPos.x+1 , y=playerPos.y+1, z=playerPos.z}
posT[2] = {x=playerPos.x , y=playerPos.y+1, z=playerPos.z}
posT[3] = {x=playerPos.x-1 , y=playerPos.y+1, z=playerPos.z}
posT[4] = {x=playerPos.x , y=playerPos.y+1, z=playerPos.z}
posT[5] = {x=playerPos.x+1 , y=playerPos.y+1, z=playerPos.z}
elseif playerDir == 3 then
posT[1] = {x=playerPos.x-1 , y=playerPos.y-1, z=playerPos.z}
posT[2] = {x=playerPos.x-1 , y=playerPos.y, z=playerPos.z}
posT[3] = {x=playerPos.x-1 , y=playerPos.y+1, z=playerPos.z}
posT[4] = {x=playerPos.x-1 , y=playerPos.y, z=playerPos.z}
posT[5] = {x=playerPos.x-1 , y=playerPos.y-1, z=playerPos.z}
end
for times, pos in pairs (posT) do
local delay = cT.interval * times
local newplypos = player:getPosition()
if playerPos ~= newplypos then
break
else
addEvent(function() Position(pos):sendMagicEffect(10) end, delay)
-- addEvent(dealDamagePos, delay, cid, pos, 1, PHYSICAL, 50, 200, 4)
end
end
end
interval = 200,
}
function onSay(cid)
local player = Player(cid)
local playerPos = player:getPosition()
local playerDir = player:getDirection()
local cT = config
local posT = {}
if playerDir == 0 then
posT[1] = {x=playerPos.x+1 , y=playerPos.y-1, z=playerPos.z}
posT[2] = {x=playerPos.x , y=playerPos.y-1, z=playerPos.z}
posT[3] = {x=playerPos.x-1 , y=playerPos.y-1, z=playerPos.z}
posT[4] = {x=playerPos.x , y=playerPos.y-1, z=playerPos.z}
posT[5] = {x=playerPos.x+1 , y=playerPos.y-1, z=playerPos.z}
elseif playerDir == 1 then
posT[1] = {x=playerPos.x+1 , y=playerPos.y-1, z=playerPos.z}
posT[2] = {x=playerPos.x+1 , y=playerPos.y, z=playerPos.z}
posT[3] = {x=playerPos.x+1 , y=playerPos.y+1, z=playerPos.z}
posT[4] = {x=playerPos.x+1 , y=playerPos.y, z=playerPos.z}
posT[5] = {x=playerPos.x+1 , y=playerPos.y-1, z=playerPos.z}
elseif playerDir == 2 then
posT[1] = {x=playerPos.x+1 , y=playerPos.y+1, z=playerPos.z}
posT[2] = {x=playerPos.x , y=playerPos.y+1, z=playerPos.z}
posT[3] = {x=playerPos.x-1 , y=playerPos.y+1, z=playerPos.z}
posT[4] = {x=playerPos.x , y=playerPos.y+1, z=playerPos.z}
posT[5] = {x=playerPos.x+1 , y=playerPos.y+1, z=playerPos.z}
elseif playerDir == 3 then
posT[1] = {x=playerPos.x-1 , y=playerPos.y-1, z=playerPos.z}
posT[2] = {x=playerPos.x-1 , y=playerPos.y, z=playerPos.z}
posT[3] = {x=playerPos.x-1 , y=playerPos.y+1, z=playerPos.z}
posT[4] = {x=playerPos.x-1 , y=playerPos.y, z=playerPos.z}
posT[5] = {x=playerPos.x-1 , y=playerPos.y-1, z=playerPos.z}
end
for times, pos in pairs (posT) do
local delay = cT.interval * times
local newplypos = player:getPosition()
if playerPos ~= newplypos then
break
else
addEvent(function() Position(pos):sendMagicEffect(10) end, delay)
-- addEvent(dealDamagePos, delay, cid, pos, 1, PHYSICAL, 50, 200, 4)
end
end
end
I figured that once you get the player's position the value is set, but I was wondering if there's a way to refresh that value so that the for can break if the player moves.
Also I'm having issues with the dealDamagePos on the second addEvent, if someone could help me figure this out it'll be a plus. Thanks!