Skip to main content

LocalVehicle

Hierarchy

  • Vehicle
    • LocalVehicle

Index

Constructors

publicconstructor

  • new LocalVehicle(model: string | number, dimension: number, pos: IVector3, rot: IVector3): LocalVehicle
  • new LocalVehicle(model: string | number, dimension: number, pos: IVector3, rot: IVector3, useStreaming: true, streamingDistance: number): LocalVehicle
  • Creates static local vehicle without streaming enabled.

Properties

publicabsLight

absLight: boolean

Changes the abs lamp of the vehicle dashboard.

publicbatteryLight

batteryLight: boolean

Changes the battery lamp of the vehicle dashboard.

publicdimension

dimension: number

Object dimension.

Remarks

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

publicengineLight

engineLight: boolean

Changes the engine lamp of the vehicle dashboard.

publicreadonlyengineOn

engineOn: boolean

Vehicle engine state.

publicengineTemperature

engineTemperature: number

The vehicle’s engine temperature.

publicfrozen

frozen: boolean

publicfuelLevel

fuelLevel: number

The vehicle’s fuel level.

publicgear

gear: number

Vehicle gear.

Returns

A number indicating actual gear.

publichandling

handling: IVehicleHandling

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

publicreadonlyid

id: number

publicindicatorLights

indicatorLights: VehicleIndicatorLights

Vehicle indicator lights.

publicreadonlyisRemote

isRemote: boolean

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

publicreadonlyisSpawned

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.

publicreadonlyisStreamedIn

isStreamedIn: boolean

publicreadonlylockState

lockState: VehicleLockState

Vehicle lock state.

publicreadonlymaxGear

maxGear: number

Vehicle max gear.

publicreadonlynetOwner

netOwner: null | Player

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.

publicoilLevel

oilLevel: number

The vehicle’s oil level.

publicoilLight

oilLight: boolean

Changes the oil lamp of the vehicle dashboard.

publicpetrolLight

petrolLight: boolean

Changes the petrol lamp of the vehicle dashboard.

publicreadonlypetrolTankHealth

petrolTankHealth: number

The vehicle’s petrol tank health.

publicpos

pos: Vector3

Object position.

Remarks

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

publicreadonlyrefCount

refCount: number

Returns the ref count of the entity.

Remarks

It’s only available in debug-mode.

publicreadonlyremoteID

remoteID: number

The serverside id of this entity.

publicrot

rot: Vector3

publicrpm

rpm: number

Vehicle RPM.

Returns

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

publicreadonlyscriptID

scriptID: number

publicreadonlyseatCount

seatCount: number

Vehicle seat count.

publicreadonlyspeed

speed: number

Vehicle wheels speed.

publicreadonlyspeedVector

speedVector: Vector3

Vehicle speed vector.

publicsteeringAngle

steeringAngle: number

Remarks

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

publicreadonlystreamingDistance

streamingDistance: number

publicsuspensionHeight

suspensionHeight: number

publicreadonlytype

type: BaseObjectType

Type of the object.

publicreadonlyvalid

valid: boolean

Object usability.

Returns

False if object is no longer usable.

publicvisible

visible: boolean

publicreadonlywheelsCount

wheelsCount: number

Vehicle wheels count.

publicstaticreadonlyall

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
}

publicstaticreadonlycount

count: number

publicstaticreadonlystreamedIn

streamedIn: readonly Vehicle[]

Array with all streamed in vehicles.

Accessors

publicmodel

  • get model(): number
  • set model(model: string | number): void

    Getter

    Setter

Methods

publicdeleteMeta

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

publicdestroy

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

publicgetMeta

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

    • K: string

publicgetMetaDataKeys

  • getMetaDataKeys(): readonly string[]

publicgetStreamSyncedMeta

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

    • K: string

publicgetStreamSyncedMetaKeys

  • getStreamSyncedMetaKeys(): readonly string[]

publicgetSyncInfo

  • getSyncInfo(): ISyncInfo

publicgetSyncedMeta

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

    • K: string

publicgetSyncedMetaKeys

  • getSyncedMetaKeys(): readonly string[]

publicgetWheelCamber

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

publicgetWheelHeight

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

publicgetWheelRimRadius

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

publicgetWheelSurfaceMaterial

  • getWheelSurfaceMaterial(wheel: number): number

publicgetWheelTrackWidth

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

publicgetWheelTyreRadius

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

publicgetWheelTyreWidth

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

publichasMeta

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

publichasStreamSyncedMeta

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

publichasSyncedMeta

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

publicresetDashboardLights

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

publicsetMeta

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

    • K: string

publicsetWheelCamber

  • 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.

publicsetWheelHeight

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

publicsetWheelRimRadius

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

    Does not show any visible effect.

publicsetWheelTrackWidth

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

publicsetWheelTyreRadius

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

    Applies only physical effects to the wheel.

publicsetWheelTyreWidth

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

    Does not show any visible effect.

publicwaitForSpawn

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

publicstaticgetByID

  • getByID(id: number): null | LocalVehicle
  • Retrieves the localvehicle from the pool.

publicstaticgetByRemoteID

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

publicstaticgetByScriptID

  • getByScriptID(scriptID: number): null | LocalVehicle
  • Retrieves the localvehicle from the pool.