PathfindingClientChecked by LS:MP5 outputs

getClosestRoad

GET_CLOSEST_ROAD0x132F52BBA570FE92

The 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.

SignatureJavaScript
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
]
SignatureLua
getClosestRoad(
  x: number,
  y: number,
  z: number,
  minLength: number,
  minLanes: integer,
  ignoreSwitchedOffNodes: boolean
): boolean, Vector3, Vector3, integer, integer, number

Usage

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

ParameterTypeJavaScriptLua
xfloatnumbernumber
yfloatnumbernumber
zfloatnumbernumber
minLengthfloatnumbernumber
minLanesintnumberinteger
ignoreSwitchedOffNodesBOOLbooleanboolean

Returns

6 values, in this order: an array in JavaScript, multiple return values in Lua.

#ValueTypeJavaScriptLuaDescription
1okBOOLbooleanbooleanThe native’s own return value.
2southEndVector3{ x: number, y: number, z: number }Vector3output
3northEndVector3{ x: number, y: number, z: number }Vector3output
4lanesSouthintnumberintegeroutput
5lanesNorthintnumberintegeroutput
6medianWidthfloatnumbernumberoutput

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

Open in the interactive natives reference