diff --git a/addons/common/fnc_getMuzzles.sqf b/addons/common/fnc_getMuzzles.sqf index d6a7b8d7c..77811b20e 100644 --- a/addons/common/fnc_getMuzzles.sqf +++ b/addons/common/fnc_getMuzzles.sqf @@ -13,23 +13,34 @@ Returns: Examples: (begin example) - _muzzles = "M4A1_RCO_GL" call CBA_fnc_getMuzzles - -> ["M4_ACOG_Muzzle", "M203Muzzle"] + _muzzles = "arifle_AK12_GL_F" call CBA_fnc_getMuzzles + -> ["arifle_AK12_GL_F","EGLM"] (end) Author: - commy2 + commy2, johnb43 ---------------------------------------------------------------------------- */ SCRIPT(getMuzzles); params [["_weapon", "", [""]]]; -private _muzzles = getArray (configFile >> "CfgWeapons" >> _weapon >> "muzzles"); +private _config = configFile >> "CfgWeapons" >> _weapon; +if (!isClass _config) exitWith { + [] // return +}; + +private _muzzles = []; + +// Get config case muzzle names { if (_x == "this") then { - _muzzles set [_forEachIndex, _weapon]; + _muzzles pushBack (configName _config); + } else { + if (isClass (_config >> _x)) then { + _muzzles pushBack (configName (_config >> _x)); + }; }; -} forEach _muzzles; +} forEach getArray (_config >> "muzzles"); -_muzzles +_muzzles // return