Vectors
vector2, vector3 and vector4 values for positions, directions and rotations.
vector2
Section titled “vector2”vector2(x?, y?) --> vector2Create a vector2 with 2 numbers (x, y). Server and client.
| Parameter | Type | Description |
|---|---|---|
x (optional) |
number |
x component. With only one number, all components get it. |
y (optional) |
number |
y component. With only one number, all components get it. |
Returns
vector2: Read-only vector.
local size = vector2(1920, 1080)print(size.x, size.y)Compared to FiveM: Same as in FiveM: + - * / with vectors and numbers, #v is the length, v.xy and other swizzles, type(v) returns “vector2”. GAMPEON uses double precision.
vec2(x?, y?) --> vector2Short name for vector2. Server and client.
| Parameter | Type | Description |
|---|---|---|
x (optional) |
number |
x component. |
y (optional) |
number |
y component. |
Returns
vector2: Read-only vector.
local v = vec2(1, 2)Compared to FiveM: Same as in FiveM.
vector3
Section titled “vector3”vector3(x?, y?, z?) --> vector3Create a vector3 with 3 numbers (x, y, z). Server and client.
Vectors are values: components cannot be changed, create a new vector instead. They keep their type in events between server and client and in exports.
| Parameter | Type | Description |
|---|---|---|
x (optional) |
number |
x component. With only one number, all components get it. |
y (optional) |
number |
y component. With only one number, all components get it. |
z (optional) |
number |
z component. With only one number, all components get it. |
Returns
vector3: Read-only vector.
local spawn = vector3(120.0, -45.5, 30.0)local dist = #(GetEntityCoords(ped) - spawn)Compared to FiveM: Same as in FiveM: + - * / with vectors and numbers, #v is the length, v.xy and other swizzles, type(v) returns “vector3”. GAMPEON uses double precision.
vec3(x?, y?, z?) --> vector3Short name for vector3. Server and client.
| Parameter | Type | Description |
|---|---|---|
x (optional) |
number |
x component. |
y (optional) |
number |
y component. |
z (optional) |
number |
z component. |
Returns
vector3: Read-only vector.
local v = vec3(1, 2, 3)Compared to FiveM: Same as in FiveM.
vector4
Section titled “vector4”vector4(x?, y?, z?, w?) --> vector4Create a vector4 with 4 numbers (x, y, z, w). Server and client.
| Parameter | Type | Description |
|---|---|---|
x (optional) |
number |
x component. With only one number, all components get it. |
y (optional) |
number |
y component. With only one number, all components get it. |
z (optional) |
number |
z component. With only one number, all components get it. |
w (optional) |
number |
w component. With only one number, all components get it. |
Returns
vector4: Read-only vector.
local spawnWithHeading = vector4(120.0, -45.5, 30.0, 90.0)print(spawnWithHeading.w)Compared to FiveM: Same as in FiveM: + - * / with vectors and numbers, #v is the length, v.xy and other swizzles, type(v) returns “vector4”. GAMPEON uses double precision.
vec4(x?, y?, z?, w?) --> vector4Short name for vector4. Server and client.
| Parameter | Type | Description |
|---|---|---|
x (optional) |
number |
x component. |
y (optional) |
number |
y component. |
z (optional) |
number |
z component. |
w (optional) |
number |
w component. |
Returns
vector4: Read-only vector.
local v = vec4(1, 2, 3, 4)Compared to FiveM: Same as in FiveM.
vec(x, y, z?, w?) --> vector2|vector3|vector4Create a vector with 2, 3 or 4 numbers. Server and client.
| Parameter | Type | Description |
|---|---|---|
x |
number |
x |
y |
number |
y |
z (optional) |
number |
z |
w (optional) |
number |
w |
Returns
vector2|vector3|vector4: Vector with as many components as arguments.
local v = vec(1, 2, 3) -- vector3Compared to FiveM: Same as in FiveM.