HUDClient2 outputs

getHudScreenPositionFromWorldPosition

GET_HUD_SCREEN_POSITION_FROM_WORLD_POSITION0xF9904D11F1ACBEC3

The GTA V native GET_HUD_SCREEN_POSITION_FROM_WORLD_POSITION of the HUD namespace, as LS:MP client scripts call it: the global function getHudScreenPositionFromWorldPosition, in JavaScript and in Lua.

SignatureJavaScript
getHudScreenPositionFromWorldPosition(
  worldX: number,
  worldY: number,
  worldZ: number
): [result: number, screenX: number, screenY: number]
SignatureLua
getHudScreenPositionFromWorldPosition(
  worldX: number,
  worldY: number,
  worldZ: number
): integer, number, number

Usage

JavaScript
const [result, screenX, screenY] =
  getHudScreenPositionFromWorldPosition(worldX, worldY, worldZ);
Lua
local result, screenX, screenY = getHudScreenPositionFromWorldPosition(worldX, worldY, worldZ)

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 [result, screenX, screenY] = getHudScreenPositionFromWorldPosition(world);
Lua · with vectors
local result, screenX, screenY = getHudScreenPositionFromWorldPosition(world)

Parameters

ParameterTypeJavaScriptLua
worldXfloatnumbernumber
worldYfloatnumbernumber
worldZfloatnumbernumber

Returns

3 values, in this order: an array in JavaScript, multiple return values in Lua.

#ValueTypeJavaScriptLuaDescription
1resultintnumberintegerThe native’s own return value.
2screenXfloatnumbernumberoutput
3screenYfloatnumbernumberoutput

Notes

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

World to relative screen coords, this world to screen will keep the text on screen.

Reference

Namespace
HUD HUD
In the game
int GET_HUD_SCREEN_POSITION_FROM_WORLD_POSITION(float worldX, float worldY, float worldZ, float* screenX, float* screenY)
Hash
0xF9904D11F1ACBEC3
Formerly
_GET_2D_COORD_FROM_3D_COORD

Open in the interactive natives reference