# addVehicleUpgrade (Shared)

> Fits a tuning upgrade on a vehicle, replacing whatever is on the same slot.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Vehicles
- **URL**: https://wiki.mymp.gg/en/addVehicleUpgrade

## Syntax

```lua
bool addVehicleUpgrade(element vehicle, string upgrade)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `vehicle` | `element` | The vehicle, or a parent element whose vehicles all get the upgrade. |
| `upgrade` | `string` | The upgrade's model name (case does not matter), or `"all"` to fit a compatible upgrade on every slot. |

## Returns

`true` if it was fitted. `false` if the upgrade does not suit the vehicle's model or the element is not a vehicle.

Given a parent element such as `root`, it applies to every vehicle below it, but the value returned is the element's own: `false` when it is not a vehicle.

## Example

```lua
addCommandHandler("tunar", function(player)
    local vehicle = getPedOccupiedVehicle(player)
    if vehicle then
        addVehicleUpgrade(vehicle, "all")
    end
end)
```

### Coming from MTA

MTA uses numeric upgrade ids (1000 to 1193). Here an upgrade is its model's name, and the slots are the ones the mounted packs declare.

## See also

- [removeVehicleUpgrade (Shared)](https://wiki.mymp.gg/en/removeVehicleUpgrade.md): Takes a tuning upgrade off a vehicle.
- [getVehicleCompatibleUpgrades (Shared)](https://wiki.mymp.gg/en/getVehicleCompatibleUpgrades.md): Returns the tuning upgrades that fit a vehicle's model.
- [getVehicleUpgrades (Shared)](https://wiki.mymp.gg/en/getVehicleUpgrades.md): Returns every tuning upgrade fitted on a vehicle.
- [getVehicleUpgradeOnSlot (Shared)](https://wiki.mymp.gg/en/getVehicleUpgradeOnSlot.md): Returns the upgrade fitted on one slot of a vehicle.
