- Documentation
- Shared functions
- addVehicleUpgrade
Function
addVehicleUpgrade
Fits a tuning part to a vehicle (spoiler, wheels, exhaust, nitro, hydraulics, bumpers…), visible and working for every player. The part must fit the model (getVehicleCompatibleUpgrades lists them). If the same slot already had a part, it is replaced; fitting the same part again changes nothing. New parts added with engineRequestModel work too.
Syntax
bool addVehicleUpgrade(vehicle vehicle, int upgrade)Arguments
vehiclevehicle- The vehicle.
upgradeint- Part ID 1000-1193 (e.g. 1010 = nitro x10, 1080 = Switch wheels, 1087 = hydraulics) or a new ID from
engineRequestModel.
Returns
true when the part was fitted; false when it does not fit the model or the ID is invalid.
Example
addCommandHandler("tuning", function(player)
local vehicle = getPedOccupiedVehicle(player)
if not vehicle then return end
for _, part in ipairs({ 1010, 1080, 1087 }) do
addVehicleUpgrade(vehicle, part)
end
end)
Notes
Client. In a client script the part is for this player only (others do not see it); permanent tuning - on the server.
See also
removeVehicleUpgradeRemoves a fitted tuning part from a vehicle. Removing nitro also clears the stored nitro charges.getVehicleUpgradesReturns the IDs of all tuning parts fitted to a vehicle. Works on both sides.getVehicleCompatibleUpgradesReturns the tuning parts that fit this vehicle, based on the game's data (the carmods list plus wheels for regular cars). The result can be narrowed to one slot. Ideal for building a workshop menu.getVehicleUpgradeOnSlotReturns the ID of the part fitted in the given tuning slot, or 0 when the slot is empty. Slot numbers 0-16 are described bygetVehicleUpgradeSlotName.