I wrote a function for use with the "fired" event handler that checks if a flare or other kind of signal projectile had been fired. The function works well, but I can't get it to return a value for the life of me.
Maybe it's something stupid with the function:private ["_shooter", "_weapon", "_muzzle", "_firemode", "_ammo", "_return_val", "_fired_flare"];
_ammo = (_this select 0) select 4;
_fired_flare = "false";
if(_ammo == "Flare" || _ammo == "FlareRed" || _ammo == "JAM_MarkerGrenadeammo") then {
_fired_flare = "true";
};
_fired_flare
Note, no semicolon on that last line. I originally added the handler in the "init=" line for the units in the mission.sqs file. I moved it out into the Init.sqs file. Assuming I have a player with text=Rescue1, this is what I put in Init.sqs:Rescue1 addEventHandler ["fired", { _marker_fired = [_this] call fired_marker, _marker_shooter=_this select 4 }]
When run, _marker_fired never changes state with the function. I checked with some hint statements and found _fired_flare would be set to "true," and then _marker_flare would subsequently come up as "false."
I read about the "format[]" trick, but it doesn't seem to work. Specifically, I tried:Rescue1 addEventHandler ["fired", format[{ _marker_fired = [_this] call fired_marker, _marker_shooter=_this select 4 }]]
So I'm at the end of my rope here, having blown off 3 hours on this. What do I do?