Skip to content

vehicles.create

Creates a vehicle of your gamemode’s own: a job car, a player’s personal car, a car parked for everyone. Every player sees the same vehicle. It is persistent: it stays in the world until you destroy it, also when players get out of it or leave the server.

vehicles.create(settings: VehicleSettings): Promise<ActionResult>
Name Type Description
settings.model number The vehicle model, 400 to 611. Trains cannot be created.
settings.position Vector3 Where, [x, y, z]. Give a height on the ground.
settings.facingAngleDegrees number Optional. The direction it faces, in degrees (default 0).
settings.color1, settings.color2 number Optional. The game’s car colors, palette indexes 0 to 126 (default 0), as vehicles.setColors takes them. A Pay ‘n’ Spray or a mod shop does not change them.
settings.interior number Optional. 0 outside (the default), or 1 to 18 an interior’s.
settings.virtualWorld number Optional. The virtual world it is in. Defaults to 0.
settings.respawnDelaySeconds number Optional. Seconds an empty vehicle waits before it goes back to where you created it. Left out: it stays where it was left.

A promise of an ActionResult: applied with value, the new vehicle’s ID. Bad settings are invalid-vehicle or invalid-position, a color outside 0 to 126 invalid-color; a model that is no vehicle, or a train, is invalid-model.

An Infernus at Grove Street that comes back two minutes after it is left.

gamemodes/my-mode.ts
import { vehicles } from "nativemp";
const result = await vehicles.create({ model: 411, position: [2495, -1680, 13.3], facingAngleDegrees: 90, color1: 3, respawnDelaySeconds: 120 });
const infernus = result.status === "applied" ? result.createdId : undefined;