Native referenceFiveM

SET_ENTITY_COORDS

0x06843DA7060A026B ENTITY
FUNCTION SIGNATURE
void SET_ENTITY_COORDS(Entity entity, float xPos, float yPos, float zPos, BOOL alive, BOOL deadFlag, BOOL ragdollFlag, BOOL clearArea);
Property Value
Native Name SET_ENTITY_COORDS
Hash 0x06843DA7060A026B
Return Type void
Parameters entity (Entity), xPos (float), yPos (float), zPos (float), alive (BOOL), deadFlag (BOOL), ragdollFlag (BOOL), clearArea (BOOL)

Description: Sets the coordinates (world position) for a specified entity, offset by the radius of the entity on the Z axis.

Parameters

  • entity (Entity) — The entity to change coordinates for.
  • xPos (float) — The X coordinate.
  • yPos (float) — The Y coordinate.
  • zPos (float) — The Z coordinate, ground level.
  • alive (BOOL) — Unused by the game, potentially used by debug builds of GTA in order to assert whether or not an entity was alive.
  • deadFlag (BOOL) — Whether to disable physics for dead peds, too, and not just living peds.
  • ragdollFlag (BOOL) — A special flag used for ragdolling peds.
  • clearArea (BOOL) — Whether to clear any entities in the target area.

Examples

local ped = PlayerPedId()
local currentPos = GetEntityCoords(ped)
print(currentPos)

SetEntityCoords(ped, 674.883, 548.269, 133.94, false, false, false, true)

currentPos = GetEntityCoords(ped)
print(currentPos) -- changed!
const ped = PlayerPedId();
let currentPos = GetEntityCoords(ped, false);
console.log(`${currentPos[0]} ${currentPos[1]} ${currentPos[2]}`);

SetEntityCoords(ped, 674.883, 548.269, 133.94, false, false, false, true);

currentPos = GetEntityCoords(ped, false);
console.log(`${currentPos[0]} ${currentPos[1]} ${currentPos[2]}`); // changed!
using static CitizenFX.Core.Native.API;
// ...

int ped = PlayerPedId();
Vector3 currentPos = GetEntityCoords(ped, false);
Debug.WriteLine($"{currentPos}");

SetEntityCoords(ped, 674.883f, 548.269f, 133.94f, false, false, false, true);

currentPos = GetEntityCoords(ped, false);
Debug.WriteLine($"{currentPos}"); // changed!

// or the preferred use of C# wrapper
Debug.WriteLine($"{Game.PlayerPed.Position}");

Game.PlayerPed.Position = new Vector3(674.883f, 548.269f, 133.94f);

Debug.WriteLine($"{Game.PlayerPed.Position}"); // changed!
Back to ENTITY