Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Vehicle

A vehicle is an extension of the Entity class.

example
// Get the vehicle a player is driving.
const vehicle = alt.Vehicle.all.find(veh => veh.driver && veh.driver.name === 'Stuyk');
if (!vehicle) {
    console.log('Stuyk is not driving a vehicle');
} else {
    console.log('Stuyk is driving a vehicle.')
    const player = vehicle.driver;
}
export

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new Vehicle(model: string | number, x: number, y: number, z: number, rx: number, ry: number, rz: number, streamingDistance?: number): Vehicle
  • new Vehicle(model: string | number, pos: IVector3, rot: IVector3, streamingDistance?: number): Vehicle
  • Parameters

    • model: string | number
    • x: number
    • y: number
    • z: number
    • rx: number
    • ry: number
    • rz: number
    • Optional streamingDistance: number

    Returns Vehicle

  • Parameters

    • model: string | number
    • pos: IVector3
    • rot: IVector3
    • Optional streamingDistance: number

    Returns Vehicle

Properties

Readonly accelerationLevel

accelerationLevel: number

activeRadioStation

activeRadioStation: RadioStation

Gets or sets the active radio station.

example
const someVehicle = alt.Vehicle.all[0];
const stationNumber = someVehicle.activeRadioStation;
console.log(`Current Station: ${stationNumber}`);

someVehicle.activeRadioStation = 255;
console.log(`Vehicle radio station was turned off.`);

Readonly attached

attached: Vehicle | null

Gets a vehicle that is attached to the vehicle instance.

Readonly attachedTo

attachedTo: Vehicle | null

Gets a vehicle where the vehicle is attached to.

boatAnchorActive

boatAnchorActive: boolean

Gets or sets the status of the boat anchor.

bodyAdditionalHealth

bodyAdditionalHealth: number

Gets or sets the additional body health.

bodyHealth

bodyHealth: number

Gets or sets the body health.

Readonly brakeLevel

brakeLevel: number

collision

collision: boolean

counterMeasureCount

counterMeasureCount: number

customPrimaryColor

customPrimaryColor: RGBA

Gets or sets the custom primary color as a RGBA type.

example
const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
someVehicle.customPrimaryColor = new alt.RGBA(255, 0, 0);
console.log(`Vehicle custom primary color was set to red`);

customSecondaryColor

customSecondaryColor: RGBA

Gets or sets the custom secondary color as a RGBA type.

example
const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
someVehicle.customSecondaryColor = new alt.RGBA(255, 0, 0);
console.log(`Vehicle custom secondary color was set to red`);

customTires

customTires: boolean

Gets or sets if the vehicle instance has custom tires.

darkness

darkness: number

Applies some decoration effects to the vehicle (e.g.: It makes the hydra looking rusty or applies snow to the front bumper of policeold1). Does not work on every vehicle model.

example
const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
someVehicle.darkness = 500;

dashboardColor

dashboardColor: number

Gets or sets the dashboard color of the vehicle.

Dash board colors range from 0 to 159.

example
const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
someVehicle.dashboardColor = 139;

Readonly daylightOn

daylightOn: boolean

Gets the current state of the daylights.

example
const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
if (someVehicle.daylightOn) {
    console.log('Vehicle daylights are on');
} else {
    console.log('Vehicle daylights are off');
}

Readonly destroyed

destroyed: boolean

Gets if a vehicle is destroyed.

Destroyed is set to true when specific game activities cause the engine to stop. Explosions, being underwater, crashing too much, etc.

example
const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);

if (someVehicle.destroyed) {
   console.log(`The elegy has been destroyed.`);
}

dimension

dimension: number

Object dimension.

remarks

Check https://docs.altv.mp/articles/dimensions.html to understand how it works.

dirtLevel

dirtLevel: number

Gets or sets the dirt level of the vehicle.

driftModeEnabled

driftModeEnabled: boolean

Gets or sets the drift mode state of the vehicle.

Readonly driver

driver: Player | null

Gets the current driver of the vehicle. It returns null, if there is no driver.

example
const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
const driver = someVehicle.driver;

if (driver) {
    console.log(`There is currently a player driving this car. ${driver.name}`);
}

engineHealth

engineHealth: number

Gets or sets the current engine health.

Default maximum engine health is 1000. The vehicle.repair() function should be used to repair a vehicle if the engine health is less than or equal to zero.

This example demonstrates that when you drive through a ColShape it will repair the vehicle.

example
const someColShape = new alt.ColshapeCircle(-1295.9208984375, 86.0835189819336, 2);
someColShape.repairVehicles = true;

alt.on('entityEnterColshape', (colshape, entity) => {
      // Check if the entity is a vehicle or not.
    if (!(entity instanceof alt.Vehicle)) {
       return;
    }

    // Check if it's the right colshape to do this.
    if (!colshape.repairVehicles) {
       return;
    }

    if (entity.destroyed) {
        entity.repair();
        console.log('Repaired Destroyed Vehicle');
        return;
    }

    entity.engineHealth = 1000;
    console.log('Repaired Vehicle')
});

engineOn

engineOn: boolean

Gets or sets the engine state of the vehicle.

The functionality of the vehicle engine can be triggered on either client-side or server-side. If you want to trigger the engine on client-side use native.setVehicleEngineOn.

example
const vehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
vehicle.engineOn = true;

Readonly flamethrowerActive

flamethrowerActive: boolean

Gets if a flamethrower of a vehicle is active on vehicle models like cerberus.

Readonly frontWheels

frontWheels: number

Gets the type of the front wheels.

frozen

frozen: boolean

Readonly handbrakeActive

handbrakeActive: boolean

Gets if the handbrake of a car is active.

Readonly hasArmoredWindows

hasArmoredWindows: boolean

Gets if the car has armored windows.

Readonly hasTimedExplosion

hasTimedExplosion: boolean

headlightColor

headlightColor: number

Gets or sets the headlight color of a vehicle.

hornActive

hornActive: boolean

hybridExtraActive

hybridExtraActive: boolean

hybridExtraState

hybridExtraState: number

Readonly id

id: number

interiorColor

interiorColor: number

Gets or sets the interior color of a vehicle.

isMissionTrain

isMissionTrain: boolean

Gets or sets if the created train is a mission train.

isTrainCaboose

isTrainCaboose: boolean

Gets or sets if the train is a caboose.

isTrainEngine

isTrainEngine: boolean

Gets or sets if the train is the engine of the train.

lightState

lightState: number

lightsMultiplier

lightsMultiplier: number

Gets or sets the lights intensity and distance of a vehicle.

livery

livery: number

Gets or sets the livery of a vehicle.

lockState

lockState: VehicleLockState

Gets or sets the lock state of a vehicle.

manualEngineControl

manualEngineControl: boolean

Enables or disables the manual engine control.

modKit

modKit: number

Gets or sets the current mod kit of a vehicle.

Readonly modKitsCount

modKitsCount: number

Gets the maximum amount of vehicle mod kits available.

neon

Enables or disables a neon light on a specific position.

neonColor

neonColor: RGBA

Gets or sets the color of the neon lights.

Readonly netOwner

netOwner: Player | null

Network owner of the entity.

remarks

Network owner is responsible for syncing entity with the server. It changes when actual network owner passes the migration range, then the new one is determined based on distance from the entity (if entity is a vehicle, then the driver will take priority for becoming network owner). Disabling migration range will stop this process from happening until turned on again.

Readonly nightlightOn

nightlightOn: boolean

Gets the current state of the nightlights.

numberPlateIndex

numberPlateIndex: NumberPlateStyle

Gets or sets the current number plate style.

numberPlateText

numberPlateText: string

Gets or sets the current text displayed on the number plate.

Readonly passengers

passengers: IVehiclePassenger

Gets all passengers of the vehicle including the driver itself.

example
const someVehicle = new alt.Vehicle('elegy', 0, 0, 0, 0, 0, 0);
const passengers = someVehicle.passengers;

for (const [seat, player] of Object.entries(passengers)) {
   alt.log(`Seat: ${seat} - Player: ${player.name}`);
}

pearlColor

pearlColor: number

Gets or sets the pearl color of a vehicle.

petrolTankHealth

petrolTankHealth: number

Gets or sets the current health amount of the petrol tank.

pos

pos: Vector3

Object position.

primaryColor

primaryColor: number

Gets or sets the current primary color of a vehicle.

quaternion

quaternion: Quaternion

Gets or sets the vehicles rotation with a quaternion.

Readonly rearWheels

rearWheels: number

Gets the type of the rear wheels.

Readonly refCount

refCount: number

Returns the ref count of the entity.

remarks

It's only available in debug-mode.

Readonly repairsCount

repairsCount: number

Gets how often a vehicle got repaired.

rocketRefuelSpeed

rocketRefuelSpeed: number

roofClosed

roofClosed: boolean

Opens or closes the vehicle roof (if vehicle has this feature, otherwise it is always true).

example
const surano = new alt.Vehicle('surano', 0, 0, 72, 0, 0, 0);
surano.roofClosed = false; // Hides the roof of the car

roofLivery

roofLivery: number

Gets or sets the roof livery of a vehicle.

roofState

roofState: boolean

Gets or sets the roof state of a vehicle (closed or open).

deprecated

Use roofClosed instead.

rot

rot: Vector3

Entity rotation.

remarks

Values are provided in radians.

scriptMaxSpeed

scriptMaxSpeed: number
remarks

Value is in meters per second.

secondaryColor

secondaryColor: number

Gets or sets the current secondary color.

sirenActive

sirenActive: boolean

Gets or sets the siren state of a vehicle.

Readonly steeringAngle

steeringAngle: number

streamed

streamed: boolean

Whether the entity should be streamed for other entities.

streamingDistance

streamingDistance: number

Readonly timedExplosionCulprit

timedExplosionCulprit: Player

Readonly timedExplosionTime

timedExplosionTime: number

Readonly timestamp

timestamp: number

tireSmokeColor

tireSmokeColor: RGBA

Gets or sets the color of the tire smoke.

trainCarriageConfigIndex

trainCarriageConfigIndex: number

Gets or sets the config index of the train's carriage.

trainConfigIndex

trainConfigIndex: number

Gets or sets the trains config index.

remarks

You can find a list of all possible config indices in the trains.xml. Valid indices are between 1 and 25.

trainCruiseSpeed

trainCruiseSpeed: number

Gets or sets the cruise speed of the train.

trainDirection

trainDirection: boolean

Gets or sets the direction of the train.

trainDistanceFromEngine

trainDistanceFromEngine: number

Gets or sets the distance of the trains to the engine.

Readonly trainEngineId

trainEngineId: Vehicle | null

Gets the engine of the train.

trainForceDoorsOpen

trainForceDoorsOpen: boolean

Gets or sets if the doors of the trains should be forced open.

Readonly trainLinkedToBackwardId

trainLinkedToBackwardId: Vehicle | null

Gets another train that is linked to the back of the train. Returns null if there is no linked train.

Readonly trainLinkedToForwardId

trainLinkedToForwardId: Vehicle | null

Gets another train that is linked to the back of the train. Returns null if there is no linked train in front.

trainPassengerCarriages

trainPassengerCarriages: boolean

Gets or sets if the train is a passenger carriage.

trainRenderDerailed

trainRenderDerailed: boolean

Gets or sets if the trains is rendered derailed.

trainTrackId

trainTrackId: number

Gets or sets the track id of the train.

remarks

Valid track ids are between 0 and 11.

trainUnk1

trainUnk1: boolean

trainUnk2

trainUnk2: boolean

trainUnk3

trainUnk3: boolean

Readonly type

Type of the object.

Readonly valid

valid: boolean

Object usability.

returns

False if object is no longer usable.

Readonly velocity

velocity: Vector3

Gets the velocity vector of a vehicle.

visible

visible: boolean

Whether the entity is visible.

wheelColor

wheelColor: number

Gets or sets the wheel color.

Readonly wheelType

wheelType: number

Gets the wheel type.

Readonly wheelsCount

wheelsCount: number

Gets the amount of wheels of a vehicle.

windowTint

windowTint: WindowTint

Gets or sets the window tint of a vehicle.

Static Readonly all

all: readonly Vehicle[]

Array with all vehicles.

remarks

This creates a clone of the array everytime it is called. It is advised to call this once and store the result in a variable, before iterating over it.

example
const vehicles = alt.Vehicle.all; // Store it in a variable, so it doesn't create a copy of the array on each iteration
for(let i = 0; i < vehicles.length; i++)
{
  alt.log(`${vehicles[i].model}`); // Logs the model of every vehicle
}

Static Readonly count

count: number

Accessors

model

  • get model(): number
  • Get the entity model hash.

    example
    const comparisonHash = alt.hash('infernus');
    if (comparisonHash === someVehicle.model) {
        console.log('This vehicle is an infernus.');
    } else {
        console.log('This vehicle is not an infernus.');
    }
    
    remarks

    Vehicle doesn't provide a setter.

    Returns number

Methods

attachTo

  • attachTo(entity: Entity, entityBone: number | string, ownBone: number | string, pos: IVector3, rot: IVector3, enableCollisions: boolean, noFixedRotation: boolean): void
  • Attaches this entity to another entity.

    Parameters

    • entity: Entity

      Target entity.

    • entityBone: number | string

      Target bone id or name.

    • ownBone: number | string

      Origin bone id or name.

    • pos: IVector3

      Position offset.

    • rot: IVector3

      Rotation - needs to be in radians.

    • enableCollisions: boolean

      If true the attached entity has a collision.

    • noFixedRotation: boolean

      If false the entity is attached with a fixed rotation (no bouncing). That means if the value in native was true, you have to use false in the serverside method

    Returns void

deleteMeta

  • deleteMeta(key: string): void
  • deleteMeta<K>(key: K): void
  • Parameters

    • key: string

    Returns void

  • Type parameters

    Parameters

    • key: K

    Returns void

deleteStreamSyncedMeta

  • deleteStreamSyncedMeta(key: string): void
  • deleteStreamSyncedMeta<K>(key: K): void

deleteSyncedMeta

  • deleteSyncedMeta(key: string): void
  • deleteSyncedMeta<K>(key: K): void

destroy

  • destroy(): void
  • Removes the object from the world.

    Returns void

detach

  • detach(): void
  • Detaches this entity if attached to another entity.

    Returns void

doesWheelHasTire

  • doesWheelHasTire(wheelId: number): boolean
  • Returns if a specific wheel has a tire.

    Parameters

    • wheelId: number

      The specific wheel based on the id

    Returns boolean

    True when the wheel has a tire, otherwise false.

getAppearanceDataBase64

  • getAppearanceDataBase64(): string
  • Returns the appearance of a vehicle as a base64 string.

    Returns string

    A base64 string.

getArmoredWindowHealth

  • getArmoredWindowHealth(windowId: number): number
  • Returns the health of a specific armored window.

    Parameters

    • windowId: number

      The window id.

    Returns number

    The amount of health.

getArmoredWindowShootCount

  • getArmoredWindowShootCount(windowId: number): number
  • Returns the amount of shoots that a specific armoured window received.

    Parameters

    • windowId: number

      The window id.

    Returns number

    The amount of shoots that a window received.

getBumperDamageLevel

  • Returns the damage level of a specific bumper.

    Parameters

    Returns VehicleBumperDamage

    The damage level of a bumper.

  • Type parameters

    • T: number

    • V: number = VehicleBumperDamage

    Parameters

    • bumperId: T

    Returns V

getDamageStatusBase64

  • getDamageStatusBase64(): string
  • Returns the damage status of a vehicle as a base64 string.

    Returns string

    A base64 string of the damage status.

getDoorState

  • Returns the state of a specific door.

    Parameters

    Returns VehicleDoorState

    The state of the door.

  • Type parameters

    • T: number

    • V: number = VehicleDoorState

    Parameters

    • doorId: T

    Returns V

getExtra

  • getExtra(extraId: number): boolean
  • Returns the state of a specific extra of a vehicle.

    remarks

    Extras are not available on every vehicle model.

    Parameters

    • extraId: number

      The id of the extra.

    Returns boolean

    True when the extra is enabled, otherwise false.

getGamestateDataBase64

  • getGamestateDataBase64(): string
  • Returns the game state data of a vehicle as a base64 string.

    Returns string

    A base64 string of the game state data.

getHealthDataBase64

  • getHealthDataBase64(): string
  • Returns the health data of a vehicle as a base64 string.

    Returns string

    A base64 string of the health data.

getMeta

  • getMeta<K>(key: Exclude<K, keyof ICustomVehicleMeta>): unknown
  • getMeta<K>(key: K): ICustomVehicleMeta[K] | undefined
  • getMeta<V>(key: string): V | undefined
  • Type parameters

    • K: string

    Parameters

    Returns unknown

  • Type parameters

    Parameters

    • key: K

    Returns ICustomVehicleMeta[K] | undefined

  • deprecated

    See ICustomVehicleMeta

    Type parameters

    • V: any

    Parameters

    • key: string

    Returns V | undefined

getMetaDataKeys

  • getMetaDataKeys(): readonly string[]

getMod

  • getMod(modType: VehicleModType): number
  • getMod<T>(modType: T): number
  • Returns the mod value for a specific mod type.

    Parameters

    Returns number

    The value of the mod type.

  • Type parameters

    • T: number

    Parameters

    • modType: T

    Returns number

getModsCount

  • getModsCount(modType: VehicleModType): number
  • getModsCount<T>(modType: T): number
  • Returns the amount of possible mod values for a specific mod type.

    Parameters

    Returns number

    The amount of possible mod values of a mod type.

  • Type parameters

    • T: number

    Parameters

    • modType: T

    Returns number

getPartBulletHoles

  • getPartBulletHoles(partId: VehiclePart): number
  • getPartBulletHoles<T>(partId: T): number
  • Returns the amount of bullet holes of a vehicle part.

    Parameters

    Returns number

    The amount of bullet holes of a vehicle part.

  • Type parameters

    • T: number

    Parameters

    • partId: T

    Returns number

getPartDamageLevel

  • Returns the damage level of a vehicle part.

    Parameters

    Returns VehiclePartDamage

    The damage level of a vehicle part.

  • Type parameters

    • T: number

    • V: number = VehiclePartDamage

    Parameters

    • partId: T

    Returns V

getScriptDataBase64

  • getScriptDataBase64(): string
  • Returns the script data of a vehicle as a base64 string.

    Returns string

    A base64 string of the script data.

getStreamSyncedMeta

  • getStreamSyncedMeta<K>(key: Exclude<K, keyof ICustomVehicleStreamSyncedMeta>): unknown
  • getStreamSyncedMeta<K>(key: K): ICustomVehicleStreamSyncedMeta[K] | undefined
  • getStreamSyncedMeta<V>(key: string): V | undefined

getStreamSyncedMetaKeys

  • getStreamSyncedMetaKeys(): readonly string[]

getSyncedMeta

  • getSyncedMeta<K>(key: Exclude<K, keyof ICustomVehicleSyncedMeta>): unknown
  • getSyncedMeta<K>(key: K): ICustomVehicleSyncedMeta[K] | undefined
  • getSyncedMeta<V>(key: string): V | undefined

getSyncedMetaKeys

  • getSyncedMetaKeys(): readonly string[]

getWeaponCapacity

  • getWeaponCapacity(weaponIndex: number): number
  • Parameters

    • weaponIndex: number

    Returns number

getWheelHealth

  • getWheelHealth(wheelId: number): number
  • Returns the health of a specific wheel.

    Parameters

    • wheelId: number

      The id of the wheel.

    Returns number

    The amount of health of a specific wheel.

hasMeta

  • hasMeta(key: string): boolean
  • hasMeta<K>(key: K): boolean
  • Parameters

    • key: string

    Returns boolean

  • Type parameters

    Parameters

    • key: K

    Returns boolean

hasStreamSyncedMeta

  • hasStreamSyncedMeta(key: string): boolean
  • hasStreamSyncedMeta<K>(key: K): boolean

hasSyncedMeta

  • hasSyncedMeta(key: string): boolean
  • hasSyncedMeta<K>(key: K): boolean

isLightDamaged

  • isLightDamaged(lightId: number): boolean
  • Returns if a specific light is damaged.

    Parameters

    • lightId: number

      The id of the light.

    Returns boolean

    True if the light is damaged, otherwise false.

isSpecialLightDamaged

  • isSpecialLightDamaged(specialLightId: number): boolean
  • Returns if a specific special light is damaged.

    Parameters

    • specialLightId: number

      The id of the special light.

    Returns boolean

    True if the special light is damaged, otherwise false.

isWheelBurst

  • isWheelBurst(wheelId: number): boolean
  • Returns if a specific wheel is burst.

    Parameters

    • wheelId: number

      The id of the wheel.

    Returns boolean

    True if the wheel is burst, otherwise false.

isWheelDetached

  • isWheelDetached(wheelId: number): boolean
  • Returns if a specific wheel is detached.

    Parameters

    • wheelId: number

      The id of the wheel.

    Returns boolean

    True if the wheel is detached, otherwise false.

isWheelOnFire

  • isWheelOnFire(wheelId: number): boolean
  • Returns if a specific wheel is on fire.

    Parameters

    • wheelId: number

      The id of the wheel.

    Returns boolean

    True if the wheel is on fire, otherwise false.

isWindowDamaged

  • isWindowDamaged(windowId: number): boolean
  • Returns if a specific window is damaged.

    Parameters

    • windowId: number

      The id of the window.

    Returns boolean

    True if the window is damaged, otherwise false.

isWindowOpened

  • isWindowOpened(windowId: number): boolean
  • Returns if a specific window is open.

    Parameters

    • windowId: number

      The id of the window.

    Returns boolean

    True if the window is open, otherwise false.

repair

  • repair(): void

resetNetOwner

  • resetNetOwner(disableMigration?: boolean): void
  • Resets overwritten network owner.

    remarks

    See {@link Entity~netOwner} to understand how network owner works.

    Keep in mind that disabling migration can lead to unexpected behaviour when the network owner gets out of the streaming range.

    Parameters

    • Optional disableMigration: boolean

      Pass true to disable migration, false to keep it enabled. If not specified, it defaults to "false".

    Returns void

setAppearanceDataBase64

  • setAppearanceDataBase64(data: string): void
  • Sets the appearance of a vehicle with a base64 string.

    Parameters

    • data: string

      The base64 string of the appearance data.

    Returns void

setArmoredWindowHealth

  • setArmoredWindowHealth(windowId: number, health: number): void
  • Sets the health of a specific armored window.

    Parameters

    • windowId: number

      The id of the window.

    • health: number

      The amount of health.

    Returns void

setArmoredWindowShootCount

  • setArmoredWindowShootCount(windowId: number, count: number): void
  • Sets the shoot count of a specific armoured window.

    Parameters

    • windowId: number

      The id of the window.

    • count: number

      The amount of shoots.

    Returns void

setBadge

setBumperDamageLevel

  • Sets the damage level of a specific bumper.

    Parameters

    Returns void

  • Type parameters

    • T: number

    • V: number = VehicleBumperDamage

    Parameters

    • bumperId: T
    • level: V

    Returns void

setDamageStatusBase64

  • setDamageStatusBase64(data: string): void
  • Sets the damage status of a vehicle based on a base64 string.

    Parameters

    • data: string

      A base64 string that represents the damage status.

    Returns void

setDoorState

  • Sets the state of a specific door

    Parameters

    Returns void

  • Type parameters

    • T: number

    • V: number = VehicleDoorState

    Parameters

    • doorId: T
    • state: V

    Returns void

setExtra

  • setExtra(extraId: number, state: boolean): void
  • Sets the state of an extra of a vehicle.

    remarks

    Setting extras on vehicle does not work for every vehicle model. For example you can change the light bar of a police car with this method.

    Parameters

    • extraId: number

      The id of the extra.

    • state: boolean

      The state of the extra.

    Returns void

setGamestateDataBase64

  • setGamestateDataBase64(data: string): void
  • Sets the game state data of a vehicle with a given base64 string.

    Parameters

    • data: string

      A base64 string that represents the game state data.

    Returns void

setHealthDataBase64

  • setHealthDataBase64(data: string): void
  • Sets the health data of a vehicle with a given base64 string.

    Parameters

    • data: string

      A base64 string that represents the health data.

    Returns void

setLightDamaged

  • setLightDamaged(lightId: number, isDamaged: boolean): void
  • Sets a specific light of the vehicle either damaged or not.

    Parameters

    • lightId: number

      The id of the light.

    • isDamaged: boolean

      True to damage the specific light, otherwise false.

    Returns void

setMeta

  • setMeta<K>(key: K, value: shared.InterfaceValueByKey<ICustomVehicleMeta, K>): void
  • setMeta<K>(key: K, value: ICustomVehicleMeta[K]): void
  • setMeta<V, K>(key: K, value: shared.InterfaceValueByKey<ICustomVehicleMeta, K, V>): void
  • Type parameters

    • K: string

    Parameters

    Returns void

  • Type parameters

    Parameters

    • key: K
    • value: ICustomVehicleMeta[K]

    Returns void

  • deprecated

    See ICustomVehicleMeta

    Type parameters

    • V: any

    • K: string = string

    Parameters

    Returns void

setMod

  • setMod(modType: VehicleModType, modId: number): void
  • setMod<T>(modType: T, modId: number): void
  • Applies a specific mod of a given mod type.

    Parameters

    • modType: VehicleModType

      The type of the mod.

    • modId: number

      The id of the mod.

    Returns void

  • Type parameters

    • T: number

    Parameters

    • modType: T
    • modId: number

    Returns void

setNetOwner

  • setNetOwner(player: Player, disableMigration?: boolean): void
  • Changes network owner to the specified player.

    remarks

    See {@link Entity~netOwner} to understand how network owner works.

    Keep in mind that disabling migration can lead to unexpected behaviour when the network owner gets out of the streaming range.

    Parameters

    • player: Player

      The given player that will be set as new network owner.

    • Optional disableMigration: boolean

      Pass true to disable migration, false to keep it enabled. If not specified, it defaults to "false".

    Returns void

setPartBulletHoles

  • setPartBulletHoles(partId: VehiclePart, count: number): void
  • setPartBulletHoles<T>(partId: T, count: number): void
  • Applies bullet holes to a specific vehicle part.

    Parameters

    • partId: VehiclePart

      The id of the part.

    • count: number

      The amount of bullet holes.

    Returns void

  • Type parameters

    • T: number

    Parameters

    • partId: T
    • count: number

    Returns void

setPartDamageLevel

  • Sets the damage level of a vehicle part.

    Parameters

    Returns void

  • Type parameters

    • T: number

    • V: number = VehiclePartDamage

    Parameters

    • partId: T
    • level: V

    Returns void

setRearWheels

  • setRearWheels(wheelId: number): void
  • Sets type of the rear wheels.

    Parameters

    • wheelId: number

      The id of the rear wheel type.

    Returns void

setScriptDataBase64

  • setScriptDataBase64(data: string): void
  • Sets the script data of a vehicle based on a base64 string.

    Parameters

    • data: string

      A base64 string that represents the script data.

    Returns void

setSearchLightTo

  • setSearchLightTo(entity: Entity, state: boolean): void
  • Activates the searchlight and follows the target.

    remarks

    Entity parameter isn't working for now and this can only be used for helicopter searchlights.

    Parameters

    • entity: Entity
    • state: boolean

    Returns void

setSpecialLightDamaged

  • setSpecialLightDamaged(specialLightId: number, isDamaged: boolean): void
  • Sets if a special light is damaged.

    Parameters

    • specialLightId: number

      The id of the special light.

    • isDamaged: boolean

      True to damage the specific special light, otherwise false.

    Returns void

setStreamSyncedMeta

  • setStreamSyncedMeta<K>(key: K, value: shared.InterfaceValueByKey<ICustomVehicleStreamSyncedMeta, K>): void
  • setStreamSyncedMeta<K>(key: K, value: ICustomVehicleStreamSyncedMeta[K]): void
  • setStreamSyncedMeta<V, K>(key: K, value: shared.InterfaceValueByKey<ICustomVehicleStreamSyncedMeta, K, V>): void

setSyncedMeta

  • setSyncedMeta<K>(key: K, value: shared.InterfaceValueByKey<ICustomVehicleSyncedMeta, K>): void
  • setSyncedMeta<K>(key: K, value: ICustomVehicleSyncedMeta[K]): void
  • setSyncedMeta<V, K>(key: K, value: shared.InterfaceValueByKey<ICustomVehicleSyncedMeta, K, V>): void

setTimedExplosion

  • setTimedExplosion(state: boolean, culprit: Player, time: number): void
  • Parameters

    • state: boolean
    • culprit: Player
    • time: number

    Returns void

setTrainEngineId

  • setTrainEngineId(vehicle: Vehicle | null): void
  • Set a train as an engine of a train.

    Parameters

    • vehicle: Vehicle | null

      The vehicle to set as an engine.

    Returns void

setTrainLinkedToBackwardId

  • setTrainLinkedToBackwardId(vehicle: Vehicle | null): void
  • Links another train to the back of the train.

    Parameters

    • vehicle: Vehicle | null

      The vehicle to set as linked to the back of the train.

    Returns void

setTrainLinkedToForwardId

  • setTrainLinkedToForwardId(vehicle: Vehicle | null): void
  • Links another train to the front of the train.

    Parameters

    • vehicle: Vehicle | null

      The vehicle to set as linked to the front of the train.

    Returns void

setWeaponCapacity

  • setWeaponCapacity(weaponIndex: number, capacity: number): void
  • Parameters

    • weaponIndex: number
    • capacity: number

    Returns void

setWheelBurst

  • setWheelBurst(wheelId: number, state: boolean): void
  • Sets if a specific wheel is burst.

    Parameters

    • wheelId: number

      The id of the wheel.

    • state: boolean

      True to burst the wheel, otherwise false.

    Returns void

setWheelDetached

  • setWheelDetached(wheelId: number, state: boolean): void
  • Sets a wheel either detached or attached.

    Parameters

    • wheelId: number

      The id of the wheel.

    • state: boolean

      True to detach the wheel, otherwise false.

    Returns void

setWheelFixed

  • setWheelFixed(wheelId: number): void
  • Repairs a specific wheel.

    Parameters

    • wheelId: number

      The id of the wheel.

    Returns void

setWheelHasTire

  • setWheelHasTire(wheelId: number, state: boolean): void
  • Sets if a specific wheel has a tire.

    Parameters

    • wheelId: number

      The id of the wheel.

    • state: boolean

      True to apply a tire to a wheel, otherwise false.

    Returns void

setWheelHealth

  • setWheelHealth(wheelId: number, health: number): void
  • Sets the health of a specific wheel.

    Parameters

    • wheelId: number

      The id of the wheel.

    • health: number

      The health of the wheel.

    Returns void

setWheelOnFire

  • setWheelOnFire(wheelId: number, state: boolean): void
  • Sets a wheel either on fire or not

    Parameters

    • wheelId: number

      The id of the wheel.

    • state: boolean

      True to set the wheel on fire, otherwise false.

    Returns void

setWheels

  • setWheels(wheelType: number, wheelId: number): void
  • Applies a wheel style based on the type and variation.

    Parameters

    • wheelType: number

      The type of the wheel.

    • wheelId: number

      The variation id of the wheel.

    Returns void

setWindowDamaged

  • setWindowDamaged(windowId: number, isDamaged: boolean): void
  • Sets if a specific window is damaged.

    Parameters

    • windowId: number

      The id of the window.

    • isDamaged: boolean

      True to damage the specific window, otherwise false.

    Returns void

setWindowOpened

  • setWindowOpened(windowId: number, state: boolean): void
  • Sets if a specific window is open.

    Parameters

    • windowId: number

      The id of the window.

    • state: boolean

      True to open the window, otherwise false.

    Returns void

Static getByID

  • getByID(id: number): Vehicle | null
  • Retrieves the vehicle from the pool.

    Parameters

    • id: number

      The id of the vehicle.

    Returns Vehicle | null

    Vehicle if it was found, otherwise null.