Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Vehicle

Hierarchy

Index

Constructors

Protected constructor

Properties

absLight

absLight: boolean

Changes the abs lamp of the vehicle dashboard.

batteryLight

batteryLight: boolean

Changes the battery lamp of the vehicle dashboard.

dimension

dimension: number

Object dimension.

remarks

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

engineLight

engineLight: boolean

Changes the engine lamp of the vehicle dashboard.

Readonly engineOn

engineOn: boolean

Vehicle engine state.

engineTemperature

engineTemperature: number

The vehicle's engine temperature.

frozen

frozen: boolean

fuelLevel

fuelLevel: number

The vehicle's fuel level.

gear

gear: number

Vehicle gear.

returns

A number indicating actual gear.

handling

Vehicle handling, which affects how vehicle responds and reacts to the inputs of a driver.

Readonly id

id: number

indicatorLights

indicatorLights: VehicleIndicatorLights

Vehicle indicator lights.

Readonly isRemote

isRemote: boolean

Whether this entity was created clientside or serverside. (Clientside = false, Serverside = true).

Readonly isSpawned

isSpawned: boolean

Returns whether the entity is spawned in the game world.

remarks

This does the same thing as checking if the scriptID is 0.

Readonly lockState

lockState: VehicleLockState

Vehicle lock state.

Readonly maxGear

maxGear: number

Vehicle max gear.

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.

oilLevel

oilLevel: number

The vehicle's oil level.

oilLight

oilLight: boolean

Changes the oil lamp of the vehicle dashboard.

petrolLight

petrolLight: boolean

Changes the petrol lamp of the vehicle dashboard.

Readonly petrolTankHealth

petrolTankHealth: number

The vehicle's petrol tank health.

pos

pos: Vector3

Object position.

remarks

Setting this throws an error if the client is not the network owner of an entity

Readonly refCount

refCount: number

Returns the ref count of the entity.

remarks

It's only available in debug-mode.

Readonly remoteID

remoteID: number

The serverside id of this entity.

rot

rot: Vector3

Entity rotation in radians

remarks

Setting this throws an error if the client is not the network owner of an entity

rpm

rpm: number

Vehicle RPM.

returns

Normalised value on a scale of [0, 1].

Readonly scriptID

scriptID: number

Internal game id that can be used in native calls

Readonly seatCount

seatCount: number

Vehicle seat count.

Readonly speed

speed: number

Vehicle wheels speed.

Readonly speedVector

speedVector: Vector3

Vehicle speed vector.

steeringAngle

steeringAngle: number
remarks

Setter needs to be called in everytick and engine must be off.

Readonly type

Type of the object.

Readonly valid

valid: boolean

Object usability.

returns

False if object is no longer usable.

Readonly visible

visible: boolean

Readonly wheelsCount

wheelsCount: number

Vehicle wheels count.

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

Static Readonly streamedIn

streamedIn: readonly Vehicle[]

Array with all streamed in vehicles.

Accessors

model

  • get model(): number
  • Hash of entity model

    Returns number

Methods

deleteMeta

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

    • key: string

    Returns void

  • Type parameters

    Parameters

    • key: K

    Returns void

destroy

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

    Returns void

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[]

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[]

getSyncInfo

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[]

getWheelCamber

  • getWheelCamber(wheelIndex: number): number
  • Gets the camber angle of the specified wheel.

    Parameters

    • wheelIndex: number

      The index of the wheel.

    Returns number

getWheelHeight

  • getWheelHeight(wheelIndex: number): number
  • Gets the height of the specified wheel.

    Parameters

    • wheelIndex: number

      The index of the wheel.

    Returns number

getWheelRimRadius

  • getWheelRimRadius(wheelIndex: number): number
  • Gets the rim radius of the specified wheel.

    Parameters

    • wheelIndex: number

      The index of the wheel.

    Returns number

getWheelSurfaceMaterial

  • getWheelSurfaceMaterial(wheel: number): number
  • Parameters

    • wheel: number

    Returns number

getWheelTrackWidth

  • getWheelTrackWidth(wheelIndex: number): number
  • Gets the track width of the specified wheel.

    Parameters

    • wheelIndex: number

      The index of the wheel.

    Returns number

getWheelTyreRadius

  • getWheelTyreRadius(wheelIndex: number): number
  • Gets the tyre radius of the specified wheel.

    Parameters

    • wheelIndex: number

      The index of the wheel.

    Returns number

getWheelTyreWidth

  • getWheelTyreWidth(wheelIndex: number): number
  • Gets the tyre width the specified wheel.

    Parameters

    • wheelIndex: number

      The index of the wheel.

    Returns number

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

resetDashboardLights

  • resetDashboardLights(): void
  • Resets the dashboard lights to default values.

    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

setWheelCamber

  • setWheelCamber(wheelIndex: number, camber: number): void
  • Sets the camber angle of the specified wheel.

    remarks

    A positive camber angle means that the top of the wheel is farther out than the bottom. A negative camber angle means that the bottom of the wheel is farther out than the top.

    Parameters

    • wheelIndex: number

      The index of the wheel.

    • camber: number

      The value the of camber angle.

    Returns void

setWheelHeight

  • setWheelHeight(wheelIndex: number, height: number): void
  • Sets the height of the specified wheel.

    Parameters

    • wheelIndex: number

      The index of the wheel.

    • height: number

      The value of the wheel height.

    Returns void

setWheelRimRadius

  • setWheelRimRadius(wheelIndex: number, radius: number): void
  • remarks

    Does not show any visible effect.

    Parameters

    • wheelIndex: number

      The index of the wheel.

    • radius: number

      The index of the rim radius.

    Returns void

setWheelTrackWidth

  • setWheelTrackWidth(wheelIndex: number, width: number): void
  • Sets the track width of the specified wheel.

    Parameters

    • wheelIndex: number

      The index of the wheel.

    • width: number

      The value of the track width.

    Returns void

setWheelTyreRadius

  • setWheelTyreRadius(wheelIndex: number, radius: number): void
  • remarks

    Applies only physical effects to the wheel.

    Parameters

    • wheelIndex: number

      The index of the wheel.

    • radius: number

      The value of the tyre radius.

    Returns void

setWheelTyreWidth

  • setWheelTyreWidth(wheelIndex: number, width: number): void
  • remarks

    Does not show any visible effect.

    Parameters

    • wheelIndex: number

      The index of the wheel.

    • width: number

      The value of the tyre width.

    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

    Entity if it was found, otherwise null.

Static getByRemoteID

  • getByRemoteID(id: number): Vehicle | null
  • Gets the vehicle with the given remote id

    Parameters

    • id: number

    Returns Vehicle | null

Static getByScriptID

  • getByScriptID(scriptID: number): Vehicle | null
  • Retrieves the vehicle from the pool.

    Parameters

    • scriptID: number

      The script id of the vehicle.

    Returns Vehicle | null

    Entity if it was found, otherwise null.