ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. getVehicleCompatibleUpgrades

Function

getVehicleCompatibleUpgrades

Server and clientVehiclesIdentical to MTA:SA

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