getSafeCoordForPed
GET_SAFE_COORD_FOR_PED0xB61C8E878A4199CAThe GTA V native GET_SAFE_COORD_FOR_PED of the PATHFIND namespace, as LS:MP client scripts call it: the global function getSafeCoordForPed, in JavaScript and in Lua.
getSafeCoordForPed(
x: number,
y: number,
z: number,
onGround: boolean,
flags: number
): [ok: boolean, outPosition: { x: number, y: number, z: number }]getSafeCoordForPed(
x: number,
y: number,
z: number,
onGround: boolean,
flags: integer
): boolean, Vector3Usage
const [ok, outPosition] = getSafeCoordForPed(x, y, z, onGround, flags);local ok, outPosition = getSafeCoordForPed(x, y, z, onGround, flags)Three consecutive numbers can be given as one vector: { x, y, z } (or [x, y, z]) in JavaScript, a Vector3 in Lua.
const [ok, outPosition] = getSafeCoordForPed(pos, onGround, flags);local ok, outPosition = getSafeCoordForPed(pos, onGround, flags)Parameters
| Parameter | Type | JavaScript | Lua |
|---|---|---|---|
x | float | number | number |
y | float | number | number |
z | float | number | number |
onGround | BOOL | boolean | boolean |
flags | int | number | integer |
Returns
2 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 | outPosition | Vector3 | { x: number, y: number, z: number } | Vector3 | output |
Notes
From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.
Flags are:
1 = 1 = B02_IsFootpath
2 = 4 = !B15_InteractionUnk
4 = 0x20 = !B14_IsInterior
8 = 0x40 = !B07_IsWater
16 = 0x200 = B17_IsFlatGround
When onGround == true outPosition is a position located on the nearest pavement.
When a safe coord could not be found the result of a function is false and outPosition == Vector3.Zero.
In the scripts these flags are used: 0, 14, 12, 16, 20, 21, 28. 0 is most commonly used, then 16.
16 works for me, 0 crashed the script.
Reference
- Namespace
- Pathfinding PATHFIND
- In the game
BOOL GET_SAFE_COORD_FOR_PED(float x, float y, float z, BOOL onGround, Vector3* outPosition, int flags)- Hash
0xB61C8E878A4199CA