open.mp | AddVehicleComponent
  • Home
  • FAQ
  • Forum
  • Servers
  • Docs
  • Blog
  • Login
  • Englishاللغة العربيةar-TNবাংলাbosanski jezikDeutschΕλληνικάEspañoleestiفارسیFrançaisHrvatskimagyarBahasa IndonesiaItaliano日本語ქართულიlietuvių kalbaNederlandsNorskjęzyk polskiPortuguêsRomânăРусскийslovenski jezikсрпски језикไทยWikang TagalogTürkçeУкраїнськаاردوTiếng Việt简体中文繁體中文

AddVehicleComponent

Description

Adds a 'component' (often referred to as a 'mod' (modification)) to a vehicle. Valid components can be found here.

NameDescription
vehicleidThe ID of the vehicle to add the component to. Not to be confused with modelid.
componentidThe ID of the component to add to the vehicle.

Returns

0 - The component was not added because the vehicle does not exist.

1 - The component was successfully added to the vehicle.

Examples

new gTaxi;

public OnGameModeInit()
{
    gTaxi = AddStaticVehicle(420, -2482.4937, 2242.3936, 4.6225, 179.3656, 6, 1); // Taxi
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if (newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
    {
        if (GetPlayerVehicleID(playerid) == gTaxi)
        {
            AddVehicleComponent(gTaxi, 1010); // Nitro
            SendClientMessage(playerid, 0xFFFFFFAA, "Nitro added to the Taxi.");
        }
    }
    return 1;
}

Notes

warning

Using an invalid component ID crashes the player's game. There are no internal checks for this.

Related Functions

  • RemoveVehicleComponent: Remove a component from a vehicle.
  • GetVehicleComponentInSlot: Check what components a vehicle has.
  • GetVehicleComponentType: Check the type of component via the ID.
  • OnVehicleMod: Called when a vehicle is modded.
  • OnEnterExitModShop: Called when a vehicle enters or exits a mod shop.

Community

  • Discord
  • Instagram
  • Twitter
  • Twitch
  • YouTube
  • Facebook
  • VK

More

  • SA-MP
  • Blog
  • GitHub