getNthClosestPathNode
Client
Finds the nth road or footpath node closest to a point.
int, vec3|false getNthClosestPathNode(float x, y, z, int n [, string type = car, bool water = false])
Parameters
| Name | Type | Description |
|---|---|---|
| x, y, z | float | The point to search from. |
| n | int | Which node: 1 is the closest, 2 the next one, and so on. Below 1 raises an error. |
| type | string | car for roads, ped for footpaths.default car |
| water | bool | true searches only the boat paths on water; false, only on land.default false |
Returns
The node's id and its position, or false if there are not that many nodes.
Example
local position = getElementPosition(localPlayer)
for n = 1, 5 do
local node = getNthClosestPathNode(position.x, position.y, position.z, n)
if not node then
break
end
outputDebugString(("node %d: %d"):format(n, node))
endNoteOnly nodes in loaded path areas count: those near the player, or requested with
requestPathNodesInArea.