MiscClient1 output

getGroundZFor3dCoord

GET_GROUND_Z_FOR_3D_COORD0xC906A7DAB05C8D2B

The GTA V native GET_GROUND_Z_FOR_3D_COORD of the MISC namespace, as LS:MP client scripts call it: the global function getGroundZFor3dCoord, in JavaScript and in Lua.

SignatureJavaScript
getGroundZFor3dCoord(
  x: number,
  y: number,
  z: number,
  ignoreWater: boolean,
  p5: boolean
): [ok: boolean, groundZ: number]
SignatureLua
getGroundZFor3dCoord(
  x: number,
  y: number,
  z: number,
  ignoreWater: boolean,
  p5: boolean
): boolean, number

Usage

JavaScript
const [ok, groundZ] = getGroundZFor3dCoord(x, y, z, ignoreWater, p5);
Lua
local ok, groundZ = getGroundZFor3dCoord(x, y, z, ignoreWater, p5)

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, groundZ] = getGroundZFor3dCoord(pos, ignoreWater, p5);
Lua · with vectors
local ok, groundZ = getGroundZFor3dCoord(pos, ignoreWater, p5)

Parameters

ParameterTypeJavaScriptLuaDescription
xfloatnumbernumberPosition on the X-axis to get ground elevation at.
yfloatnumbernumberPosition on the Y-axis to get ground elevation at.
zfloatnumbernumberPosition on the Z-axis to get ground elevation at.
ignoreWaterBOOLbooleanbooleanNearly always 0, very rarely 1 in the scripts
p5BOOLbooleanboolean

Returns

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

#ValueTypeJavaScriptLuaDescription
1okBOOLbooleanbooleanThe native’s own return value.
2groundZfloatnumbernumberThe ground elevation at the specified position. output

On LS:MP

✓
Friendlier helper

lsmp.getGroundZ is this call with the tuple collapsed: the height, or null when no ground was found.

Notes

From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.

Gets the ground elevation at the specified position. Note that if the specified position is below ground level, the function will output zero!

Bear in mind this native can only calculate the elevation when the coordinates are within the client's render distance.

Reference

Namespace
Misc MISC
In the game
BOOL GET_GROUND_Z_FOR_3D_COORD(float x, float y, float z, float* groundZ, BOOL ignoreWater, BOOL p5)
Hash
0xC906A7DAB05C8D2B

Open in the interactive natives reference