getClosestPathNode
Shared
Finds the road or footpath node closest to a point.
int, vec3|false getClosestPathNode(float x, y, z [, string type = car, bool water = false])
Parameters
| Name | Type | Description |
|---|---|---|
| x, y, z | float | The point to search from. |
| 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 no node was found.
A node id joins the path area (750 m wide) and the node's index in it: area << 16 | node.
Example
local position = getElementPosition(localPlayer)
local node, nodePosition = getClosestPathNode(position.x, position.y, position.z)
if node then
setElementPosition(localPlayer, nodePosition.x, nodePosition.y, nodePosition.z + 1)
endNoteOnly nodes in loaded path areas count: those near the player, or requested with
requestPathNodesInArea.