EntityClient

getOffsetFromEntityGivenWorldCoords

GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS0x2274BC1C4885E333

The GTA V native GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS of the ENTITY namespace, as LS:MP client scripts call it: the global function getOffsetFromEntityGivenWorldCoords, in JavaScript and in Lua.

SignatureJavaScript
getOffsetFromEntityGivenWorldCoords(
  entity: Entity,
  posX: number,
  posY: number,
  posZ: number
): { x: number, y: number, z: number }
SignatureLua
getOffsetFromEntityGivenWorldCoords(
  entity: Entity,
  posX: number,
  posY: number,
  posZ: number
): Vector3

Usage

JavaScript
const { x, y, z } = getOffsetFromEntityGivenWorldCoords(entity, posX, posY, posZ);
Lua
local coords = getOffsetFromEntityGivenWorldCoords(entity, posX, posY, posZ)
-- coords.x, coords.y, coords.z

Three consecutive numbers can be given as one vector: { x, y, z } (or [x, y, z]) in JavaScript, a Vector3 in Lua.

JavaScript · with vectors
const coords = getOffsetFromEntityGivenWorldCoords(entity, pos);
Lua · with vectors
local coords = getOffsetFromEntityGivenWorldCoords(entity, pos)

Parameters

ParameterTypeJavaScriptLua
entityEntitynumberinteger
posXfloatnumbernumber
posYfloatnumbernumber
posZfloatnumbernumber

Returns

Vector3 JavaScript { x: number, y: number, z: number }, Lua Vector3

A 3D vector. JavaScript gets a plain { x, y, z } object; Lua gets a real Vector3, with .x .y .z and arithmetic. As an argument, one vector fills three consecutive coordinates.

Notes

From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.

Converts world coords (posX - Z) to coords relative to the entity

Example:
posX is given as 50
entity's x coord is 40
the returned x coord will then be 10 or -10, not sure haven't used this in a while (think it is 10 though).

Reference

Namespace
Entity ENTITY
In the game
Vector3 GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS(Entity entity, float posX, float posY, float posZ)
Hash
0x2274BC1C4885E333

Open in the interactive natives reference