{"name":"Example Code: Remove NVGs From Enemies","title":"Example Code: Remove NVGs From Enemies","type":"topic","url":"https://community.bistudio.com/wiki/Example_Code:_Remove_NVGs_From_Enemies","revid":364504,"updated":"2024-05-16T20:42:04Z","aliases":[],"markdown":"### Arma 3 (Arma 3 v2.02)\n\n> [!NOTE]\n> - units *side* has been introduced in Arma 3 v2.02\n\n```sqf\n{\n    _x unlinkItem hmd _x;                                        // removal of each unit's hmd\n} forEach units opfor;                                            // code is to be executed for each enemy\n```\n\n### Arma 3 (Arma 3 v1.56)\n\n> [!NOTE]\n> - opfor has been introduced in Arma 3 v0.50\n> - `_array select _code` has been introduced in Arma 3 v1.56\n\n```sqf\nprivate _enemySide = opfor;                                        // definition of the enemy side\nprivate _enemies = allUnits select { side _x == _enemySide; };    // selection of all enemy units from allUnits\n{\n    _x unlinkItem hmd _x;                                        // removal of each unit's hmd\n} forEach _enemies;                                                // code is to be executed for each enemy\n```\n\n### Arma 2 (Arma 2 v1.00)\n\n> [!NOTE]\n> - allUnits has been introduced in Arma 2 v1.00\n\n```sqf\nprivate \"_enemySide\";                    // private definition of the _enemySide variable\n_enemySide = east;                        // value attribution to _enemySide\n{\n    if (side _x == _enemySide) then        // if the unit is on the _enemySide, process the next step\n    {\n        _x removeWeapon \"NVGoggles\";    // removal of the enemy unit's NVG\n    }\n} forEach allUnits;                        // going through -all- units\n```\n\n### Armed Assault / Operation Flashpoint: Resistance (Armed Assault v1.00 Operation Flashpoint: Resistance v1.85)\n\n> [!NOTE]\n> - SQF Syntax has been introduced in Operation Flashpoint: Resistance v1.85\n\n```sqf\nprivate \"_enemySide\";                    // private definition of the _enemySide variable\n_enemySide = east;                        // value attribution to _enemySide\n{\n    if (side _x == _enemySide) then        // if the unit is on the _enemySide, process the next step\n    {\n        _x removeWeapon \"NVGoggles\";    // removal of the enemy unit's NVG\n    }\n} forEach _unitsArray;                    // going through provided units - allUnits has been introduced in Arma 2\n```\n\n### Operation Flashpoint (Operation Flashpoint v1.00)\n\n> [!NOTE]\n> This is an SQS Syntax example.\n\n```sqs\n; remove its NVG for each provided enemy units\n\"_x removeWeapon \"\"NVGoggles\"\"\" forEach _enemyUnitsArray\n```","sections":[{"heading":"Arma 3 (Arma 3 v2.02)","level":3,"markdown":"> [!NOTE]\n> - units *side* has been introduced in Arma 3 v2.02\n\n```sqf\n{\n    _x unlinkItem hmd _x;                                        // removal of each unit's hmd\n} forEach units opfor;                                            // code is to be executed for each enemy\n```"},{"heading":"Arma 3 (Arma 3 v1.56)","level":3,"markdown":"> [!NOTE]\n> - opfor has been introduced in Arma 3 v0.50\n> - `_array select _code` has been introduced in Arma 3 v1.56\n\n```sqf\nprivate _enemySide = opfor;                                        // definition of the enemy side\nprivate _enemies = allUnits select { side _x == _enemySide; };    // selection of all enemy units from allUnits\n{\n    _x unlinkItem hmd _x;                                        // removal of each unit's hmd\n} forEach _enemies;                                                // code is to be executed for each enemy\n```"},{"heading":"Arma 2 (Arma 2 v1.00)","level":3,"markdown":"> [!NOTE]\n> - allUnits has been introduced in Arma 2 v1.00\n\n```sqf\nprivate \"_enemySide\";                    // private definition of the _enemySide variable\n_enemySide = east;                        // value attribution to _enemySide\n{\n    if (side _x == _enemySide) then        // if the unit is on the _enemySide, process the next step\n    {\n        _x removeWeapon \"NVGoggles\";    // removal of the enemy unit's NVG\n    }\n} forEach allUnits;                        // going through -all- units\n```"},{"heading":"Armed Assault / Operation Flashpoint: Resistance (Armed Assault v1.00 Operation Flashpoint: Resistance v1.85)","level":3,"markdown":"> [!NOTE]\n> - SQF Syntax has been introduced in Operation Flashpoint: Resistance v1.85\n\n```sqf\nprivate \"_enemySide\";                    // private definition of the _enemySide variable\n_enemySide = east;                        // value attribution to _enemySide\n{\n    if (side _x == _enemySide) then        // if the unit is on the _enemySide, process the next step\n    {\n        _x removeWeapon \"NVGoggles\";    // removal of the enemy unit's NVG\n    }\n} forEach _unitsArray;                    // going through provided units - allUnits has been introduced in Arma 2\n```"},{"heading":"Operation Flashpoint (Operation Flashpoint v1.00)","level":3,"markdown":"> [!NOTE]\n> This is an SQS Syntax example.\n\n```sqs\n; remove its NVG for each provided enemy units\n\"_x removeWeapon \"\"NVGoggles\"\"\" forEach _enemyUnitsArray\n```"}],"categories":["Example Code"],"groups":["Scripting"]}