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.
Signature
Section titled “Signature”vehicles.setColors(id: number, colors: readonly number[]): Promise<ActionResult>Parameters
Section titled “Parameters”| 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. |
Returns
Section titled “Returns”A promise of an ActionResult: "applied" once every player is told, or rejected with
invalid-color or vehicle-not-found.
Example
Section titled “Example”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]);});Related
Section titled “Related”vehicles.getAppearance: read the colorsvehicleAppearanceChanged: every change of a look