In the following reply I mention zones multiple times. I’ll always refer to the following map:

I do know about a map that consists of squares completely, although I didn’t look further into it whether that one is the one to be used here.
Not sure I’m completely catching you here.
AreNodesLoadedForArea is just a check, not the function triggering loading, correct?
I took the above code and replaced RequestPaths... with AreNodesLoadedForArea. This got the function stuck in the while-loop.
Then I went a little overboard. I added every native that I have tried so far at the same time. The GPS-Route I plot accurately does what I want. The GPS-route stys on the screen now, tries before had it vanish point by point.
Note: Startposition and Endposition differ from points A and B but are properly defined in the script.
local startzone = GetZoneAtCoords(Ax, Ay, Az)
local startzonename = GetNameOfZone(Ax, Ay, Az)
print(startzone, startzonename)
local endzone = GetZoneAtCoords(Bx, By, Bz)
local endzonename = GetNameOfZone(Bx, By, Bz)
print(endzone, endzonename)
SetZoneEnabled(startzone, true)
SetZoneEnabled(endzone, true)
local centerx = (Bx + Ax)/2
local centery = (Ay + By)/2
local radius = math.abs(Bx-Ax)
if math.abs(By-Ay) > radius then
radius = math.abs(By-Ay)
end
AddNavmeshRequiredRegion(centerx, centery, radius)
ClearGpsMultiRoute()
StartGpsMultiRoute(6, false, true)
AddPointToGpsMultiRoute(Startposition.x, Startposition.y, Startposition.z)
AddPointToGpsMultiRoute(Ax, Ay, Az)
AddPointToGpsMultiRoute(Bx, By, Bz)
AddPointToGpsMultiRoute(Endposition.x, Endposition.y, Endposition.z)
SetGpsMultiRouteRender(true)
local _ = RequestPathsPreferAccurateBoundingstruct(Ax, Ay, Bx, By)
local _, _, _, _ = GenerateDirectionsToCoord(Startposition.x, Startposition.y, Startposition.z, 0)
local _, _, _, _ = GenerateDirectionsToCoord(Ax, Ay, Az, 0)
local _, _, _, _ = GenerateDirectionsToCoord(Bx, By, Bz, 0)
local _, _, _, _ = GenerateDirectionsToCoord(Endposition.x, Endposition.y, Endposition.z, 0)
local retval = false
retval = AreNodesLoadedForArea(Ax, Ay, Bx, By)
local k = 0
print('Requested', retval)
while not retval do
print('Waiting for return')
k = k + 1
Wait(10)
if k > 100 then
print('Aborted')
end
end
The above function gets stuck in the while-loop (forgot the break in there). After I removed the while-loop the function afterwards ran through.
What I want the function to output is best displayed in the following picture. The picture is taken with one player on the server, me. I’m standing in Paleto Bay and just used NoClip to fly over part of the highway.
I’d like the car to drive from a starting point (the leftmost yellow blip on the map) to a goal (the upmost green blip) without a player being near (if you remember the last posts, I’m that lunatic). For that I placed a few nodes myself which function as anchors and divide the whole part in multiple sections (in the picture: yellow is from start to my first node. White is first to second node, blue is second to third node, green is third node to finish).
Let’s assume that for each section the car drives from point A to point B. I execute the following code (not actual copy, just the idea. I omitted a few safeguards that I put in place):
local x, y, z = GetClosestVehicleNode(Ax, Ay, Az, 0, 3.0, 0) -- start coordinates
local tx, ty, tz = GetClosestVehicleNode(Bx, By, Bz, 0, 3.0, 0) -- target coordinates
-- if the nodes are loaded both my start and target are always exactly on a vehicle node position.
-- natives are done wrong in this example but it's done properly in the script
local distance = Vdist(x, y, z, tx, ty, tz)
while distance > 1.0 do -- reach position close to point B iteratively
local newx, newy, newz = 0 -- initialize temp coordinate values
local newdistance = 999999.9 -- initialize temp distance
for i = 1, 40 do
local _, newpos = GetNthClosestVehicleNode(x, y, z, i, 0, 3.0, 2.5) -- find 40 pathnodes close to the initial position
newdistance = Vdist(newpos.x, newpos.y, newpos.z, tx, ty, tz) -- calculate the distance to the goal from the new position
if newdistance < distance then
-- the new position is better than the old so is saved
newx, newy, newz = newpos
distance = newdistance
end
end
-- after the for-loop a new best node is found, which gets saved
x = newx
y = newy
z = newz
distance = Vdist(x, y, z, tx, ty, tz) -- calculating new distance
end
As you can see from the above picture, the function works just fine if I am in the general area, meaning that in this case there is no obvious error in my logic.
It also works just fine if I fly over the highway once, then teleport far away and execute the function in a moderate timeframe. The function will still find all appropriate positions and resolve in the above way. I don’t know an upper bound for how long it will reliably work.
However it is definitely not a given that a player was at many places, also most likely the game is going to unload pathnodes after some time. If that happens the results look like in the below picture. This is the exact picture I got after executing the above script without the while-loop. However I could get to this result a few times with a sensible amount of natives that are supposed to load pathnodes or navmesh.
Not everything has failed: Blue and Green function executed as they should. White and yellow however didn’t. There exists only one yellow node, at (0, 0, 0). White should start at the northern end of Paleto Bay (compare with the correct attempt, the colors match). However it starts somewhere beneath the Paleto Bay PD, which lines up pretty much perfect with the border between the areas Paleto Bay and Paleto Forest. That’s where my suspicion comes from that Paleto Forest is loaded, Paleto Bay isn’t. The issue starts in line 1 - the start coordinates that are returned do not match the input at all (I checked this by printing the inputs and the output). Also the white function tries to reach (0, 0, 0). This means that for white the target coordinate (line 2) native failed to return a pathnode, defaulting to the standard values.
Same is true for yellow, where both start and target coordinates return (0, 0, 0).
Also something interesting to note:
Because of the way the zones lay on the map both white and yellow go through three zones whereas blue and green only impact two zones. Could this be what in the end results in the failure? Because I’m only loading the zones at start and finish, the zone in the middle might not be loaded thus resulting in false returns?