GET_ENTITY_COORDS
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.
CFX
Signature
lua
GetEntityCoords(entity)
-- returns Vector3Parameters
| Name | Type | Description |
|---|---|---|
| Entity | The entity to get the coordinates from. |
Usage
Named call
GetEntityCoords(entity)InvokeNative
Citizen.InvokeNative(0x1647F1CB, entity)lua 1
local function ShowCoordinates()
local player = source
local ped = GetPlayerPed(player)
local playerCoords = GetEntityCoords(ped)
print(playerCoords) -- vector3(...)
end
RegisterNetEvent("myCoordinates")
AddEventHandler("myCoordinates", ShowCoordinates)js 2
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 3
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}");
}
Details
- Hash
- API set
- Source
- cfx
Source: cfx
