AddVehicleComponent

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 02:42, 7 November 2017
RIDE2DAY (Talk | contribs)

← Previous diff
Current revision
Dugi (Talk | contribs)
(revert)
Line 11: Line 11:
* '''1''' - The component was successfully added to the vehicle.}} * '''1''' - The component was successfully added to the vehicle.}}
-{{note|Using an invalid [[Car Component ID|component ID]] crashes the player's game, [https://goo.gl/GnA1j5 vSync] fixes this issue.}}+{{Note2|Using an invalid [[Car Component ID|component ID]] crashes the player's game. There are no internal checks for this.}}
<pawn> <pawn>

Current revision



Description:

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


Parameters:
(vehicleid, componentid)
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.


Return Values:

  • 0 - The component was not added because the vehicle does not exist.
  • 1 - The component was successfully added to the vehicle.


Image:32px-Circle-style-warning.png

Important
Note

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


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;
}

Related Functions

The following functions may be useful, as they are related to this function in one way or another.


Related Callbacks

The following callbacks might be useful, as they're related to this function in one way or another.