Skip to content

vehicles.addComponent

Fits a component (a spoiler, wheels, nitro, a side skirt and so on) to a vehicle for every player, as a mod shop would. A component already in the same slot comes off first. Components that come as a pair, such as side skirts and bonnet vents, go on and come off together.

vehicles.addComponent(id: number, component: number): Promise<ActionResult>
vehicles.removeComponent(id: number, component: number): Promise<ActionResult>
Name Type Description
id number The vehicle’s network ID.
component number The component’s model ID, 1000-1193.

A promise of an ActionResult: "applied", or rejected with invalid-component, component-not-compatible (see vehicles.isComponentCompatible) or vehicle-not-found. Removing a component the vehicle does not have is applied and changes nothing.

gamemodes/my-mode.ts
import { commands, vehicles } from "nativemp";
commands.register("nos", async (player) => {
if (player.vehicleId === null) return;
const vehicle = vehicles.getById(player.vehicleId);
if (vehicle && vehicles.isComponentCompatible(vehicle.model, 1010)) await vehicles.addComponent(player.vehicleId, 1010);
});