---
name: "setAmmo"
type: command
status: ok
groups: ["Unit Inventory", "Vehicle Inventory"]
arma3_since: "0.50"
locality: {"argument": "local", "effect": "global", "server_exec": false}
source: https://community.bistudio.com/wiki/setAmmo
revid: 369275
updated: 2024-09-03T18:42:45Z
---

# setAmmo

*Command · Unit Inventory, Vehicle Inventory · Arma 3 v0.50*

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

## Description

Sets custom ammo count in the currently loaded magazine of the specified weapon or muzzle.

## Syntax

```sqf
unit setAmmo [weaponOrMuzzle, count]
```

**Parameters:**

- `unit`: [Object](../topics/Object.md) - gunner or vehicle.
- `weaponOrMuzzle`: [String](../topics/String.md) - weapon name. Muzzle name in case the weapon has more than one muzzle, e.g. weapon with grenade launcher. See CfgWeapons for muzzle names
- `count`: [Number](../topics/Number.md)

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

## Examples

### Example 1

Set player's handgun magazine ammo count to 10 rounds:

```sqf
player setAmmo [handgunWeapon player, 10];
```

### Example 2

Set player's current weapon magazine ammo count to 1 round:

```sqf
player setAmmo [currentWeapon player, 1];
```

### Example 3

If player is a gunner in a vehicle, set current weapon magazine ammo count to 5 rounds:

```sqf
if (local vehicle player) then {
    vehicle player setAmmo [currentWeapon vehicle player, 5];
} else {
    hint "Vehicle must be local to this machine for 'setAmmo' to work";
};
```

### Example 4

If you try to set more ammo than the magazine can hold, it will be clipped at default magazine capacity:

```sqf
player setAmmo [primaryWeapon player, 1000000]; // full mag with default ammo count
```

### Example 5

Some weapons has more than one muzzles:

```sqf
_marshall setAmmo ["autocannon_40mm_CTWS", 0];// won't work
_marshall setAmmo ["HE", 0];// works
```

## See also

[ammo](../commands/ammo.md) · [setVehicleAmmo](../commands/setVehicleAmmo.md) · [setFuel](../commands/setFuel.md) · [setHit](../commands/setHit.md)

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