RedM Natives

GET_ENTITY_COORDS

Gets the current coordinates for a specified entity.

Hash0x1647F1CB
Runtime nameGetEntityCoords
NamespaceCFX
SideServer
NameOfficial
Docs

Signature

Vector3 GET_ENTITY_COORDS(Entity entity);

Parameters

NameTypeDescription
entityEntity

The entity to get the coordinates from.

Returns Vector3 — The current entity coordinates.

Description

Cfx.re native reference

Gets the current coordinates for a specified entity. This native is used server side when using OneSync.

See GET_ENTITY_COORDS for client side.

Usage

Lua
local retval = GetEntityCoords(entity)

-- always works, by hash
local retval = Citizen.InvokeNative(0x1647f1cb, entity, Citizen.ResultAsVector())
JavaScript and C#
JavaScript
const retval = GetEntityCoords(entity);

// by hash
const retval = Citizen.invokeNative('0x1647f1cb', entity, Citizen.returnResultAnyway(), Citizen.resultAsVector());
C#
Vector3 retval = Function.Call<Vector3>((Hash)0x1647f1cb, entity);

Examples

LUA · Cfx.re native reference
local function ShowCoordinates()
    local player = source
    local ped = GetPlayerPed(player)
    local playerCoords = GetEntityCoords(ped)

    print(playerCoords) -- vector3(...)
end

RegisterNetEvent("myCoordinates")
AddEventHandler("myCoordinates", ShowCoordinates)
JS · Cfx.re native reference
onNet('myCoordinates', () => {
  const player = global.source; // use (global as any).source for Typescript
  const ped = GetPlayerPed(player);
  const [playerX, playerY, playerZ] = GetEntityCoords(ped);

  console.log(`${playerX}, ${playerY}, ${playerZ}`);
});
CS · Cfx.re native reference
using static CitizenFX.Core.Native.API;
// ...

// In class constructor
EventHandlers["myCoordinates"] += new Action<Player>(ShowCoordinates);

// Delegate method
private void ShowCoordinates([FromSource]Player player) {
    Vector3 playerCoords = GetEntityCoords(player.Character);

    // or the preferred use of C# wrapper
    Vector3 playerCoords = player.Character.Position;

    Debug.WriteLine($"{playerCoords}");
}

See also

Sources

Cfx.re native reference

Something wrong or missing? Contribute a verified note — corrections ship through pull requests.