- Documentation
- Shared functions
- getVehicleCompatibleUpgrades
Function
getVehicleCompatibleUpgrades
Returns 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.
Syntax
table getVehicleCompatibleUpgrades(vehicle vehicle [, int slot = nil])Arguments
vehiclevehicle- The vehicle.
slotint, optional = nil- Slot number 0-16; without it all fitting parts.
Returns
An array of part IDs.
Example
addCommandHandler("felgi", function(player)
local vehicle = getPedOccupiedVehicle(player)
if not vehicle then return end
local wheels = getVehicleCompatibleUpgrades(vehicle, 12)
if #wheels > 0 then addVehicleUpgrade(vehicle, wheels[math.random(#wheels)]) end
end)
See also
getModelCompatibleUpgradesLikegetVehicleCompatibleUpgrades, but for a model number, without creating a vehicle. Useful in a shop that shows parts before buying the car.addVehicleUpgradeFits a tuning part to a vehicle (spoiler, wheels, exhaust, nitro, hydraulics, bumpers…), visible and working for every player. The part must fit the model (getVehicleCompatibleUpgradeslists them). If the same slot already had a part, it is replaced; fitting the same part again changes nothing. New parts added withengineRequestModelwork too.