# CFX::GET_ENTITY_COORDS

- **Hash:** `0x1647F1CB`
- **Namespace:** CFX
- **Runtime name (Lua/JS):** `GetEntityCoords`
- **Side:** server (Cfx runtime native)
- **Name status:** official
- **Documentation:** described with examples
- **URL:** https://natives.borderlinerp.com/natives/CFX/GET_ENTITY_COORDS

## Signature

```c
Vector3 GET_ENTITY_COORDS(Entity entity);
```

## Parameters

- `entity` (`Entity`) — The entity to get the coordinates from.

## Returns

`Vector3` — The current entity coordinates.

## Description

*Source: 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](#\_0x3FEF770D40960D5A) for client side.

## Usage

### Lua

```lua
local retval = GetEntityCoords(entity)

-- always available, by hash
local retval = Citizen.InvokeNative(0x1647f1cb, entity, Citizen.ResultAsVector())
```

### JavaScript

```js
const retval = GetEntityCoords(entity);

// by hash
const retval = Citizen.invokeNative('0x1647f1cb', entity, Citizen.returnResultAnyway(), Citizen.resultAsVector());
```

### C#

```csharp
Vector3 retval = Function.Call<Vector3>((Hash)0x1647f1cb, entity);
```

## Examples

*Source: Cfx.re native reference*

```lua
local function ShowCoordinates()
    local player = source
    local ped = GetPlayerPed(player)
    local playerCoords = GetEntityCoords(ped)

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

RegisterNetEvent("myCoordinates")
AddEventHandler("myCoordinates", ShowCoordinates)
```

*Source: Cfx.re native reference*

```js
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}`);
});
```

*Source: Cfx.re native reference*

```cs
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

- [CFX::SET_ENTITY_COORDS](https://natives.borderlinerp.com/natives/CFX/SET_ENTITY_COORDS.md) — Sets the coordinates (world position) for a specified entity, offset by the radius of the entity on the Z axis.

*Sources: Cfx.re native reference.*
