Skip to content
GAMPEONCreate
New project
Preview: this works today, but details can still change.

Vectors

vector2, vector3 and vector4 values for positions, directions and rotations.

vector2(x?, y?) --> vector2

Create 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?) --> vector2

Short 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(x?, y?, z?) --> vector3

Create 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?) --> vector3

Short 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(x?, y?, z?, w?) --> vector4

Create 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?) --> vector4

Short 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|vector4

Create 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) -- vector3

Compared to FiveM: Same as in FiveM.

Report a problem with this pageOther ways to give feedback