getClosestRoad
GET_CLOSEST_ROAD0x132F52BBA570FE92The GTA V native GET_CLOSEST_ROAD of the PATHFIND namespace, as LS:MP client scripts call it: the global function getClosestRoad, in JavaScript and in Lua.
getClosestRoad(
x: number,
y: number,
z: number,
minLength: number,
minLanes: number,
ignoreSwitchedOffNodes: boolean
): [
ok: boolean,
southEnd: { x: number, y: number, z: number },
northEnd: { x: number, y: number, z: number },
lanesSouth: number,
lanesNorth: number,
medianWidth: number
]getClosestRoad(
x: number,
y: number,
z: number,
minLength: number,
minLanes: integer,
ignoreSwitchedOffNodes: boolean
): boolean, Vector3, Vector3, integer, integer, numberUsage
JavaScript
const [ok, southEnd, northEnd, lanesSouth, lanesNorth, medianWidth] =
getClosestRoad(x, y, z, minLength, minLanes, ignoreSwitchedOffNodes);Lua
local ok, southEnd, northEnd, lanesSouth, lanesNorth, medianWidth =
getClosestRoad(x, y, z, minLength, minLanes, ignoreSwitchedOffNodes)Three consecutive numbers can be given as one vector: { x, y, z } (or [x, y, z]) in JavaScript, a Vector3 in Lua.
JavaScript · with vectors
const [ok, southEnd, northEnd, lanesSouth, lanesNorth, medianWidth] = getClosestRoad(
pos, minLength, minLanes, ignoreSwitchedOffNodes
);Lua · with vectors
local ok, southEnd, northEnd, lanesSouth, lanesNorth, medianWidth = getClosestRoad(
pos, minLength, minLanes, ignoreSwitchedOffNodes
)Parameters
| Parameter | Type | JavaScript | Lua |
|---|---|---|---|
x | float | number | number |
y | float | number | number |
z | float | number | number |
minLength | float | number | number |
minLanes | int | number | integer |
ignoreSwitchedOffNodes | BOOL | boolean | boolean |
Returns
6 values, in this order: an array in JavaScript, multiple return values in Lua.
| # | Value | Type | JavaScript | Lua | Description |
|---|---|---|---|---|---|
| 1 | ok | BOOL | boolean | boolean | The native’s own return value. |
| 2 | southEnd | Vector3 | { x: number, y: number, z: number } | Vector3 | output |
| 3 | northEnd | Vector3 | { x: number, y: number, z: number } | Vector3 | output |
| 4 | lanesSouth | int | number | integer | output |
| 5 | lanesNorth | int | number | integer | output |
| 6 | medianWidth | float | number | number | output |
On LS:MP
ℹ
Road segment
Returns success, the south and north endpoints, the two directional lane counts and the median width. Use finite coordinates within ±100,000, a minimum length from 0 to 100,000, and 0 to 32 minimum lanes.
ℹ
GTA V Enhanced 1158.16
This LS:MP adapter is available on Enhanced 1158.16. Calls on another build raise an error.
Reference
- Namespace
- Pathfinding PATHFIND
- In the game
BOOL GET_CLOSEST_ROAD(float x, float y, float z, float minLength, int minLanes, Vector3* southEnd, Vector3* northEnd, int* lanesSouth, int* lanesNorth, float* medianWidth, BOOL ignoreSwitchedOffNodes)- Hash
0x132F52BBA570FE92