Vehicle
Defined in: server/api.d.ts:247
Replicated M2O vehicle handle.
Extends
Section titled “Extends”Entity
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Vehicle(
id):Vehicle
Defined in: server/api.d.ts:252
Creates a script wrapper for an existing vehicle with this ID; use Vehicle.spawn() to spawn a vehicle.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”Vehicle
Methods
Section titled “Methods”clearRadio()
Section titled “clearRadio()”clearRadio():
void
Defined in: server/api.d.ts:715
Turns off this vehicle’s in-car radio.
Returns
Section titled “Returns”void
clearWantedLevel()
Section titled “clearWantedLevel()”clearWantedLevel():
void
Defined in: server/api.d.ts:648
Clears the vehicle wanted icon for its current driver.
Returns
Section titled “Returns”void
destroy()
Section titled “destroy()”destroy():
void
Defined in: server/api.d.ts:393
Destroys this replicated vehicle after emitting vehicleDestroyed.
Returns
Section titled “Returns”void
explode()
Section titled “explode()”explode():
void
Defined in: server/api.d.ts:637
Blows the vehicle up on every client with the native explosion, killing its occupants, and marks it destroyed until repair(). Emits vehicleExplode with a null attacker.
Returns
Section titled “Returns”void
getBeacon()
Section titled “getBeacon()”getBeacon():
boolean
Defined in: server/api.d.ts:490
Checks the replicated emergency-beacon state.
Returns
Section titled “Returns”boolean
True when the beacon is active.
getColor()
Section titled “getColor()”getColor():
number
Defined in: server/api.d.ts:537
Returns the stored primary paint color.
Returns
Section titled “Returns”number
Packed 0x00RRGGBB, or -1 when the model default is used.
getColorSecondary()
Section titled “getColorSecondary()”getColorSecondary():
number
Defined in: server/api.d.ts:551
Returns the stored secondary paint color.
Returns
Section titled “Returns”number
Packed 0x00RRGGBB, or -1 when the model default is used.
getControl()
Section titled “getControl()”getControl(
control):boolean
Defined in: server/api.d.ts:407
Reads an accessory from the current replicated control flags.
Parameters
Section titled “Parameters”control
Section titled “control”number
Vehicle accessory control identifier.
Returns
Section titled “Returns”boolean
True when the selected accessory is active.
getDirt()
Section titled “getDirt()”getDirt():
number
Defined in: server/api.d.ts:563
Returns the stored dirt level.
Returns
Section titled “Returns”number
A value from 0 through 100.
getEngine()
Section titled “getEngine()”getEngine():
boolean
Defined in: server/api.d.ts:424
Checks the replicated engine state.
Returns
Section titled “Returns”boolean
True when the engine is running.
getEngineHealth()
Section titled “getEngineHealth()”getEngineHealth():
number
Defined in: server/api.d.ts:704
Returns the most recently driver-reported engine health.
Returns
Section titled “Returns”number
Health from 0 through 100, or -1 before the first report.
getFuel()
Section titled “getFuel()”getFuel():
number
Defined in: server/api.d.ts:686
Returns the most recently driver-reported fuel amount.
Returns
Section titled “Returns”number
Current fuel, or -1 before the first report.
getFuelCapacity()
Section titled “getFuelCapacity()”getFuelCapacity():
number
Defined in: server/api.d.ts:692
Returns the driver-reported fuel tank max capacity.
Returns
Section titled “Returns”number
Tank capacity, or -1 before the first report.
getHazard()
Section titled “getHazard()”getHazard():
boolean
Defined in: server/api.d.ts:468
Checks the replicated hazard-light state.
Returns
Section titled “Returns”boolean
True when both turn indicators are active.
getHood()
Section titled “getHood()”getHood():
boolean
Defined in: server/api.d.ts:512
Checks the replicated hood state.
Returns
Section titled “Returns”boolean
True when the hood is open.
getHorn()
Section titled “getHorn()”getHorn():
boolean
Defined in: server/api.d.ts:501
Checks the replicated horn state.
Returns
Section titled “Returns”boolean
True while the horn is active.
getLeftIndicator()
Section titled “getLeftIndicator()”getLeftIndicator():
boolean
Defined in: server/api.d.ts:446
Checks the replicated left-indicator state.
Returns
Section titled “Returns”boolean
True when the left indicator is active.
getLights()
Section titled “getLights()”getLights():
boolean
Defined in: server/api.d.ts:435
Checks the replicated headlight state.
Returns
Section titled “Returns”boolean
True when either low or high beams are active.
getPart()
Section titled “getPart()”getPart(
index):boolean
Defined in: server/api.d.ts:668
Checks the stored visibility state of one vehicle part.
Parameters
Section titled “Parameters”number
Model-specific deform-part index from 0 through 63.
Returns
Section titled “Returns”boolean
True when the part is visible.
getRightIndicator()
Section titled “getRightIndicator()”getRightIndicator():
boolean
Defined in: server/api.d.ts:457
Checks the replicated right-indicator state.
Returns
Section titled “Returns”boolean
True when the right indicator is active.
getSiren()
Section titled “getSiren()”getSiren():
boolean
Defined in: server/api.d.ts:479
Checks the replicated siren state.
Returns
Section titled “Returns”boolean
True when the siren is active.
getTrunk()
Section titled “getTrunk()”getTrunk():
boolean
Defined in: server/api.d.ts:523
Checks the replicated trunk state.
Returns
Section titled “Returns”boolean
True when the trunk is open.
getWheelModel()
Section titled “getWheelModel()”getWheelModel(
index):string
Defined in: server/api.d.ts:601
Returns the stored model name for one wheel group.
Parameters
Section titled “Parameters”number
Wheel group: 0 front, 1 rear, or 2 spare.
Returns
Section titled “Returns”string
The wheel model name, or an empty string when the default is used.
getWheelState()
Section titled “getWheelState()”getWheelState(
index):number
Defined in: server/api.d.ts:615
Returns the stored damage state of one wheel.
Parameters
Section titled “Parameters”number
Vehicle wheel index.
Returns
Section titled “Returns”number
A numeric VehicleWheelState value.
getWipers()
Section titled “getWipers()”getWipers():
boolean
Defined in: server/api.d.ts:581
Checks the stored windshield-wiper state.
Returns
Section titled “Returns”boolean
True when the wipers are active.
repair()
Section titled “repair()”repair():
void
Defined in: server/api.d.ts:632
Fully repairs native deformation, mechanical and part damage, wheels, paint, and tuning, then stops the vehicle without moving it. Also restores a destroyed (exploded) vehicle.
Returns
Section titled “Returns”void
setColor()
Section titled “setColor()”setColor(
r,g,b):void
Defined in: server/api.d.ts:531
Sets the server-authoritative primary paint color and broadcasts it to all clients.
Parameters
Section titled “Parameters”number
Primary red component from 0 through 255.
number
Primary green component from 0 through 255.
number
Primary blue component from 0 through 255.
Returns
Section titled “Returns”void
setColorSecondary()
Section titled “setColorSecondary()”setColorSecondary(
r,g,b):void
Defined in: server/api.d.ts:545
Sets the server-authoritative secondary paint color and broadcasts it to all clients.
Parameters
Section titled “Parameters”number
Secondary red component from 0 through 255.
number
Secondary green component from 0 through 255.
number
Secondary blue component from 0 through 255.
Returns
Section titled “Returns”void
setControl()
Section titled “setControl()”setControl(
control,action):void
Defined in: server/api.d.ts:400
Changes an accessory control. A driver applies the command natively; otherwise the server updates replicated state directly.
Parameters
Section titled “Parameters”control
Section titled “control”number
Vehicle accessory control identifier.
action
Section titled “action”0 | 1 | 2
Action: 0 turns the control off, 1 turns it on, and 2 toggles it.
Returns
Section titled “Returns”void
setDirt()
Section titled “setDirt()”setDirt(
level):void
Defined in: server/api.d.ts:557
Sets and replicates the vehicle’s dirt level.
Parameters
Section titled “Parameters”number
Dirt amount from 0 for clean to 100 for fully dirty.
Returns
Section titled “Returns”void
setEngine()
Section titled “setEngine()”setEngine(
enabled):void
Defined in: server/api.d.ts:418
Sets the vehicle engine state.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
True to start the engine; false to stop it.
Returns
Section titled “Returns”void
setEngineHealth()
Section titled “setEngineHealth()”setEngineHealth(
health):void
Defined in: server/api.d.ts:698
Broadcasts a one-shot native engine-health update to every live copy of this vehicle.
Parameters
Section titled “Parameters”health
Section titled “health”number
Engine health from 0 for destroyed to 100 for perfect.
Returns
Section titled “Returns”void
setFuel()
Section titled “setFuel()”setFuel(
fuel):void
Defined in: server/api.d.ts:680
Broadcasts a one-shot fuel update to every live copy of this vehicle.
Parameters
Section titled “Parameters”number
Target native fuel amount; each client clamps it to the vehicle tank.
Returns
Section titled “Returns”void
setLocked()
Section titled “setLocked()”setLocked(
locked):void
Defined in: server/api.d.ts:674
Convenience method that sets the entry lock to fully locked or unlocked.
Parameters
Section titled “Parameters”locked
Section titled “locked”boolean
True for fully locked; false for unlocked.
Returns
Section titled “Returns”void
setLockState()
Section titled “setLockState()”setLockState(
state):void
Defined in: server/api.d.ts:654
Sets the server-authoritative vehicle entry lock state.
Parameters
Section titled “Parameters”number
Entry lock state: 0 unlocked, 1 breakable, or 2 fully locked.
Returns
Section titled “Returns”void
setPart()
Section titled “setPart()”setPart(
index,enabled):void
Defined in: server/api.d.ts:661
Shows or hides one model-specific vehicle part on all clients.
Parameters
Section titled “Parameters”number
Model-specific deform-part index from 0 through 63.
enabled
Section titled “enabled”boolean
Whether the selected part is visible.
Returns
Section titled “Returns”void
setPlate()
Section titled “setPlate()”setPlate(
text):void
Defined in: server/api.d.ts:587
Sets and replicates the vehicle’s license-plate text.
Parameters
Section titled “Parameters”string
License-plate text, limited to six characters by the game.
Returns
Section titled “Returns”void
setRadioLocked()
Section titled “setRadioLocked()”setRadioLocked(
locked):void
Defined in: server/api.d.ts:721
Locks or unlocks driver-controlled radio station changes.
Parameters
Section titled “Parameters”locked
Section titled “locked”boolean
Whether the driver is prevented from changing station.
Returns
Section titled “Returns”void
setRadioStation()
Section titled “setRadioStation()”setRadioStation(
station):void
Defined in: server/api.d.ts:710
Sets the in-car radio station for this vehicle’s driver.
Parameters
Section titled “Parameters”station
Section titled “station”number
Native radio station identifier; a negative value turns the radio off.
Returns
Section titled “Returns”void
setSpeedLimiter()
Section titled “setSpeedLimiter()”setSpeedLimiter(
enabled):void
Defined in: server/api.d.ts:621
Enables or disables the vehicle speed limiter on all clients.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Whether the native server-controlled speed limiter is active.
Returns
Section titled “Returns”void
setSpeedLimiterSpeed()
Section titled “setSpeedLimiterSpeed()”setSpeedLimiterSpeed(
kmh):void
Defined in: server/api.d.ts:627
Sets and replicates the vehicle speed-limiter threshold.
Parameters
Section titled “Parameters”number
Maximum speed in kilometres per hour; a negative value restores the model default.
Returns
Section titled “Returns”void
setTuning()
Section titled “setTuning()”setTuning(
level):void
Defined in: server/api.d.ts:569
Sets and replicates the vehicle’s visual tuning level.
Parameters
Section titled “Parameters”number
Tuning level from 0 for stock through 3.
Returns
Section titled “Returns”void
setVirtualWorld()
Section titled “setVirtualWorld()”setVirtualWorld(
world):void
Defined in: shared.d.ts:83
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
setVisibleTo()
Section titled “setVisibleTo()”setVisibleTo(
player):void
Defined in: shared.d.ts:84
Parameters
Section titled “Parameters”player
Section titled “player”Entity | null
Returns
Section titled “Returns”void
setWantedLevel()
Section titled “setWantedLevel()”setWantedLevel(
level):void
Defined in: server/api.d.ts:643
Sets the vehicle wanted icon shown to its current driver.
Parameters
Section titled “Parameters”number
Non-zero native vehicle wanted-icon level; zero hides the icon.
Returns
Section titled “Returns”void
setWheelModel()
Section titled “setWheelModel()”setWheelModel(
index,name):void
Defined in: server/api.d.ts:594
Sets and replicates the model used by one wheel group.
Parameters
Section titled “Parameters”number
Wheel group: 0 front, 1 rear, or 2 spare.
string
Wheel model name; an empty string restores the vehicle model default.
Returns
Section titled “Returns”void
setWheelState()
Section titled “setWheelState()”setWheelState(
index,state):void
Defined in: server/api.d.ts:608
Sets and replicates the damage state of one wheel.
Parameters
Section titled “Parameters”number
Vehicle wheel index.
number
Damage state from VehicleWheelState: Normal, Deflated, or BlownOut.
Returns
Section titled “Returns”void
setWipers()
Section titled “setWipers()”setWipers(
enabled):void
Defined in: server/api.d.ts:575
Sets and replicates the vehicle’s windshield wipers.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Whether the windshield wipers are active.
Returns
Section titled “Returns”void
toggleBeacon()
Section titled “toggleBeacon()”toggleBeacon():
void
Defined in: server/api.d.ts:484
Toggles the vehicle emergency beacon.
Returns
Section titled “Returns”void
toggleEngine()
Section titled “toggleEngine()”toggleEngine():
void
Defined in: server/api.d.ts:412
Toggles the vehicle engine state.
Returns
Section titled “Returns”void
toggleHazard()
Section titled “toggleHazard()”toggleHazard():
void
Defined in: server/api.d.ts:462
Toggles both turn indicators as hazard lights.
Returns
Section titled “Returns”void
toggleHood()
Section titled “toggleHood()”toggleHood():
void
Defined in: server/api.d.ts:506
Toggles the vehicle hood between open and closed.
Returns
Section titled “Returns”void
toggleHorn()
Section titled “toggleHorn()”toggleHorn():
void
Defined in: server/api.d.ts:495
Toggles the vehicle horn.
Returns
Section titled “Returns”void
toggleLeftIndicator()
Section titled “toggleLeftIndicator()”toggleLeftIndicator():
void
Defined in: server/api.d.ts:440
Toggles the left turn indicator.
Returns
Section titled “Returns”void
toggleLights()
Section titled “toggleLights()”toggleLights():
void
Defined in: server/api.d.ts:429
Toggles the vehicle headlights.
Returns
Section titled “Returns”void
toggleRightIndicator()
Section titled “toggleRightIndicator()”toggleRightIndicator():
void
Defined in: server/api.d.ts:451
Toggles the right turn indicator.
Returns
Section titled “Returns”void
toggleSiren()
Section titled “toggleSiren()”toggleSiren():
void
Defined in: server/api.d.ts:473
Toggles the vehicle siren.
Returns
Section titled “Returns”void
toggleTrunk()
Section titled “toggleTrunk()”toggleTrunk():
void
Defined in: server/api.d.ts:517
Toggles the vehicle trunk between open and closed.
Returns
Section titled “Returns”void
toString()
Section titled “toString()”toString():
string
Defined in: server/api.d.ts:388
Returns a readable representation of this vehicle.
Returns
Section titled “Returns”string
The vehicle ID and model formatted for logging or debugging.
spawn()
Section titled “spawn()”
staticspawn(modelId,position?,rotation?):Vehicle
Defined in: server/api.d.ts:730
Spawns and replicates a new vehicle.
Parameters
Section titled “Parameters”modelId
Section titled “modelId”number
Mafia II vehicle model identifier.
position?
Section titled “position?”Partial<Vector3>
Optional initial world-space position; omitted components default to zero.
rotation?
Section titled “rotation?”Optional initial orientation: a Quaternion, or a Vector3 of Euler angles in radians.
Returns
Section titled “Returns”Vehicle
The newly spawned vehicle handle.
Properties
Section titled “Properties”beacon
Section titled “beacon”
readonlybeacon:boolean
Defined in: server/api.d.ts:367
Whether the replicated emergency beacon is on.
readonlycolor:number
Defined in: server/api.d.ts:267
Packed primary paint color 0x00RRGGBB, or -1 for the model default.
colorSecondary
Section titled “colorSecondary”
readonlycolorSecondary:number
Defined in: server/api.d.ts:272
Packed secondary paint color 0x00RRGGBB, or -1 for the model default.
destroyed
Section titled “destroyed”
readonlydestroyed:boolean
Defined in: server/api.d.ts:332
Whether the vehicle has been blown up and not repaired since.
readonlydirt:number
Defined in: server/api.d.ts:277
Stored dirt level from 0 through 100.
engine
Section titled “engine”
readonlyengine:boolean
Defined in: server/api.d.ts:337
Whether the replicated engine state is on.
engineHealth
Section titled “engineHealth”
readonlyengineHealth:number
Defined in: server/api.d.ts:327
Most recently driver-reported engine health from 0 through 100, or -1 before the first report.
readonlyfuel:number
Defined in: server/api.d.ts:317
Most recently driver-reported fuel amount, or -1 before the first report.
fuelCapacity
Section titled “fuelCapacity”
readonlyfuelCapacity:number
Defined in: server/api.d.ts:322
Driver-reported fuel tank max capacity, or -1 before the first report.
hazard
Section titled “hazard”
readonlyhazard:boolean
Defined in: server/api.d.ts:357
Whether both replicated turn indicators are on as hazard lights.
readonlyhood:boolean
Defined in: server/api.d.ts:377
Whether the replicated hood is open.
readonlyhorn:boolean
Defined in: server/api.d.ts:372
Whether the replicated horn is active.
readonlyid:number
Defined in: shared.d.ts:79
leftIndicator
Section titled “leftIndicator”
readonlyleftIndicator:boolean
Defined in: server/api.d.ts:347
Whether the replicated left turn indicator is on.
lights
Section titled “lights”
readonlylights:boolean
Defined in: server/api.d.ts:342
Whether either replicated headlight beam is on.
lockState
Section titled “lockState”
readonlylockState:number
Defined in: server/api.d.ts:262
Entry lock state: 0 unlocked, 1 breakable, or 2 fully locked.
readonlymodel:number
Defined in: server/api.d.ts:257
Mafia II vehicle model identifier used when this vehicle was spawned.
position
Section titled “position”position:
Vector3
Defined in: shared.d.ts:81
radioStation
Section titled “radioStation”
readonlyradioStation:number
Defined in: server/api.d.ts:312
Stored native radio station ID; 255 represents unset or off.
rightIndicator
Section titled “rightIndicator”
readonlyrightIndicator:boolean
Defined in: server/api.d.ts:352
Whether the replicated right turn indicator is on.
rotation
Section titled “rotation”rotation:
Vector3|Quaternion
Defined in: shared.d.ts:82
readonlysiren:boolean
Defined in: server/api.d.ts:362
Whether the replicated siren is on.
speedLimiter
Section titled “speedLimiter”
readonlyspeedLimiter:boolean
Defined in: server/api.d.ts:302
Whether the server-controlled native speed limiter is enabled.
speedLimiterSpeed
Section titled “speedLimiterSpeed”
readonlyspeedLimiterSpeed:number
Defined in: server/api.d.ts:307
Speed-limiter threshold in kilometres per hour, or a negative model-default value.
readonlytrunk:boolean
Defined in: server/api.d.ts:382
Whether the replicated trunk is open.
tuning
Section titled “tuning”
readonlytuning:number
Defined in: server/api.d.ts:282
Stored tuning level from 0 for stock through 3.
virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: shared.d.ts:80
wheelModels
Section titled “wheelModels”
readonlywheelModels:string[]
Defined in: server/api.d.ts:292
Stored model names for the front, rear, and spare wheel groups.
wheelStates
Section titled “wheelStates”
readonlywheelStates:number[]
Defined in: server/api.d.ts:297
Stored VehicleWheelState value for every wheel.
wipers
Section titled “wipers”
readonlywipers:boolean
Defined in: server/api.d.ts:287
Whether the windshield wipers are active.
