mr_shadow 4 Posted January 8, 2015 Hello, I would like to make a script which will add the magazins for both of the guns of the player. Im gonna use it in redress script, so person will not loose his inventory. Thats what Im trying to do, but it doesnt work, mthere is not much info about such requset. _mags = magazines player; _mags1 = _mags select 0; player addMagazine _mags; Share this post Link to post Share on other sites
Jona33 51 Posted January 8, 2015 _mags = magazines player; _mags1 = _mags select 0; {player addMagazine _x} forEach _Magazines (I assume _mags1 is for something else) Share this post Link to post Share on other sites
mr_shadow 4 Posted January 8, 2015 Thanks a lot, works perfect. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted January 8, 2015 You could also use: [player,currentweapon player,1] call BIS_fnc_addWeapon; will check if the unit already has the weapon and just add the amount of magazines specified in the third parameter, all in only one line instead of three. Share this post Link to post Share on other sites
Larrow 2803 Posted January 8, 2015 (edited) The above magazines player will not work if the player does not already have some of the magazine type in his inventory. These commands maybe handy primaryWeaponMagazine handgunMagazine secondaryWeaponMagazine As long as the player has not got rid of the last empty mag from his weapon then these commands should work ok. If the player currently has no mags in either his inventory or weapon then you can retrieve the type of magazine needed from each weapons config. getArray ( configfile >> "CfgWeapons" >> primaryWeapon player >> "magazines" ) select 0 example { if !( _x isEqualTo "" ) then { _defaultMag = getArray ( configfile >> "CfgWeapons" >> _x >> "magazines" ) select 0; player addMagazine _defaultMag; }; }forEach [ primaryWeapon player, handgunWeapon player, secondaryWeapon player ]; The above will add one magazine for each primary, secondary and handgun weapon the player current has no matter the current status of mags from the inventory or weapon itself. For multiple muzzle weapons like a rifle with a UGL { _gunType = _x; if !( _gunType isEqualTo "" ) then { _baseCfg = ( configfile >> "CfgWeapons" >> _gunType ); _muzzles = getArray ( _baseCfg >> "muzzles" ); { _muzzle = _x; _defaultMag = ""; if ( _muzzle isEqualTo "this" ) then{ _defaultMag = getArray ( _baseCfg >> "magazines" ) select 0; }else{ _defaultMag = getArray ( _baseCfg >> _muzzle >> "magazines" ) select 0; }; player addMagazine _defaultMag; }forEach _muzzles; }; }forEach [ primaryWeapon player, handgunWeapon player, secondaryWeapon player ]; Edited January 8, 2015 by Larrow Share this post Link to post Share on other sites