---
name: "BIS_fnc_limitWeaponItems"
type: function
status: ok
groups: ["Inventory"]
arma3_since: "1.00"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/BIS_fnc_limitWeaponItems
revid: 348030
updated: 2023-11-08T11:26:29Z
---

# BIS_fnc_limitWeaponItems

*Function · Inventory · Arma 3 v1.00*

## Description

Keeps or remove unit's weapon attachments based on probability user sets. Apply for primary, secondary or handgun weapon separately.

## Syntax

```sqf
[unit, mode, chanceOptics, chanceAttach, chanceMuzzle, chanceUnderbarrel] call BIS_fnc_limitWeaponItems
```

**Parameters:**

- `unit`: [Object](../topics/Object.md) - target unit
- `mode`: [Number](../topics/Number.md) - (Optional, default 0) can be:
  - 1 = primary weapon
  - 2 = secondary weapon
  - 3 = handgun
- `chanceOptics`: [Number](../topics/Number.md) or [Array](../topics/Array.md) in format ["itemClass", chance] - (Optional, default 50) chance to keep optics from 0 to 100%

  - if ["itemClassname", number] is used, the function will add that attachment if it passes the check. If not, the current attachment will be removed.
- `chanceAttach`: [Number](../topics/Number.md) or [Array](../topics/Array.md) in format ["itemClass", chance] - (Optional, default 50) chance to keep side attachments from 0 to 100%
- `chanceMuzzle`: [Number](../topics/Number.md) or [Array](../topics/Array.md) in format ["itemClass", chance] - (Optional, default 50) chance to keep muzzle attachment from 0 to 100%
- `chanceUnderbarrel`: [Number](../topics/Number.md) or [Array](../topics/Array.md) in format ["itemClass",chance] - (Optional, default 50) chance to keep underbarrel attachment from 0 to 100%

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

## Examples

### Example 1

```sqf
player call BIS_fnc_limitWeaponItems;
```

### Example 2

```sqf
[[player, 0, 25, 50, 75, 100]]  call BIS_fnc_limitWeaponItems;
```

### Example 3

```sqf
[[player, 0, ["optic_lrps", 100], ["acc_pointer_ir", 100], ["muzzle_snds_B", 100], ["bipod_01_F_blk", 100]]] call BIS_fnc_limitWeaponItems;
```

## See also

[BIS_fnc_limitAmmunition](../functions/BIS_fnc_limitAmmunition.md) · [BIS_fnc_limitItems](../functions/BIS_fnc_limitItems.md)

<sub>Source: [BI Community Wiki — BIS fnc limitWeaponItems](https://community.bistudio.com/wiki/BIS_fnc_limitWeaponItems) (revision 348030).</sub>
