Skip to content

Commit

Permalink
Merge pull request #1676 from johnb432/common-muzzle-configcase
Browse files Browse the repository at this point in the history
Common - Make `CBA_fnc_getMuzzles` configcase
  • Loading branch information
PabstMirror committed Jul 28, 2024
2 parents cef8beb + 9d0083c commit 6bd842d
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions addons/common/fnc_getMuzzles.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6bd842d

Please sign in to comment.