RedM Natives

VMAG2

Calculates the magnitude of a vector but does not perform Sqrt operations.

Hash0xA8CEACB4F35AE058
Runtime nameVmag2
NamespaceBUILTIN
SideClient
NameOfficial
Docs
Since build1207
GTA V hash0xA8CEACB4F35AE058

Signature

float VMAG2(float x, float y, float z);

Parameters

NameTypeDescription
xfloat—
yfloat—
zfloat—

Returns float

Description

Calculates the magnitude of a vector but does not perform Sqrt operations. (Its way faster)

Usage

Lua
local retval = Vmag2(x, y, z)

-- always works, by hash
local retval = Citizen.InvokeNative(0xA8CEACB4F35AE058, x, y, z, Citizen.ResultAsFloat())
JavaScript and C#
JavaScript
const retval = Vmag2(x, y, z);

// by hash
const retval = Citizen.invokeNative('0xA8CEACB4F35AE058', x + 0.0000001, y + 0.0000001, z + 0.0000001, Citizen.returnResultAnyway(), Citizen.resultAsFloat());
C#
float retval = Function.Call<float>((Hash)0xA8CEACB4F35AE058, x, y, z);
  • Float parameters: Lua integers (10, or whole numbers decoded from NUI/JSON) are sent as ints and read as garbage. Write 10.0 or value + 0.0. The generated JS wrappers add 0.0000001 to non-zero floats for the same reason.

Sources

alloc8or RDR3 NativeDB

Something wrong or missing? Contribute a verified note — corrections ship through pull requests.