Jump to content
Sign in to follow this  
jamez_5

Sound when hit

Recommended Posts

Hey guys. I am trying to do two things. I am making a shooting range and when somebody shoots the target(s) I a noise go off and a hint message to appear. 

 

And instead of making two post I would also like for that AI to respawn. Is it possible to make AI respawn without extra sqt files? I know you can make vehicles respawn with just a module placed down and synced. 

Share this post


Link to post
Share on other sites

I know we have an Eisenstein in this community who can figure this out. 

Share this post


Link to post
Share on other sites
On 6/1/2017 at 10:03 AM, jamez_5 said:

Hey guys. I am trying to do two things. I am making a shooting range and when somebody shoots the target(s) I a noise go off and a hint message to appear. 

 

And instead of making two post I would also like for that AI to respawn. Is it possible to make AI respawn without extra sqt files? I know you can make vehicles respawn with just a module placed down and synced. 

I can't help you with part 2, but for part 1 you should look at adding a "hit" eventhandler to your target. You can script it to do pretty much anything when the target is hit.

 

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Hit

Share this post


Link to post
Share on other sites

Thank you; however, I found this page before and still didnt understand what my code line should look like? Mind showing me?

Share this post


Link to post
Share on other sites

Put this in the init field of your target:

this addEventHandler ["Hit",{playSound "Alarm"}];

 

 

Keep in mind that the code of the eventhandler is only executed locally to the object it was assigned to. Meaning, no other player will hear the sound. If you have further questions, feel free to make a thread here

 

https://forums.bistudio.com/forums/forum/154-arma-3-mission-editing-scripting/

Share this post


Link to post
Share on other sites

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.

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
Sign in to follow this  

×