GetGroundZFor3dCoord
Docslocal retval, groundZ = GetGroundZFor3dCoord(x, y, z, includeWater)Description
This native gets the ground level (ground elevation) and returns the Z coordinate that represents it.
Note: This native can only calculate the elevation when the coordinates are within the render distance of the client.
NativeDB Added Parameter 6: BOOL p5
Parameters
| Name | Type | Description |
|---|---|---|
x | float | Position on the X-axis to get ground elevation. |
y | float | Position on the Y-axis to get ground elevation. |
z | float | Position on the Z-axis to get ground elevation. |
groundZ | float* | — |
includeWater | BOOL | Determines if the top water level at the specified position should be considered the ground elevation. (It would only matter if the specified position is located above or under the water) |
Quick Snippet: Get Coordinatesxyz
xyzAdd this command to your client script to retrieve precise locations in-game.
-- Add this to your client.lua. Type /pos in-game to copy coords.
RegisterCommand('pos', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local output = string.format("vector4(%.2f, %.2f, %.2f, %.2f)", coords.x, coords.y, coords.z, heading)
print(output)
TriggerEvent('chat:addMessage', { args = { '^4[COORD]^0', output } })
end)Returns
BOOLReturns TRUE (1) or FALSE (0).
Examples
Official
local ped = PlayerPedId()
local pedCoords = GetEntityCoords(ped)
local retval, groundZ = GetGroundZFor_3dCoord(pedCoords.x, pedCoords.y, pedCoords.z, true)
if retval then
-- Do stuff with groundZ
end