dyrmoon 22 Posted January 20, 2018 Hello, how do I find if I have a gun switched to muzzle grenade? Is there any command? currentWeaponMode Player is not working (show only "Single"). I use ((WeaponState Player) select 1 isEqualTo ((getarray (configFile >> "CfgWeapons" >> (primaryWeapon Player) >> "muzzles")) select 1)) but this is no perfect. If I switch to other gun, which does not have a grenade launcher, then I get error from this. And second, is there any way to calculate how much a grenade muzzle has player in inventory? Thank you. Share this post Link to post Share on other sites
Larrow 2800 Posted January 21, 2018 Maybe you can pull from this what you need, as a quick example to cover your two questions.. _fnc_isUsingGL = { params[ "_unit" ]; //Get units current weapon and muzzle weaponState _unit params[ "_weapon", "_muzzle" ]; //Default config path to weapon private _cfgPath = configFile >> "CfgWeapons" >> _weapon; //If the muzzle name is not the weapon name if !( _muzzle == _weapon ) then { //append muzzle name to weapons config path _cfgPath = _cfgPath >> _muzzle; }; //Return compare of muzzles cursor type to gl ( grenade launcher ) getText( _cfgPath >> "cursorAim" ) == "gl" }; _fnc_getNumberOfMuzzleMags = { params[ "_unit", [ "_includeLoaded", false ], "_magName", "_storedIn", "_muzzle", "_weapon" ]; //If we have not specified a specific weapon to check if ( isNil "_weapon" ) then { //Get units current weapon _weapon = currentWeapon _unit; }; //If we have a weapon if ( _weapon != "" ) exitWith { //Get weapons config path private _cfgPath = configFile >> "CfgWeapons" >> _weapon; //Get weapons available muzzles ( sorted ) private _muzzles = getArray( _cfgPath >> "muzzles" ) apply { //If muzzle is called 'this' _muzzleName = if ( _x == "this" ) then { //Then the muzle name is the weapon name _weapon }else{ //Else its the name stored in config _x }; //If have not specified a specific muzzle OR its is the muzzle specified if ( isNil "_muzzle" || { _muzzle == _muzzleName } ) then { //If the name is the weapon name then return default path if ( _muzzleName == _weapon ) then { _cfgPath }else{ //Else return muzzle path _cfgPath >> _muzzleName }; }else{ //Else return null objNull }; }; //Remove an null entries _muzzles = _muzzles - [ objNull ]; //Private some variables defaulted to [] [] params[ [ "_mags", [] ], [ "_counts", [] ] ]; //Get a full list of magazines the unit has private _magazines = magazinesAmmoFull _unit; //For each of our sorted muzzle paths { _muzzlePath = _x; //Get the muzzles name private _muzzleName = configName _muzzlePath; //Store an array of compatible magazines for this muzzle private _nul = _mags pushBack getArray( _muzzlePath >> "magazines" ); //Push a empty array ready to hold magazines counts private _index = _counts pushBack []; //For each compatible magazine { _x params[ "_magazine" ]; //If we have not specified a magazine type OR it is the specified magazine private _numSortedMags = if ( isNil "_magName" || { _magName == _magazine } ) then { //Count the number of magazines that... count ( _magazines select { _x params[ "_name", "", "_loaded", "", "_location" ]; //Matches.. the current compatible muzzle magazine AND specified Loaded AND specified Stored In _name == _magazine && ( !_loaded || { _loaded && _includeLoaded } ) && ( isNil "_storedIn" || { _storedIn == _location } ) } ) }else{ //Otherwise just return none 0 }; //Store the count private _nul = ( _counts select _index ) pushBack _numSortedMags; }forEach ( _mags select _forEachIndex ); }forEach _muzzles; //Return array of.. [ _muzzles, _mags, _counts ] }; //Otherwise there was none, return empty arrays [ [], [], [] ] }; private _isUsingGL = player call _fnc_isUsingGL; private _text = format[ "Current Weapon = %1\nCurrent Muzzle = %2\nUsing GL = %3\n\n", currentWeapon player, currentMuzzle player, _isUsingGL ]; { _x params[ "_loaded", "_storedIn" ]; //Get current magazines as specified //[ unit, ( optional )include loaded, ( optional )magazine name, ( optional )stored in, ( optional )muzzle, ( optional )weapon ] [ player, _loaded, nil, _storedIn, currentMuzzle player, currentWeapon player ] call _fnc_getNumberOfMuzzleMags params[ "_muzzles", "_mags", "_counts" ]; //Format data into hint _text = format[ "%1\n%2:\n", _text, [ _storedIn, "Total - including weapon loaded" ] select isNil "_storedIn" ]; { private _muzzlePath = _x; private _muzzleIndex = _forEachIndex; { private _magCount = _counts select _muzzleIndex select _forEachIndex; if ( _magCount > 0 ) then { //_text = format[ "%1%2:\n", _text, configName _muzzlePath ]; _text = format[ "%1 %2 - %3\n", _text, getText( configFile >> "CfgMagazines" >> _x >> "displayName" ) , _counts select _muzzleIndex select _forEachIndex ]; }; }forEach ( _mags select _muzzleIndex ); }forEach _muzzles; }forEach [ [ false, "uniform" ], [ false, "vest" ], [ false, "backpack" ], [ true, nil ] ]; hint _text; Place in the debug console and run, change weapon mode(muzzle) and loadout configuration to see results 1 Share this post Link to post Share on other sites
dyrmoon 22 Posted January 22, 2018 You are a magician. It works perfectly. Thank you very much. Share this post Link to post Share on other sites
johnnyboy 3742 Posted January 22, 2018 On 1/20/2018 at 7:14 PM, Larrow said: as a quick example Awesome post Mr. Larrow. The comments are much appreciated. This is perfect for anyone who want to learn how to navigate configs, search text, parse text, etc. 1 Share this post Link to post Share on other sites
dyrmoon 22 Posted January 22, 2018 Yes, he is professional. Added comments is very great. We can learn a lot from it. Thank's Larrow. 1 Share this post Link to post Share on other sites