GetVehicleComponentType

From SA-MP Wiki

Jump to: navigation, search


GetVehicleComponentType was added in SA-MP 0.3a This function was added in SA-MP 0.3a and will not work in earlier versions!


Description:

Find out what type of component a certain ID is.


Parameters:
(component)
componentThe component ID to check.


Return Values:

The component slot ID of the specified component or -1 if the component is invalid.


Example:

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext,"/nitro",true))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFF0000AA,"You are not in a vehicle!"); // If the player is not in vehicle...
        if(GetVehicleComponentInSlot(GetPlayerVehicleID(playerid),GetVehicleComponentType(1010)) != 1010) // Check if the vehicle has no nitro
        {
            AddVehicleComponent(GetPlayerVehicleID(playerid),1010); // Adding nitro
            PlayerPlaySound(playerid,1133,0.0,0.0,0.0); // Sound of vehicle improving
        }
        return 1;
    }
    return 0;
}

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.

Personal tools
In other languages