Ok. I think you have to set the co-ordinates to the pit garages if you want to leave safely. Or set it. correct me if am wrong. Regards Owen.
-- x1,y1, x2,y2 - start and end points of line (edge of area)
-- xa,ya - coordinate of car
function across(x1,y1,x2,y2,xa,ya)
local ymax,ymin
if (y1 < y2) then
ymax = y2
ymin = y1
else
ymax = y1
ymin = y2
end
local y = (xa-x1)*(y2-y1)/(x2-x1) + y1
if ((xa == x1) and (ya == y1)) or ((xa == x2) and (ya == y2)) then
return 2
elseif ((x1 == x2) and (xa == x1) and (ya >= ymin) and (ya <= ymax)) then
return 2
elseif ((x1 < x2) and (xa >= x1) and (xa <= x2)) or ((x1 > x2) and (xa <= x1) and (xa >= x2)) then
if (ya >= y) and (ymin <= y) then
return 1
end
end
return 0
end
function in_area(points,x,y)
local trig = 0
local temp
-- #points - number of points
for i=2,#points/2 do
temp = across(points[i*2-3],points[i*2-2],points[i*2-1],points[i*2-0],x,y)
if (temp == 2) then
return true
elseif (temp == 1) then
trig = 1 - trig
end
end
temp = across(points[#points-1],points[#points-0],points[1],points[2],x,y)
if (temp == 2) then
return true
elseif (temp == 1) then
trig = 1 - trig
end
if (trig == 1) then return true else return false end
end
local area = {18379340,2221338, 17468965,1976709, 17309117,2608274, 18208925,2855925}
local into_area = in_area(area, mci.compcar[DRAG.PLIDS[i]].x,mci.compcar[DRAG.PLIDS[i]].y)
if (into_area) then
...
end