GetVehicleComponentType
From SA-MP Wiki
GetVehicleComponentType
Warning: This function was added in SA-MP version 0.3. It is not available in previous versions.
Find out what type of component a certain ID is.
(component)
| component | The component ID to check. |
| Returns | The component slot ID of the specified component |
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 might be useful as well, as they're related to this function in one way or another.
- AddVehicleComponent: Add a component to a vehicle.
- RemoveVehicleComponent: Remove a component from a vehicle.
- GetVehicleComponentInSlot: Check what components a vehicle has.
Related Callbacks
The following callbacks might be useful, as they're related to this function in one way or another.
- OnVehicleMod: Called when a vehicle is modded.
- OnEnterExitModShop: Called when a vehicle enter or exit mod shop.
