GetOffsetFromCoordAndHeadingInWorldCoords
Docslocal retval = GetOffsetFromCoordAndHeadingInWorldCoords(xPos, yPos, zPos, heading, xOffset, yOffset, zOffset)Description
Calculates the world coordinates after applying the specified offsets to the given position, relative to a certain heading.
This native is similar to <code>GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS</code>, but uses a world position and heading as the reference point.
Parameters
| Name | Type | Description |
|---|---|---|
xPos | float | The X coordinate of the original position. |
yPos | float | The Y coordinate of the original position. |
zPos | float | The Z coordinate of the original position. |
heading | float | The heading (in degrees) relative to which the offsets are applied. |
xOffset | float | Left/right offset from the coord. |
yOffset | float | Forward/backward offset from the coord. |
zOffset | float | Upward/downward offset from the coord. |
Quick Snippet: Get CoordinatesxPosyPoszPosheading
xPosyPoszPosheadingAdd 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
Vector3Returns a 3D vector (x, y, z).