Jump to content
Sign in to follow this  
Balschoiw

Eventhandler fired , attach sound to projectile

Recommended Posts

Hi !

I can detect that a d30 has fired a shot. Now I want to have a sound attached to the projectile that got fired. Is there any way this can be done with scripting only ? The sound should move along with the projectile. I guess I can´t use the projectile as a "speaker" as it´s no live unit and looping a speaker along the flightpath of the projectile will probably not work that good.

Any ideas ?

Share this post


Link to post
Share on other sites
Quote[/b] ] I guess I can´t use the projectile as a "speaker" as it´s no live unit and looping a speaker along the flightpath of the projectile will probably not work that good.

I thought the Say command would work with any object?

For anyone who is not familiar with what Balschoiw is doing, for a script only modification it could look something like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">This AddEventHandler ["Fired",{[_This Select 0,NearestObject [_This Select 0,_This Select 4] ExecVM "Script.sqs"}]

Will launch a script.

Script.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Gun=_This Select 0;

_Round=_This Select 1;

//Length of the sound sample in seconds

_SoundDuration=3;

WaitUntil

       {

_Round Say "MySound";

       Sleep _SoundDuration;

       !(Alive _Round)

       };

Share this post


Link to post
Share on other sites

The best part of the story is that I actually already have some empty objects as speakers in the mission... whistle.gif

I guess at some point I just have my confused 5 minutes while editing.

Thx for the code though thumbs-up.gif

I really need to get familiar with sqf, right now all scripts I do are still sqs confused_o.gif

Thx UNN

Edit: Some issues with the provided code.

I guess there´s an error in the Line for the init:

this AddEventHandler ["Fired",{[_This Select 0, NearestObject [_This Select 0,_This Select 4]] ExecVM "arisound.sqs"}]

Error solved but the result sounds very weird huh.gif

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  

×