schadler17 36 Posted September 29, 2015 Trying to get this script to basically restrict specific weapon sights based on Class. It works, but when the player has NO sights, it throws an error based on the _weaponSight variable not being able to find anything.. private ["_rClass", "_rItem", "_weaponSight", "_weaponSightName"]; while {true} do { _rClass = _this select 0; _rItem = _this select 1; _weaponSight = primaryWeaponItems player select 2; _weaponSightName = getText(configFile >> "CfgWeapons" >>_weaponSight >> "displayName"); sleep 3; if ((_weaponSight in _rItem) && !(typeOf player in _rClass)) then { player removePrimaryWeaponItem _weaponSight; hint format ["RESTRICTED WEAPON SIGHT\n\nYour class is not allowed\nto use %1.",_weaponSightName]; }; } forEach allUnits; Share this post Link to post Share on other sites
R3vo 2654 Posted September 29, 2015 private ["_rClass", "_rItem", "_weaponSight", "_weaponSightName"]; while {true} do { _rClass = _this select 0; _rItem = _this select 1; _weaponSight = primaryWeaponItems player select 2; _weaponSightName = getText(configFile >> "CfgWeapons" >>_weaponSight >> "displayName"); sleep 3; if (!isNil _weaponSight) then //check if _weaponSight is empty { if ((_weaponSight in _rItem) && !(typeOf player in _rClass)) then { player removePrimaryWeaponItem _weaponSight; hint format ["RESTRICTED WEAPON SIGHT\n\nYour class is not allowed\nto use %1.",_weaponSightName]; }; }; } forEach allUnits; That should hopefully solve the issue. Share this post Link to post Share on other sites
schadler17 36 Posted September 29, 2015 Fixed it using: _weaponSight = player weaponAccessories primaryWeapon player select 2; Thanks for the help though :P Share this post Link to post Share on other sites