colinm9991 20 Posted July 8, 2014 (edited) I'm looking to check the units magazines, get a count, delete the magazines and then re-add them. So far I have this _magazines = ["30Rnd_9x21_Mag","9Rnd_45ACP_Mag","16Rnd_9x21_Mag"]; _result = {_x in _magazines} count magazines player; hint format ["%1",_result]; The above returns a good count of the magazines, but I'm looking to add the magazines now from the magazine array and the returned number. At any given time, it should only add the magazines that the player actually has and not a random set; the _magazines array is the set of magazines I want it to count for and add. If the unit has 10 45ACP Magazines it deletes them, and re-adds them. If the unit has 5 45ACP Mags and 6 16RND 9x21 Mags, it deletes them and re-adds them as they were (5 45ACP & 6 16RND 9x21 Mags). Who can help? --Update-- I tried forEach for the count result, it adds only one magazine and not an actual count of magazines //Define Magazines & Count _magazines = ["30Rnd_9x21_Mag","9Rnd_45ACP_Mag","16Rnd_9x21_Mag","16Rnd_9x21_Mag"]; _result = {_x in _magazines} count magazines player; hint format["%1",_result]; //Add Magazines _pHandgun = handgunWeapon player; _clipH = (getArray (configFile >> "Cfgweapons" >> _pHandgun >> "magazines")) select 0; {player addMagazine _clipH} forEach [_result]; Edited July 8, 2014 by ColinM9991 Share this post Link to post Share on other sites
quantenfrik 10 Posted July 9, 2014 not sure if that's what you are looking for, but maybe could you use this? _magazine_names = magazines player; {player removeMagazine _x;} forEach _magazine_names; {player addmagazine _x;} forEach _magazine_names; It returns all the magazines a unit has, not just "30Rnd_9x21_Mag","9Rnd_45ACP_Mag","16Rnd_9x21_Mag", saves them in an array, deletes them, and readds them from the array. A strange bug I found though was that chemlights and smokeshells were heavily multiplying at the "magazines" command, in the end replacing all other mags so you only had like a 100 chemlights, so either don't use them at all or somehow remove them fromt the _magazines_names. It will also ignore how many bullets are left in a magazine, it will just give a fresh full one, and also ignore the magazine that is currently loaded in the weapon, but if you check the wiki I think there some commands to get these features in too if you need them. Share this post Link to post Share on other sites
colinm9991 20 Posted July 9, 2014 (edited) I have something here that now works, but it removes either all magazines, or one pistol mag if I replace the forEach with _pMags primarily because there is only one function in the array of _pMags. The final question is how would I delete all magazines and put the pistol magazines back with addMagazine with the correct number of magazines that the player initially had? _magsArr = ["16Rnd_9x21_Mag","30Rnd_9x21_Mag"]; _pMags = []; _magazine_names = magazines player; { if (_x in _magazine_names) then {_pMags set [count _pMags,_x]} } foreach _magsArr; hint format["%1",_pMags]; {player removeMagazine _x;} forEach _magazine_names; {player addmagazine _x;} forEach _magazine_names; Edited July 9, 2014 by ColinM9991 Share this post Link to post Share on other sites
colinm9991 20 Posted July 9, 2014 (edited) Another update; I now have this here which counts the player magazines and adds them in to an array. _magWeapVar = []; _magazine_names = magazines player; _magWeapVar set [(count _magWeapVarr), _magazine_names]; hint format["%1",_magWeapVar]; The only problem now is that the array goes like this [["30Rnd_9x21_Mag","30Rnd_9x21_Mag","16Rnd_9x21_Mag","16Rnd_9x21_Mag","16Rnd_9x21_Mag","16Rnd_9x21_Mag","30Rnd_9x21_Mag","16Rnd_9x21_Mag","16Rnd_9x21_Mag","30Rnd_9x21_Mag","30Rnd_9x21_Mag","30Rnd_9x21_Mag","30Rnd_9x21_Mag"]] This whole thing is just getting more annoying by the minute; is there a single way to remove SPECIFIC Magazines WITHOUT removing the rest of the magazines? It seems Bohemia added removeAllWeapons but only added functions to remove magazines if a person HAS a primary weapon (primaryWeaponMagazine). It would be nice if there was a feature to check if a person has NO primary weapon but has magazines for a primary weapon. --Update 2-- Solved _magWeapIll = ["30Rnd_65x39_caseless_mag"]; _magazine_names = magazines player; _magWeapFinal = _magazine_names - _magWeapIll; hint format["%1",_magWeapFinal]; removeAllWeapons player; { player addMagazine _x; } foreach _magWeapFinal; I always knew it was going to be something simple. Edited July 10, 2014 by ColinM9991 Share this post Link to post Share on other sites