I am creating a shoot house for CQB training. I am using a Popup target script and would like to add to it so that it plays a sound when certain popup targets are hit. IE the Civ or HVT targets. Revo's Code worked fine until i reset the targets which removes the Eventhandler "hit". Below is the reset code.
params [["_dist",50,[1]],["_center",player,[objNull]]]; //in params
_targets = nearestObjects [position _center, ["TargetBase"], _dist]; //take all nearby practice targets
if (count _targets < 1) exitWith {
systemChat "No compatible targets were found."; //exit if no targets have been found
};
{_x animate ["Terc",0];} forEach _targets; //get all targets to upright pos
{_x addEventHandler ["HIT", { //add EH
(_this select 0) animate ["Terc",1]; //if hit, get to the ground
(_this select 0) RemoveEventHandler ["HIT",0]; //remove EH
}
]} forEach _targets;
I am sure it's simple but I can't figure it out. I thought to use
if ((_targets iskindof "TargetP_Civ_f") or (_targets iskindof "TargetP_Civ2_f")) then {playSound "Alarm"};
But it didn't seem to work. I am not a scripter but I can usually pick someone else's hard work apart and adapt it to my needs. This one has me stumped.