I'm working on a dynamic infinite ammo script.
I don't want to add parameters or so, you can determine the ammo type via a "fired" eventhandler, transport the ammotype to a script that checks the ammo and add that magazine type again.
It goes like this, put this in the init :
this addeventhandler ["fired",{_this exec "fired.sqs"}]
The fired script
_unit = _this select 0
_muzzle = _this select 2
[_unit,_muzzle] exec "addmag.sqs"
_unit removealleventhandlers "fired"
exit
the addmag script
_unit = _this select 0
_ammo = _this select 1
#L
?!alive _unit : exit
?_unit ammo _ammo < 1 :goto "R"
~2
goto "L"
#R
_unit addmagazine _ammo
~1
goto "L"
The problem is that the fired script only checks one ammotype ,When the unit switches to grenades, law or handgun , the script fails.
What can be done to make this work?