---
name: "setUnitLoadout"
type: command
status: ok
groups: ["Unit Inventory"]
arma3_since: "1.58"
locality: {"argument": "global", "effect": "global", "server_exec": false}
source: https://community.bistudio.com/wiki/setUnitLoadout
revid: 370162
updated: 2024-11-02T23:29:35Z
---

# setUnitLoadout

*Command · Unit Inventory · Arma 3 v1.58*

Locality: arguments **global** · effect **global**

## Description

Creates a loadout from given inventory structure and applies it to a unit.
When [String](../topics/String.md) for class name is supplied, the command will search `CfgVehicles` for the given class in order to extract the loadout from config.
If [Config](../topics/Config.md) is given, it will search given config (including [mission config](../commands/missionConfigFile.md)) for the loadout information.
In either case, the config should contain the following entries, which is standard for any unit class, for example:

```cpp
class MyLoadout
{
    uniformClass = "U_B_CombatUniform_mcam";
    backpack = "B_AssaultPack_mcamo";
    linkedItems[] = { "V_PlateCarrier1_rgr", "H_HelmetB", "ItemCompass", "ItemWatch", "ItemRadio", "NVGoggles" };
    weapons[] = { "arifle_MX_ACO_pointer_F", "hgun_P07_F" };
    items[] = { "FirstAidKit", "FirstAidKit", "FirstAidKit" };
    magazines[] = {
        "30Rnd_65x39_caseless_mag", "16Rnd_9x21_Mag", "SmokeShell",
        "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade",
        "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade",
        "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade",
        "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade",
        "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"
    };
};
```

> [!IMPORTANT]
> Since Arma 3 v2.20 if the command is executed while the unit is in the process of switching weapon, the command will be aborted. To check if unit is switching weapon use [isSwitchingWeapon](../commands/isSwitchingWeapon.md).

## Syntax

### Syntax 1

```sqf
unit setUnitLoadout loadout
```

**Parameters:**

- `unit`: [Object](../topics/Object.md)
- `loadout`: [Array](../topics/Array.md) - Unit Loadout Array

**Returns:** [Nothing](../topics/Nothing.md)

### Syntax 2

```sqf
unit setUnitLoadout [loadout, fullMagazines]
```

**Parameters:**

- `unit`: [Object](../topics/Object.md)
- `loadout`: [Array](../topics/Array.md) - Unit Loadout Array
- `fullMagazines`: [Boolean](../topics/Boolean.md) - partially emptied magazines will be refilled when the loadout is applied

**Returns:** [Nothing](../topics/Nothing.md)

### Syntax 3

```sqf
unit setUnitLoadout name
```

**Parameters:**

- `unit`: [Object](../topics/Object.md)
- `name`: [String](../topics/String.md) - class name (see description)

**Returns:** [Nothing](../topics/Nothing.md)

### Syntax 4

```sqf
unit setUnitLoadout config
```

**Parameters:**

- `unit`: [Object](../topics/Object.md)
- `config`: [Config](../topics/Config.md) - config class (see description)

**Returns:** [Nothing](../topics/Nothing.md)

## Examples

### Example 1

```sqf
_unit setUnitLoadout "B_Soldier_F";                                        // by class name
_unit setUnitLoadout (configFile >> "CfgVehicles" >> "B_Soldier_F");    // by config entry
_unit setUnitLoadout (missionConfigFile >> "MyLoadout");                // (also works for mission config)
_unit setUnitLoadout getUnitLoadout _otherUnit;                            // by loadout array
```

### Example 2

```sqf
player_2 setUnitLoadout (getUnitLoadout player_1);            // Copies loadout from player_1 and applies it to player_2
player_2 setUnitLoadout [getUnitLoadout player_1, true];    // Copies loadout from player_1 and applies it to player_2 while topping up all magazines
```

### Example 3

Strip unit of everything:

```sqf
_unit setUnitLoadout (configFile >> "EmptyLoadout");
```

### Example 4

Make sure the unit is not switching weapon:

```sqf
player spawn 
{
    waitUntil {!isSwitchingWeapon _this};
    _this setUnitLoadout (configFile >> "EmptyLoadout");
};
```

## Problems

> [!IMPORTANT]
> If this command is used on the player, it makes the inventory window bug (if opened) - vest and backpack tabs disappear. Closing and re-opening the inventory solves the issue.

## See also

[getUnitLoadout](../commands/getUnitLoadout.md) · [isSwitchingWeapon](../commands/isSwitchingWeapon.md)

## Community notes

**Demellion** — 2019-12-17

Empty or used magazines in loadouts will be refilled under specific circumstance, even if the refill argument is [false](../commands/false.md). This seems to happen if amount of used magazines is 2 or more.

```sqf
player setUnitLoadout [
    ["arifle_MX_ACO_pointer_F", "", "acc_pointer_IR", "optic_Aco", [], [], ""],
    [],
    ["hgun_P07_F", "", "", "", ["16Rnd_9x21_Mag", 16], [], ""],
    ["U_B_CombatUniform_mcam", [["30Rnd_65x39_caseless_mag", 1, 1]]],
    ["V_PlateCarrier1_rgr", []],
    ["B_AssaultPack_mcamo_Ammo", []],
    "H_HelmetB_grass", "", [], ["ItemMap", "", "ItemRadio", "ItemCompass", "ItemWatch", "NVGoggles"]
];
```

Will result in 30Rnd magazine with one bullet in it.

```sqf
player setUnitLoadout [
    ["arifle_MX_ACO_pointer_F", "", "acc_pointer_IR", "optic_Aco", [], [], ""],
    [],
    ["hgun_P07_F", "", "", "", ["16Rnd_9x21_Mag", 16], [], ""],
    ["U_B_CombatUniform_mcam", [["30Rnd_65x39_caseless_mag", 2, 1]]],
    ["V_PlateCarrier1_rgr", []],
    ["B_AssaultPack_mcamo_Ammo", []],
    "H_HelmetB_grass", "", [], ["ItemMap", "", "ItemRadio", "ItemCompass", "ItemWatch", "NVGoggles"]
];
```

Will result in 2 magazines but full, 30 rounds in it. This applies to any magazines count >2. They will never be with specified amount of rounds, even if you force the refill argument to [false](../commands/false.md).

---

**Andrew_S90** — 2020-10-23

Here is a command I wrote up that provides a fix for the ammo bug described by Demellion above.
https://pastebin.com/SHX41Jkk
Pass a loadout to your compiled command and it will provide one back that will not refill ammo.

---

**POLPOX** — 2022-08-23

```sqf
player setUnitLoadout [
    nil, nil, nil, nil, nil,
    ["B_Bergen_sgg", nil],
    nil, nil, nil, nil
];
```

You can use [nil](../commands/nil.md) to skip some desired parameter. The skipped part will be ignored and remain the same with old loadout.

This method is *very slightly* faster than the latter method:

```sqf
private _loadout = getUnitLoadout player;
_loadout#5 set [0, "B_Bergen_mcamo_F"];
player setUnitLoadout _loadout;
```

<sub>Source: [BI Community Wiki — setUnitLoadout](https://community.bistudio.com/wiki/setUnitLoadout) (revision 370162).</sub>
