Built-inClient

vmag

VMAG0x652D2EEEF1D3E62C

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

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

Usage

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

Reference

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

Open in the interactive natives reference