Jump to content
ryansoper

Script won't add magazines? But will add weapon!

Recommended Posts

Hi guys,

 

I'm currently trying to write part of a larger script and this bit should spawn a gunman and then arm him with 1 of three weapons depending on the roll, and then it will give him three mags for that gun. In testing the gun will be added to the inventory, and the hint inside the ifs for the magazines is displayed, it just won't actually add the magazines.

_weaponArray = ["hgun_Pistol_heavy_01_F", "hgun_PDW2000_F", "srifle_DMR_05_tan_f"];
			_weapon = selectRandom _weaponArray;
			_skill = random 1;
			hint format ["skill = %1", _gunmanPos];		
			_gunman = "criminal_1" createUnit [ getMarkerPos _gunmanPos, CriminalGroup, "gunman = this;"];
			removeAllWeapons gunman;
			gunman setSkill _skill;
			gunman addEventHandler ["MPKilled", {call FNC_CalloutConcluded;}];
			
			if (_weapon == "hgun_Pistol_heavy_01_F") then {
				hint "hgun_Pistol_heavy_01_F";
				gunman addMagazine "11Rnd_45ACP_Mag";
				gunman addMagazine "11Rnd_45ACP_Mag";
				gunman addMagazine "11Rnd_45ACP_Mag";
			};
			
			if (_weapon == "hgun_PDW2000_F") then {
				hint "hgun_PDW2000_F";
				gunman addMagazine "30Rnd_9x21_Mag";
				gunman addMagazine "30Rnd_9x21_Mag";
				gunman addMagazine "30Rnd_9x21_Mag";
			};
			
			if (_weapon == "srifle_DMR_05_tan_f") then {
				hint "srifle_DMR_05_tan_f";
				gunman addMagazine "10Rnd_93x64_DMR_05_Mag";
				gunman addMagazine "10Rnd_93x64_DMR_05_Mag";
				gunman addMagazine "10Rnd_93x64_DMR_05_Mag";
			};			
						
			gunman addWeapon _weapon;

Any ideas what might be going wrong? Let me know if you need more of the code, this is just a snippet that *should* deal with the weapon addition.

 

Ryan

Share this post


Link to post
Share on other sites

Try this with ur magazine type and ur needed magazine count because its the global syntax for that command:

player addMagazine ["30Rnd_556x45_STANAG", 15];

Share this post


Link to post
Share on other sites

Maybe there isn't enough space in the inventory for the magazines?

 

also you can replace

gunman addMagazine "30Rnd_9x21_Mag";
gunman addMagazine "30Rnd_9x21_Mag";
gunman addMagazine "30Rnd_9x21_Mag";

with

gunman addMagazines ["30Rnd_9x21_Mag", 3];

Share this post


Link to post
Share on other sites

Based on the code you've posted.

Replace

_weaponArray = ["hgun_Pistol_heavy_01_F", "hgun_PDW2000_F", "srifle_DMR_05_tan_f"];
            _weapon = selectRandom _weaponArray;

with this

_weapon = selectRandom ["hgun_Pistol_heavy_01_F", "hgun_PDW2000_F", "srifle_DMR_05_tan_f"];

and all this

            if (_weapon == "hgun_Pistol_heavy_01_F") then {
                hint "hgun_Pistol_heavy_01_F";
                gunman addMagazine "11Rnd_45ACP_Mag";
                gunman addMagazine "11Rnd_45ACP_Mag";
                gunman addMagazine "11Rnd_45ACP_Mag";
            };
            
            if (_weapon == "hgun_PDW2000_F") then {
                hint "hgun_PDW2000_F";
                gunman addMagazine "30Rnd_9x21_Mag";
                gunman addMagazine "30Rnd_9x21_Mag";
                gunman addMagazine "30Rnd_9x21_Mag";
            };
            
            if (_weapon == "srifle_DMR_05_tan_f") then {
                hint "srifle_DMR_05_tan_f";
                gunman addMagazine "10Rnd_93x64_DMR_05_Mag";
                gunman addMagazine "10Rnd_93x64_DMR_05_Mag";
                gunman addMagazine "10Rnd_93x64_DMR_05_Mag";
            };
           gunman addWeapon _weapon;

with this

[gunman ,_weapon,3] call BIS_fnc_addWeapon;


 

  • Like 2

Share this post


Link to post
Share on other sites

I had no idea this function even existed! Makes life much easier! Now lets see if it works!

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

×