Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LocalVehicle

Hierarchy

Index

Constructors

constructor

  • Creates static local vehicle without streaming enabled.

    Parameters

    Returns LocalVehicle

  • Creates local vehicle with streaming enabled.

    Parameters

    • model: string | number
    • dimension: number
    • pos: IVector3
    • rot: IVector3
    • useStreaming: true
    • streamingDistance: number

    Returns LocalVehicle

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 isStreamedIn

isStreamedIn: boolean

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

rpm

rpm: number

Vehicle RPM.

returns

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

Readonly scriptID

scriptID: number

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 streamingDistance

streamingDistance: number

suspensionHeight

suspensionHeight: number

Readonly type

Type of the object.

Readonly valid

valid: boolean

Object usability.

returns

False if object is no longer usable.

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
  • set model(model: number | string): any
  • Returns number

  • Parameters

    • model: number | string

    Returns any

Methods

deleteMeta

  • deleteMeta(key: string): void
  • deleteMeta<K>(key: K): 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

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

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

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

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

waitForSpawn

  • waitForSpawn(timeout?: number): Promise<void>
  • Waits asynchronously until the vehicle spawns.

    Parameters

    • Optional timeout: number

    Returns Promise<void>

Static getByID

  • Retrieves the localvehicle from the pool.

    Parameters

    • id: number

      The id of the entity.

    Returns LocalVehicle | null

    Entity if it was found, otherwise null.

Static getByRemoteID

  • getByRemoteID(id: number): Vehicle | null

Static getByScriptID

  • Retrieves the localvehicle from the pool.

    Parameters

    • scriptID: number

      The script id of the entity.

    Returns LocalVehicle | null

    Entity if it was found, otherwise null.