---
name: "Example Code: Remove NVGs From Enemies"
type: topic
source: https://community.bistudio.com/wiki/Example_Code:_Remove_NVGs_From_Enemies
revid: 364504
updated: 2024-05-16T20:42:04Z
---

# Example Code: Remove NVGs From Enemies

### Arma 3 (Arma 3 v2.02)

> [!NOTE]
> - [units](../commands/units.md) *side* has been introduced in Arma 3 v2.02

```sqf
{
    _x unlinkItem hmd _x;                                        // removal of each unit's hmd
} forEach units opfor;                                            // code is to be executed for each enemy
```

### Arma 3 (Arma 3 v1.56)

> [!NOTE]
> - [opfor](../commands/opfor.md) has been introduced in Arma 3 v0.50
> - `_array select _code` has been introduced in Arma 3 v1.56

```sqf
private _enemySide = opfor;                                        // definition of the enemy side
private _enemies = allUnits select { side _x == _enemySide; };    // selection of all enemy units from allUnits
{
    _x unlinkItem hmd _x;                                        // removal of each unit's hmd
} forEach _enemies;                                                // code is to be executed for each enemy
```

### Arma 2 (Arma 2 v1.00)

> [!NOTE]
> - [allUnits](../commands/allUnits.md) has been introduced in Arma 2 v1.00

```sqf
private "_enemySide";                    // private definition of the _enemySide variable
_enemySide = east;                        // value attribution to _enemySide
{
    if (side _x == _enemySide) then        // if the unit is on the _enemySide, process the next step
    {
        _x removeWeapon "NVGoggles";    // removal of the enemy unit's NVG
    }
} forEach allUnits;                        // going through -all- units
```

### Armed Assault / Operation Flashpoint: Resistance (Armed Assault v1.00 Operation Flashpoint: Resistance v1.85)

> [!NOTE]
> - [SQF Syntax](../topics/SQF_Syntax.md) has been introduced in Operation Flashpoint: Resistance v1.85

```sqf
private "_enemySide";                    // private definition of the _enemySide variable
_enemySide = east;                        // value attribution to _enemySide
{
    if (side _x == _enemySide) then        // if the unit is on the _enemySide, process the next step
    {
        _x removeWeapon "NVGoggles";    // removal of the enemy unit's NVG
    }
} forEach _unitsArray;                    // going through provided units - allUnits has been introduced in Arma 2
```

### Operation Flashpoint (Operation Flashpoint v1.00)

> [!NOTE]
> This is an [SQS Syntax](../topics/SQS_Syntax.md) example.

```sqs
; remove its NVG for each provided enemy units
"_x removeWeapon ""NVGoggles""" forEach _enemyUnitsArray
```

<sub>Source: [BI Community Wiki — Example Code: Remove NVGs From Enemies](https://community.bistudio.com/wiki/Example_Code:_Remove_NVGs_From_Enemies) (revision 364504).</sub>
