SixL server API / vehicle / VehicleMp

Interface: VehicleMp

A server-created vehicle.

Remarks

Looks (colours, mods, neon, extras, plate, tint, lights, wheels) are kept by the server and sent to the clients as entity data (sixl: keys, see server/docs/state-to-clients.md) to every client that has the vehicle streamed in, also to those who stream it in later. A member marked "partial" is stored and sent, but the game does not show it yet. Setters raise no event.

Example

const car = mp.vehicles.new('sultan', new mp.Vector3(0, 0, 70), { heading: 90 });

Extends

Properties

alpha

alpha: number

Opacity, 0 (invisible) to 255 (opaque).

Remarks

Values are clamped to 0..255 and rounded down. Partial: the value reaches the clients as the entity data sixl:alpha but the game does not show it yet.

Example

vehicle.alpha = 128;

Inherited from

EntityMp.alpha


bodyHealth

bodyHealth: number

The vehicle's body health.

Remarks

Partial: starts at 1000, on the 0..1000 scale. Reading gives the health from the driver's report; a write is sent to the clients that stream the vehicle, and a report taken before the game applied it (for about two seconds) does not undo it. The game keeps health in coarse steps, so the value read back can differ a little from the one written. A write is not damage; a drop that the driver reports raises vehicleDamage.

Example

car.bodyHealth = 1000;

brake

brake: boolean

Whether the brake lights are on.

Remarks

Partial: sent as sixl:flags; the game does not show it yet.

Example

car.brake = true;

controller

controller: PlayerMp

The player who controls (owns the physics of) the vehicle.

Remarks

Partial: server-side only, not sent to the clients. By default the server's owner of the vehicle (normally the driver); a script may assign one.

Example

const owner = car.controller;

customTires

customTires: boolean

Whether the vehicle has custom tyres.

Remarks

Partial: sent as sixl:wheels; the game does not show it yet.

Example

car.customTires = true;

dashboardColor

dashboardColor: number

The dashboard colour index.

Remarks

Partial: kept on the server and sent to clients as sixl:colors; the game does not apply it (no call for this colour is known in the game). The paint a script sets is the look's tint (vehicle.look).

Example

car.dashboardColor = 5;

data

data: any

The shared variables as properties: entity.data.key reads, entity.data.key = value sets.

Remarks

A view over BaseEntityMp.getVariable / BaseEntityMp.setVariable: setting a key sends it to clients exactly like setVariable.

Example

player.data.cash = 100;

Inherited from

EntityMp.data


dead

readonly dead: boolean

Whether the vehicle is destroyed.

Remarks

Read-only: the driver reports a destroyed flag, the server relays it, and vehicleDeath is raised on the first change. explode() sets it too; spawn() clears it.

Example

if (car.dead) car.spawn(pos, 0);

dimension

dimension: number

The dimension the entity lives in: players see and stream only entities of their own dimension.

Remarks

Dimension 0 is the default world. For players it is applied at once and the streaming is recomputed; for other entities it is picked up on the next tick. For PlayerMp.isStreamed dimension 0 counts as global; for vehicles, peds and objects (isStreamed) the dimensions must be equal.

Example

player.dimension = 5;

Inherited from

EntityMp.dimension


engine

engine: boolean

Whether the engine runs.

Remarks

Partial: sent as sixl:flags; the game does not show it yet.

Example

car.engine = true;

engineHealth

engineHealth: number

The vehicle's engine health.

Remarks

Partial: starts at 1000 (explode() sets -4000), on the 0..1000 scale. Reading gives the health from the driver's report; a write is sent to the clients that stream the vehicle and is held against a stale report like bodyHealth. The engine's scale in the game is not yet checked there. A drop that the driver reports raises vehicleDamage.

Example

const hp = car.engineHealth;

extras

readonly extras: object

The extras that were set.

Index Signature

[index: number]: boolean

Remarks

Partial: a copy as an object of extra id to boolean (RAGE MP's typings declare an array).

Example

const extras = car.extras;

heading

heading: number

The vehicle's heading, in degrees.

Remarks

The server updates it from the driver's reports; a script may set it (it turns the vehicle). The streaming grid is not recomputed by a heading change.

Example

const h = car.heading;

highbeams

highbeams: boolean

Whether the high beams are on.

Remarks

Partial: sent as sixl:flags; the game does not show it yet.

Example

car.highbeams = true;

horn

horn: boolean

Whether the horn sounds.

Remarks

Partial: sent as sixl:flags; the game does not show it yet.

Example

car.horn = true;

id

readonly id: number

The entity's id, unique within its pool (mp.players, mp.vehicles …).

Remarks

Ids are server-side and start at 0 or 1 per pool, so two entities of different kinds can share one. The client's remoteId is this same number.

Example

const vehicle = mp.vehicles.at(vehicleId);

Inherited from

EntityMp.id


livery

livery: number

The livery index.

Remarks

Partial: sent to the server and to clients (sixl:livery); the game does not show it yet.

Example

car.livery = 2;

locked

locked: boolean

Whether the vehicle is locked.

Remarks

Partial: sent to the server and to clients (sixl:locked); the game does not show it yet.

Example

car.locked = true;

look

look: string[]

The vehicle's paint, as VI recipes: [c0 ... c7] hex strings (a four-element v1 form is also accepted); null until known.

Remarks

A SixL addition. The first client that shows the vehicle reports the paint its game picked; a script's value repaints the vehicle for everyone. Setting a value of another length throws a TypeError.

Example

car.look = trafficCar.look;

model

model: string | number

The entity's model.

Remarks

VI's model keys are 64-bit values and GTA V model names do not resolve in VI. Vehicles, peds and objects report the model as it was given at creation, a name string (a hash that mp.joaat computed in this run is turned back into its name; an unknown hash becomes its decimal string). Players report what the script set (a VI key as a "0x..." string, a name or a hash; 0 until set). Setting it on a player reaches the clients: the player's own game loads the model and puts it on the player, and every client reads it as that player's model (not yet checked in the game); on a vehicle, ped or object it changes the server's copy and raises entityModelChange but is not sent to clients.

Example

const model = vehicle.model;

Inherited from

EntityMp.model


mods

readonly mods: object

The tuning parts that were set.

Index Signature

[modType: number]: number

Remarks

Partial: a copy as an object of mod slot to index (RAGE MP's typings declare an array).

Example

const mods = car.mods;

movable

movable: boolean

Whether the vehicle can be moved.

Remarks

Partial: default true; sent as sixl:movable; the game does not enforce it yet.

Example

car.movable = false;

neonEnabled

neonEnabled: boolean

Whether the neon lights are on.

Remarks

Partial: sent to the server and to clients (sixl:neon); the game does not show it yet.

Example

car.neonEnabled = true;

numberPlate

numberPlate: string

The licence plate text.

Remarks

Partial: sent to the server and to streaming clients as sixl:plate; the game does not show it yet.

Example

car.numberPlate = 'SIXL 1';

numberPlateType

numberPlateType: number

The licence plate style.

Remarks

Partial: sent as sixl:plate; the game does not show it yet.

Example

car.numberPlateType = 1;

pearlescentColor

pearlescentColor: number

The pearlescent colour index.

Remarks

Partial: kept on the server and sent to clients as sixl:colors; the game does not apply it (it has no call that paints a car by colour). The paint a script sets is the look's tint (vehicle.look).

Example

car.pearlescentColor = 5;

position

position: Vector3

The entity's position in metres.

Remarks

Reading returns the script host's copy. Setting moves the entity: for players, vehicles, peds and objects the new position is sent to the server (for peds the new position does not reach the clients yet). A blip, marker, label or checkpoint streams the new position to the players.

Example

player.position = new mp.Vector3(0, 0, 70);

Inherited from

EntityMp.position


quaternion

readonly quaternion: Quaternion

The vehicle's rotation as a quaternion.

Remarks

Partial: read-only, computed from VehicleMp.rotation; not sent to the clients.

Example

const { w } = car.quaternion;

rocketBoost

rocketBoost: boolean

Whether the rocket boost is active.

Remarks

Partial: sent as sixl:rocketBoost; the game does not show it yet.

Example

car.rocketBoost = true;

rotation

rotation: Vector3

The vehicle's rotation (pitch, roll, yaw) in degrees.

Remarks

Partial: setting it only changes the script host's copy; the server has no handler for it.

Example

const yaw = car.rotation.z;

siren

siren: boolean

Whether the siren is on.

Remarks

Partial: sent as sixl:flags; the game does not show it yet.

Example

car.siren = true;

steerAngle

steerAngle: number

The vehicle's steering angle.

Remarks

Partial: not sent to the clients. The driver's report carries no steering angle, so only what a script set (and spawn() resets to 0) is read back.

Example

car.steerAngle = 0;

streamedPlayers

readonly streamedPlayers: PlayerMp[]

The players who have this vehicle streamed in.

Remarks

Partial: an estimate from distance (the streaming range, 200 m by default) and dimension in the script host, not the server's real stream list.

Example

for (const p of car.streamedPlayers) p.notify('A car nearby');

taxiLights

taxiLights: boolean

Whether the taxi light is on.

Remarks

Partial: sent as sixl:flags; the game does not show it yet.

Example

car.taxiLights = true;

trailer

trailer: VehicleMp

The trailer pulled by the vehicle.

Remarks

Partial: server data only (sixl:trailer); nothing is attached in the game. Setting it also sets traileredBy on the trailer and clears it on the old trailer.

Example

truck.trailer = trailer;

traileredBy

readonly traileredBy: VehicleMp

The vehicle that pulls this one.

Remarks

Partial: read-only; set by assigning trailer on the towing vehicle.

Example

const tow = trailer.traileredBy;

trimColor

trimColor: number

The interior trim colour index.

Remarks

Partial: kept on the server and sent to clients as sixl:colors; the game does not apply it (no call for this colour is known in the game). The paint a script sets is the look's tint (vehicle.look).

Example

car.trimColor = 5;

type

readonly type: string

The kind of entity.

Remarks

'player', 'vehicle', 'ped' or 'object'.

Example

if (entity.type === 'vehicle') { }

Inherited from

EntityMp.type


velocity

readonly velocity: Vector3

The vehicle's velocity.

Remarks

Read-only: comes from the driver's state report, in RAGE MP's axes. Zero without a driver.

Example

const speed = car.velocity.length();

wheelColor

wheelColor: number

The wheel colour index.

Remarks

Partial: kept on the server and sent to clients as sixl:wheels; the game does not apply it (it has no call that sets a car's extra colours). The paint a script sets is the look's tint (vehicle.look).

Example

car.wheelColor = 12;

wheelType

wheelType: number

The wheel type.

Remarks

Partial: sent as sixl:wheels; the game does not show it yet.

Example

car.wheelType = 3;

windowTint

windowTint: number

The window tint.

Remarks

Partial: sent as sixl:windowTint; the game does not show it yet.

Example

car.windowTint = 1;

Methods

destroy()

destroy(): void

Removes the entity.

Returns

void

Remarks

For vehicles, peds and objects the entity is gone from its pool the moment destroy() returns (exists is false at once) and entityDestroyed follows. Players cannot be destroyed: use kick().

Example

vehicle.destroy();

Inherited from

EntityMp.destroy


dist()

dist(position): number

The distance from the entity to a point or another entity.

Parameters

position

IVector3 | { position: IVector3; }

A point (anything with x, y, z, metres) or an entity (anything with position).

Returns

number

The 3D distance in metres.

Example

if (player.dist(shop.position) < 3) { }

Inherited from

EntityMp.dist


distSquared()

distSquared(position): number

The squared distance (no square root: cheaper for comparisons).

Parameters

position

IVector3 | { position: IVector3; }

A point (anything with x, y, z, metres) or an entity (anything with position).

Returns

number

The squared 3D distance, metres squared.

Example

if (player.distSquared(point) < 25) { }

Inherited from

EntityMp.distSquared


explode()

explode(): void

Blows the vehicle up.

Returns

void

Remarks

Partial: sets dead, turns the engine off, zeroes the body health and raises vehicleDeath once (the driver's later report of the death is not a second one; a report taken before the explosion does not undo it). Sent as a one-shot counter, so a client that streams the vehicle in later does not replay an old explosion.

Example

car.explode();

getColor()

getColor(id): number

Reads a colour index.

Parameters

id

number

0 for primary, anything else for secondary.

Returns

number

The palette index set by setColor; 0 if never set.

Remarks

Partial: server-held state; the game does not show it yet.

Example

const primary = car.getColor(0);

getColorRGB()

getColorRGB(id): Array3d

Reads a colour as RGB.

Parameters

id

number

0 for primary, anything else for secondary.

Returns

Array3d

[r, g, b]; white (255, 255, 255) if never set.

Remarks

Partial: server-held state; the game does not show it yet.

Example

const [r, g, b] = car.getColorRGB(0);

getExtra()

getExtra(index): boolean

Whether an extra is on.

Parameters

index

number

The extra id.

Returns

boolean

True when enabled; false if never set.

Remarks

Partial: server-held state; the game does not show it yet.

Example

const on = car.getExtra(1);

getMod()

getMod(modType): number

Reads a tuning part.

Parameters

modType

number

The mod slot.

Returns

number

The mod index; -1 if none is set.

Remarks

Partial: reads the copy of what the server keeps; the game does not show mods yet.

Example

const engineMod = car.getMod(11);

getNeonColor()

getNeonColor(): number[]

Reads the neon colour.

Returns

number[]

[r, g, b]; black (0, 0, 0) if never set.

Remarks

Partial: server-held state; the game does not show it yet.

Example

const [r, g, b] = car.getNeonColor();

getOccupant()

getOccupant(seat): PlayerMp

The player in a seat.

Parameters

seat

number

The seat, 0 = driver.

Returns

PlayerMp

The player, or undefined for an empty seat. Read from a mirror of the server's seat table.

Example

const driver = car.getOccupant(0);

getOccupants()

getOccupants(): PlayerMp[]

Every player in the vehicle.

Returns

PlayerMp[]

An array of players, in seat order of the mirror.

Example

for (const p of car.getOccupants()) p.notify('Fasten your seat belt');

getOwnVariable()

getOwnVariable<T>(name): T

Reads a variable only this player's client sees (set with EntityMp.setOwnVariable).

Type Parameters

T

T = any

Parameters

name

string

The variable's key.

Returns

T

The value, or undefined when it was never set. Read from the script host's copy.

Example

const token = player.getOwnVariable('token');

Inherited from

EntityMp.getOwnVariable


getPaint()

getPaint(id): VehiclePaint

Reads the paint of a slot.

Parameters

id

number

0 for primary, anything else for secondary.

Returns

VehiclePaint

{ type, color }; zeros if never set. RAGE MP's typings declare a number here.

Remarks

Partial: server-held state; the game does not show it yet.

Example

const { type, color } = car.getPaint(0);

getVariable()

getVariable<T>(name): T

Reads a shared variable (set by BaseEntityMp.setVariable).

Type Parameters

T

T = any

Parameters

name

string

The variable's key.

Returns

T

The value, or undefined when it was never set. Read from the script host's own copy: no round trip.

Example

const job = player.getVariable('job');

Inherited from

EntityMp.getVariable


isStreamed()

isStreamed(player): boolean

Whether a player has the vehicle streamed in.

Parameters

player

PlayerMp

The player.

Returns

boolean

True when the player is in the same dimension (exactly equal) and within the streaming range (3D, 200 m by default).

Remarks

Partial: an estimate in the script host, not the server's real stream list.

Example

if (car.isStreamed(player)) { }

repair()

repair(): void

Repairs the vehicle: body and engine health back to 1000.

Returns

void

Remarks

Partial: sent as the one-shot counter sixl:repair; the game does not show it yet.

Example

car.repair();

setColor()

setColor(primary, secondary): void

Sets the primary and secondary colour by palette index.

Parameters

primary

number

The primary colour index.

secondary

number

The secondary colour index.

Returns

void

Remarks

Partial: kept on the server and sent to clients as sixl:colors; the game does not apply it (it has no call that paints a car by colour). The paint a script sets is the look's tint (vehicle.look).

Example

car.setColor(12, 0);

setColorRGB()

setColorRGB(red1, green1, blue1, red2, green2, blue2): void

Sets the primary and secondary colour as RGB.

Parameters

red1

number

Primary red, 0..255.

green1

number

Primary green, 0..255.

blue1

number

Primary blue, 0..255.

red2

number

Secondary red, 0..255.

green2

number

Secondary green, 0..255.

blue2

number

Secondary blue, 0..255.

Returns

void

Remarks

Partial: kept on the server and sent to clients as sixl:colors; the game does not apply it (it has no call that paints a car by colour). The paint a script sets is the look's tint (vehicle.look).

Example

car.setColorRGB(255, 0, 0, 0, 0, 0);

setExtra()

setExtra(index, value): void

Turns an extra on or off.

Parameters

index

number

The extra id.

value

boolean

True to enable.

Returns

void

Remarks

Partial: sent as sixl:extras; the game does not show it yet.

Example

car.setExtra(1, true);

setMod()

setMod(modType, modIndex): void

Sets a tuning part.

Parameters

modType

number

The mod slot.

modIndex

number

The mod index within the slot.

Returns

void

Remarks

Partial: the server keeps the mods and answers every call with the current set; getMod reads the answer to the last call. Sent as sixl:mods; the game does not show it yet.

Example

car.setMod(11, 3);

setNeonColor()

setNeonColor(red, green, blue): void

Sets the neon colour.

Parameters

red

number

Red, 0..255.

green

number

Green, 0..255.

blue

number

Blue, 0..255.

Returns

void

Remarks

Partial: sent as sixl:neon; the game does not show it yet.

Example

car.setNeonColor(0, 255, 255);

setOccupant()

setOccupant(seat, player): void

Seats a player, or empties a seat.

Parameters

seat

number

The seat, 0 = driver.

player

number | PlayerMp

The player (or its id); null empties the seat.

Returns

void

Remarks

The server seats the player in its seat table and records the vehicle as the player's.

Example

car.setOccupant(0, player);

setOwnVariable()

setOwnVariable(key, value): void

Sets a variable that only this player's own client receives.

Parameters

key

string

The variable's key.

value

any

Any JSON-serialisable value.

Returns

void

Remarks

Only players send it: the client reads it with mp.players.local.getOwnVariable(key). On vehicles, peds and objects it is kept in the script host only.

Example

player.setOwnVariable('token', 'abc');

Inherited from

EntityMp.setOwnVariable


setOwnVariables()

setOwnVariables(values): void

Sets several own variables; the same as EntityMp.setOwnVariable for each key.

Parameters

values

KeyValueCollection

An object of key to value.

Returns

void

Example

player.setOwnVariables({ token: 'abc', slot: 2 });

Inherited from

EntityMp.setOwnVariables


setPaint()

setPaint(primaryType, primaryColor, secondaryType, secondaryColor): void

Sets the paint type and colour of both slots.

Parameters

primaryType

number

The primary paint type.

primaryColor

number

The primary colour index.

secondaryType

number

The secondary paint type.

secondaryColor

number

The secondary colour index.

Returns

void

Remarks

Partial: kept on the server and sent to clients as sixl:colors; the game does not apply it (it has no call that paints a car by colour). The paint a script sets is the look's tint (vehicle.look).

Example

car.setPaint(0, 12, 0, 0);

setVariable()

setVariable(name, value): void

Sets a shared variable on the entity.

Parameters

name

string

The variable's key.

value

any

Any JSON-serialisable value.

Returns

void

Remarks

The script's own copy changes at once. Players, vehicles, peds and objects also send it to the clients that have the entity streamed in (with the size and rate limits of the server; a refused change is logged by the script host and the local copy stays). Colshapes and dummies keep it on the server only. Blips, markers, labels and checkpoints send it with their other data.

Example

vehicle.setVariable('fuel', 42);

Inherited from

EntityMp.setVariable


setVariables()

setVariables(values): void

Sets several shared variables at once; the same as calling BaseEntityMp.setVariable for each key.

Parameters

values

KeyValueCollection

An object of key to value.

Returns

void

Example

player.setVariables({ job: 'taxi', level: 3 });

Inherited from

EntityMp.setVariables


spawn()

spawn(position, heading?): void

Puts the vehicle back at a position, undamaged and alive.

Parameters

position

Vector3

Where (metres).

heading?

number

Optional. The heading in degrees.

Returns

void

Remarks

Partial: server-side only, the clients are not told except for the position and heading. Resets health to 1000, clears dead, the velocity and the steering angle.

Example

car.spawn(new mp.Vector3(0, 0, 70), 90);