Built-inClient

vmag2

VMAG20xA8CEACB4F35AE058

The GTA V native VMAG2 of the BUILTIN namespace, as LS:MP client scripts call it: the global function vmag2, in JavaScript and in Lua.

SignatureJavaScript
vmag2(x: number, y: number, z: number): number
SignatureLua
vmag2(x: number, y: number, z: number): number

Usage

JavaScript
const value = vmag2(x, y, z);
Lua
local value = vmag2(x, y, 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 value = vmag2(pos);
Lua · with vectors
local value = vmag2(pos)

Parameters

ParameterTypeJavaScriptLua
xfloatnumbernumber
yfloatnumbernumber
zfloatnumbernumber

Returns

float JavaScript number, Lua number

Notes

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

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

Reference

Namespace
Built-in BUILTIN
In the game
float VMAG2(float x, float y, float z)
Hash
0xA8CEACB4F35AE058

Open in the interactive natives reference