Skip to content
M2O Scripting APIScripting reference
Runtime classServer APIGenerated

Vehicle

Defined in: server/api.d.ts:247

Replicated M2O vehicle handle.

  • Entity

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.

number

Network entity identifier.

Vehicle

clearRadio(): void

Defined in: server/api.d.ts:715

Turns off this vehicle’s in-car radio.

void


clearWantedLevel(): void

Defined in: server/api.d.ts:648

Clears the vehicle wanted icon for its current driver.

void


destroy(): void

Defined in: server/api.d.ts:393

Destroys this replicated vehicle after emitting vehicleDestroyed.

void


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.

void


getBeacon(): boolean

Defined in: server/api.d.ts:490

Checks the replicated emergency-beacon state.

boolean

True when the beacon is active.


getColor(): number

Defined in: server/api.d.ts:537

Returns the stored primary paint color.

number

Packed 0x00RRGGBB, or -1 when the model default is used.


getColorSecondary(): number

Defined in: server/api.d.ts:551

Returns the stored secondary paint color.

number

Packed 0x00RRGGBB, or -1 when the model default is used.


getControl(control): boolean

Defined in: server/api.d.ts:407

Reads an accessory from the current replicated control flags.

number

Vehicle accessory control identifier.

boolean

True when the selected accessory is active.


getDirt(): number

Defined in: server/api.d.ts:563

Returns the stored dirt level.

number

A value from 0 through 100.


getEngine(): boolean

Defined in: server/api.d.ts:424

Checks the replicated engine state.

boolean

True when the engine is running.


getEngineHealth(): number

Defined in: server/api.d.ts:704

Returns the most recently driver-reported engine health.

number

Health from 0 through 100, or -1 before the first report.


getFuel(): number

Defined in: server/api.d.ts:686

Returns the most recently driver-reported fuel amount.

number

Current fuel, or -1 before the first report.


getFuelCapacity(): number

Defined in: server/api.d.ts:692

Returns the driver-reported fuel tank max capacity.

number

Tank capacity, or -1 before the first report.


getHazard(): boolean

Defined in: server/api.d.ts:468

Checks the replicated hazard-light state.

boolean

True when both turn indicators are active.


getHood(): boolean

Defined in: server/api.d.ts:512

Checks the replicated hood state.

boolean

True when the hood is open.


getHorn(): boolean

Defined in: server/api.d.ts:501

Checks the replicated horn state.

boolean

True while the horn is active.


getLeftIndicator(): boolean

Defined in: server/api.d.ts:446

Checks the replicated left-indicator state.

boolean

True when the left indicator is active.


getLights(): boolean

Defined in: server/api.d.ts:435

Checks the replicated headlight state.

boolean

True when either low or high beams are active.


getPart(index): boolean

Defined in: server/api.d.ts:668

Checks the stored visibility state of one vehicle part.

number

Model-specific deform-part index from 0 through 63.

boolean

True when the part is visible.


getRightIndicator(): boolean

Defined in: server/api.d.ts:457

Checks the replicated right-indicator state.

boolean

True when the right indicator is active.


getSiren(): boolean

Defined in: server/api.d.ts:479

Checks the replicated siren state.

boolean

True when the siren is active.


getTrunk(): boolean

Defined in: server/api.d.ts:523

Checks the replicated trunk state.

boolean

True when the trunk is open.


getWheelModel(index): string

Defined in: server/api.d.ts:601

Returns the stored model name for one wheel group.

number

Wheel group: 0 front, 1 rear, or 2 spare.

string

The wheel model name, or an empty string when the default is used.


getWheelState(index): number

Defined in: server/api.d.ts:615

Returns the stored damage state of one wheel.

number

Vehicle wheel index.

number

A numeric VehicleWheelState value.


getWipers(): boolean

Defined in: server/api.d.ts:581

Checks the stored windshield-wiper state.

boolean

True when the wipers are active.


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.

void


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.

number

Primary red component from 0 through 255.

number

Primary green component from 0 through 255.

number

Primary blue component from 0 through 255.

void


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.

number

Secondary red component from 0 through 255.

number

Secondary green component from 0 through 255.

number

Secondary blue component from 0 through 255.

void


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.

number

Vehicle accessory control identifier.

0 | 1 | 2

Action: 0 turns the control off, 1 turns it on, and 2 toggles it.

void


setDirt(level): void

Defined in: server/api.d.ts:557

Sets and replicates the vehicle’s dirt level.

number

Dirt amount from 0 for clean to 100 for fully dirty.

void


setEngine(enabled): void

Defined in: server/api.d.ts:418

Sets the vehicle engine state.

boolean

True to start the engine; false to stop it.

void


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.

number

Engine health from 0 for destroyed to 100 for perfect.

void


setFuel(fuel): void

Defined in: server/api.d.ts:680

Broadcasts a one-shot fuel update to every live copy of this vehicle.

number

Target native fuel amount; each client clamps it to the vehicle tank.

void


setLocked(locked): void

Defined in: server/api.d.ts:674

Convenience method that sets the entry lock to fully locked or unlocked.

boolean

True for fully locked; false for unlocked.

void


setLockState(state): void

Defined in: server/api.d.ts:654

Sets the server-authoritative vehicle entry lock state.

number

Entry lock state: 0 unlocked, 1 breakable, or 2 fully locked.

void


setPart(index, enabled): void

Defined in: server/api.d.ts:661

Shows or hides one model-specific vehicle part on all clients.

number

Model-specific deform-part index from 0 through 63.

boolean

Whether the selected part is visible.

void


setPlate(text): void

Defined in: server/api.d.ts:587

Sets and replicates the vehicle’s license-plate text.

string

License-plate text, limited to six characters by the game.

void


setRadioLocked(locked): void

Defined in: server/api.d.ts:721

Locks or unlocks driver-controlled radio station changes.

boolean

Whether the driver is prevented from changing station.

void


setRadioStation(station): void

Defined in: server/api.d.ts:710

Sets the in-car radio station for this vehicle’s driver.

number

Native radio station identifier; a negative value turns the radio off.

void


setSpeedLimiter(enabled): void

Defined in: server/api.d.ts:621

Enables or disables the vehicle speed limiter on all clients.

boolean

Whether the native server-controlled speed limiter is active.

void


setSpeedLimiterSpeed(kmh): void

Defined in: server/api.d.ts:627

Sets and replicates the vehicle speed-limiter threshold.

number

Maximum speed in kilometres per hour; a negative value restores the model default.

void


setTuning(level): void

Defined in: server/api.d.ts:569

Sets and replicates the vehicle’s visual tuning level.

number

Tuning level from 0 for stock through 3.

void


setVirtualWorld(world): void

Defined in: shared.d.ts:83

number

void


setVisibleTo(player): void

Defined in: shared.d.ts:84

Entity | null

void


setWantedLevel(level): void

Defined in: server/api.d.ts:643

Sets the vehicle wanted icon shown to its current driver.

number

Non-zero native vehicle wanted-icon level; zero hides the icon.

void


setWheelModel(index, name): void

Defined in: server/api.d.ts:594

Sets and replicates the model used by one wheel group.

number

Wheel group: 0 front, 1 rear, or 2 spare.

string

Wheel model name; an empty string restores the vehicle model default.

void


setWheelState(index, state): void

Defined in: server/api.d.ts:608

Sets and replicates the damage state of one wheel.

number

Vehicle wheel index.

number

Damage state from VehicleWheelState: Normal, Deflated, or BlownOut.

void


setWipers(enabled): void

Defined in: server/api.d.ts:575

Sets and replicates the vehicle’s windshield wipers.

boolean

Whether the windshield wipers are active.

void


toggleBeacon(): void

Defined in: server/api.d.ts:484

Toggles the vehicle emergency beacon.

void


toggleEngine(): void

Defined in: server/api.d.ts:412

Toggles the vehicle engine state.

void


toggleHazard(): void

Defined in: server/api.d.ts:462

Toggles both turn indicators as hazard lights.

void


toggleHood(): void

Defined in: server/api.d.ts:506

Toggles the vehicle hood between open and closed.

void


toggleHorn(): void

Defined in: server/api.d.ts:495

Toggles the vehicle horn.

void


toggleLeftIndicator(): void

Defined in: server/api.d.ts:440

Toggles the left turn indicator.

void


toggleLights(): void

Defined in: server/api.d.ts:429

Toggles the vehicle headlights.

void


toggleRightIndicator(): void

Defined in: server/api.d.ts:451

Toggles the right turn indicator.

void


toggleSiren(): void

Defined in: server/api.d.ts:473

Toggles the vehicle siren.

void


toggleTrunk(): void

Defined in: server/api.d.ts:517

Toggles the vehicle trunk between open and closed.

void


toString(): string

Defined in: server/api.d.ts:388

Returns a readable representation of this vehicle.

string

The vehicle ID and model formatted for logging or debugging.


static spawn(modelId, position?, rotation?): Vehicle

Defined in: server/api.d.ts:730

Spawns and replicates a new vehicle.

number

Mafia II vehicle model identifier.

Partial<Vector3>

Optional initial world-space position; omitted components default to zero.

Vector3 | Quaternion

Optional initial orientation: a Quaternion, or a Vector3 of Euler angles in radians.

Vehicle

The newly spawned vehicle handle.

readonly beacon: boolean

Defined in: server/api.d.ts:367

Whether the replicated emergency beacon is on.


readonly color: number

Defined in: server/api.d.ts:267

Packed primary paint color 0x00RRGGBB, or -1 for the model default.


readonly colorSecondary: number

Defined in: server/api.d.ts:272

Packed secondary paint color 0x00RRGGBB, or -1 for the model default.


readonly destroyed: boolean

Defined in: server/api.d.ts:332

Whether the vehicle has been blown up and not repaired since.


readonly dirt: number

Defined in: server/api.d.ts:277

Stored dirt level from 0 through 100.


readonly engine: boolean

Defined in: server/api.d.ts:337

Whether the replicated engine state is on.


readonly engineHealth: number

Defined in: server/api.d.ts:327

Most recently driver-reported engine health from 0 through 100, or -1 before the first report.


readonly fuel: number

Defined in: server/api.d.ts:317

Most recently driver-reported fuel amount, or -1 before the first report.


readonly fuelCapacity: number

Defined in: server/api.d.ts:322

Driver-reported fuel tank max capacity, or -1 before the first report.


readonly hazard: boolean

Defined in: server/api.d.ts:357

Whether both replicated turn indicators are on as hazard lights.


readonly hood: boolean

Defined in: server/api.d.ts:377

Whether the replicated hood is open.


readonly horn: boolean

Defined in: server/api.d.ts:372

Whether the replicated horn is active.


readonly id: number

Defined in: shared.d.ts:79


readonly leftIndicator: boolean

Defined in: server/api.d.ts:347

Whether the replicated left turn indicator is on.


readonly lights: boolean

Defined in: server/api.d.ts:342

Whether either replicated headlight beam is on.


readonly lockState: number

Defined in: server/api.d.ts:262

Entry lock state: 0 unlocked, 1 breakable, or 2 fully locked.


readonly model: number

Defined in: server/api.d.ts:257

Mafia II vehicle model identifier used when this vehicle was spawned.


position: Vector3

Defined in: shared.d.ts:81


readonly radioStation: number

Defined in: server/api.d.ts:312

Stored native radio station ID; 255 represents unset or off.


readonly rightIndicator: boolean

Defined in: server/api.d.ts:352

Whether the replicated right turn indicator is on.


rotation: Vector3 | Quaternion

Defined in: shared.d.ts:82


readonly siren: boolean

Defined in: server/api.d.ts:362

Whether the replicated siren is on.


readonly speedLimiter: boolean

Defined in: server/api.d.ts:302

Whether the server-controlled native speed limiter is enabled.


readonly speedLimiterSpeed: number

Defined in: server/api.d.ts:307

Speed-limiter threshold in kilometres per hour, or a negative model-default value.


readonly trunk: boolean

Defined in: server/api.d.ts:382

Whether the replicated trunk is open.


readonly tuning: number

Defined in: server/api.d.ts:282

Stored tuning level from 0 for stock through 3.


readonly virtualWorld: number

Defined in: shared.d.ts:80


readonly wheelModels: string[]

Defined in: server/api.d.ts:292

Stored model names for the front, rear, and spare wheel groups.


readonly wheelStates: number[]

Defined in: server/api.d.ts:297

Stored VehicleWheelState value for every wheel.


readonly wipers: boolean

Defined in: server/api.d.ts:287

Whether the windshield wipers are active.