Jump to content
Sign in to follow this  
mr_shadow

Add same magazine as used for player

Recommended Posts

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

_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

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

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 by Larrow

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×