Jump to content
HazJ

Backpack location with magazinesAmmoFull

Recommended Posts

Hi all,

I am a little stuck. Basically, I am looping through all magazines and checking if in backpack, if so, push to array with classname and count. The issue is that the location doesn't appear to work. It always returns the current muzzle but it shouldn't? At least not on every loop since there is only one mag in the weapon. it is a bit messy atm as just trying to get it working:

				{
					hintSilent str _x;
					if ((_x select 4) isEqualTo "Backpack" && !(_x select 2)) then
					{
						_bpMagazines pushBack [(_x select 0), (_x select 1)];
					};
				} forEach (magazinesAmmoFull _unit);

I am aware of backpackMagazines command but the format is weird and I also need to get the actual ammo count, not total mags. When I remove the magazine from the weapon, it works just fine. What am I missing? Surely it should re-check the location of the magazine per loop through? Any help would be great.

 

EDIT: It works if I just output the command but when using a forEach loop, it doesn't. No idea why.

Share this post


Link to post
Share on other sites

Sorry I forgot the ammo count.

Anyway, the code works and  there is no reason to fail in a loop. Some CPU heavy load and 3ms scheduler overshoot?

 

 

 

 

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

No problem, all good heh. It is weird. Each loop output returns the current weapon muzzle. I am doing this inside InventoryClosed EH before the delete part.

 

Share this post


Link to post
Share on other sites

Okay so when using diag_log it test output, it shows the correct results on each loop through. Weird? It doesn't work as a condition?

4:27:47 [["30Rnd_9x21_Mag_SMG_02",30,false,-1,"Uniform"],["30Rnd_9x21_Mag_SMG_02",30,false,-1,"Uniform"],["30Rnd_9x21_Mag_SMG_02",30,false,-1,"Uniform"],["30Rnd_9x21_Mag_SMG_02",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02_Tracer_Red",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02_Tracer_Red",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02_Tracer_Red",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02_Tracer_Red",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02_Tracer_Red",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02_Tracer_Red",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02_Tracer_Red",30,false,-1,"Backpack"],["30Rnd_9x21_Mag_SMG_02_Tracer_Red",30,false,-1,"Backpack"],["30Rn
				{
					diag_log magazinesAmmoFull player apply {[_x select 0, _x select 4]}; // returns correct output to RPT
					if ((_x select 4) isEqualTo "Backpack" && !(_x select 2)) then // this all runs fine
					{
						hintSilent "Push magazine and ammo count to the _bpMagazines array";
						_bpMagazines pushBack [(_x select 0), (_x select 1)];
					};
				} forEach (magazinesAmmoFull _unit);
4:32:58 ":: MAGAZINES :: [[""30Rnd_9x21_Mag_SMG_02"",30],[""30Rnd_9x21_Mag_SMG_02"",30],[""30Rnd_9x21_Mag_SMG_02_Tracer_Red"",30],[""30Rnd_9x21_Mag_SMG_02_Tracer_Red"",30],[""30Rnd_9x21_Mag_SMG_02"",30],[""30Rnd_9x21_Mag_SMG_02"",30],[""30Rnd_9x21_Mag_SMG_02_Tracer_Red"",30],[""30Rnd_9x21_Mag_SMG_02_Tracer_Red"",30],[""30Rnd_9x21_Mag_SMG_02"",30],[""30Rnd_9x21_Mag_SMG_02"",30],[""30Rnd_9x21_Mag_SMG_02_Tracer_Red"",30],[""30Rnd_9x21_Mag_SMG_02_Tracer_Red"",30],[""30Rnd_9x21_Mag_SMG_02"",30],[""30Rnd_9x21_Mag_SMG_02"",30],[""30Rnd_9x21_Mag_SMG_02_Tracer_Red"",30],[""30Rnd_9x21_Mag_SMG_02_Tracer_Red"",30]]"

Using the hintSilent command only gave current muzzle on each loop through. The problem isn't with magazinesAmmoFull command. Too many elements are being added when shouldn't. I will be able to resolve it from here. It would of been easier if the hintSilent command returned the correct output like diag_log did in the first place.

Share this post


Link to post
Share on other sites

Anyway, hint crush each other in a loop. You will see the last only.

  • Like 1

Share this post


Link to post
Share on other sites
14 hours ago, pierremgi said:

Anyway, hint crush each other in a loop. You will see the last only.

Yeah... I just (after your post) realised that I had no sleep in there... LOL!

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

×