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.
Signature
Section titled “Signature”vehicles.addComponent(id: number, component: number): Promise<ActionResult>vehicles.removeComponent(id: number, component: number): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
id |
number |
The vehicle’s network ID. |
component |
number |
The component’s model ID, 1000-1193. |
Returns
Section titled “Returns”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.
Example
Section titled “Example”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);});Related
Section titled “Related”vehicles.listCompatibleComponents: what a model takesvehicles.getAppearance: the components fitted now