Jump to content
AgentRev

Execute code when unit reloads weapon

Recommended Posts

31 minutes ago, Larrow said:

Use magazinesAmmoFull instead, and just look for the mag that is in the units current muzzle that is being used to fire?

Very slick my Meat Hula Hoop consuming friend.  Thanks alot! 

 

Thanks much to @ZaellixA and @Dedmen also.  I think I'm opting for Larrow's solution as it may be more reliable than relying on string elements present for every magazine.

  • Like 2
  • Haha 1

Share this post


Link to post
Share on other sites

Well, apparently there is a really easy way to do it. Thanks to @LarrowI found out that you can actually use weaponState to get the current ammo count. The last element of the returned variables is the ammoCount. So in the same way Larrow showed above you can

_myUnit addEventHandler["FiredMan", {
	_unit = _this select 0; // Get the unit who fired
	_numOfBullets = (weaponState _unit) select 4; // Get the amount of bullets left in the magazine
	if(_numOfBullets isEqualTo 0) then {
		systemChat "Reloading..."; // Start screaming
	} else {
		systemChat "Still plenty to shoot..."; // Keep shooting
	};
}];

Thanks Larrow for pointing to the right direction.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
18 minutes ago, ZaellixA said:

Well, apparently there is a really easy way to do it. Thanks to @LarrowI found out that you can actually use weaponState to get the current ammo count. The last element of the returned variables is the ammoCount. So in the same way Larrow showed above you can

Even cleaner.  Now I'm opting for this one lol.  Great job by all.

  • Haha 1

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

×