GraphicsClient

setDrawOrigin

SET_DRAW_ORIGIN0xAA0008F3BBB8F416

The GTA V native SET_DRAW_ORIGIN of the GRAPHICS namespace, as LS:MP client scripts call it: the global function setDrawOrigin, in JavaScript and in Lua.

SignatureJavaScript
setDrawOrigin(x: number, y: number, z: number, p3: boolean): void
SignatureLua
setDrawOrigin(x: number, y: number, z: number, p3: boolean)

Usage

JavaScript
setDrawOrigin(x, y, z, p3);
Lua
setDrawOrigin(x, y, z, p3)

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
setDrawOrigin(pos, p3);
Lua · with vectors
setDrawOrigin(pos, p3)

Parameters

ParameterTypeJavaScriptLua
xfloatnumbernumber
yfloatnumbernumber
zfloatnumbernumber
p3BOOLbooleanboolean

Returns

Nothing. In JavaScript the call evaluates to undefined.

Notes

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

Sets the on-screen drawing origin for draw-functions (which is normally x=0,y=0 in the upper left corner of the screen) to a world coordinate.
From now on, the screen coordinate which displays the given world coordinate on the screen is seen as x=0,y=0.

Example in C#:

Vector3 boneCoord = somePed.GetBoneCoord(Bone.SKEL_Head);
Function.Call(Hash.SET_DRAW_ORIGIN, boneCoord.X, boneCoord.Y, boneCoord.Z, 0);
Function.Call(Hash.DRAW_SPRITE, "helicopterhud", "hud_corner", -0.01, -0.015, 0.013, 0.013, 0.0, 255, 0, 0, 200);
Function.Call(Hash.DRAW_SPRITE, "helicopterhud", "hud_corner", 0.01, -0.015, 0.013, 0.013, 90.0, 255, 0, 0, 200);
Function.Call(Hash.DRAW_SPRITE, "helicopterhud", "hud_corner", -0.01, 0.015, 0.013, 0.013, 270.0, 255, 0, 0, 200);
Function.Call(Hash.DRAW_SPRITE, "helicopterhud", "hud_corner", 0.01, 0.015, 0.013, 0.013, 180.0, 255, 0, 0, 200);
Function.Call(Hash.CLEAR_DRAW_ORIGIN);

If the pedestrian starts walking around now, the sprites are always around her head, no matter where the head is displayed on the screen.

This function also effects the drawing of texts and other UI-elements.
The effect can be reset by calling clearDrawOrigin().

Reference

Namespace
Graphics GRAPHICS
In the game
void SET_DRAW_ORIGIN(float x, float y, float z, BOOL p3)
Hash
0xAA0008F3BBB8F416

Open in the interactive natives reference