Skip to content

vehicles.setColors

Sets a vehicle’s colors for every player, also for players who come later and after another player’s game takes the vehicle over. A vehicle your gamemode created keeps these colors until you change them or it respawns; a respawn gives it back the colors you created it with.

vehicles.setColors(id: number, colors: readonly number[]): Promise<ActionResult>
Name Type Description
id number The vehicle’s network ID.
colors readonly number[] 1 to 4 indexes into the game’s vehicle color palette (0-126; see vehicles.getPaletteColorRgba), for the vehicle’s color slots in order. Slots you leave out keep their color. Most models use the first two.

A promise of an ActionResult: "applied" once every player is told, or rejected with invalid-color or vehicle-not-found.

gamemodes/my-mode.ts
import { commands, vehicles } from "nativemp";
commands.register("paint", async (player, args) => {
const [first, second] = args.split(" ").map(Number);
if (player.vehicleId !== null) await vehicles.setColors(player.vehicleId, [first, second ?? first]);
});