Jump to content
Rawshark

Sound triggers on MP server

Recommended Posts

So basically I am trying to setup a trigger based sound loop for an upcoming multiplayer mission. I have converted my audio file from mp3 to .ogg and have placed it in a 'sounds' folder within the Arma 3 mission folder. I have also setup the 'description.ext' file with the following script:

class CfgSounds 
{
	sounds[] = {}; 
	class ambient1 
	{
		name = "ambient1"; 
		sound[] = {"\sounds\ambient1.ogg", 15, 1}; 
		titles[] = {};
	};
};

 

Within the trigger, which is set to trigger on the presence of BLUFOR in the trigger area I have the following in the init field:

nul = [thisTrigger] spawn {while {true} do {(_this select 0) say3D "spooky1"; sleep 150;};};

As far as I can tell, this does seem to get the job done when testing in the editor..but I have a few issues.

 

1) I don't know if this only executes locally and so would go unnoticed by other players? Would it be better to initialise the trigger as:

 

[thisTrigger, ["ambient1", 15, 1]] remoteExec ["say3d", 0, true];

 

to get everyone else to hear the sound as well?

 

and 2) When testing the sound, it seems to originate from the centre of the trigger as opposed to uniformly within the area of the trigger, as in, the sound gets louder when you approach where the centre of the trigger zone would be and fades away as you proceed further away from it. In my particular case though I want the sound to be at a consistent level throughout the trigger area and cant seem to tweak that in the coding. Does anyone have any advice on the matter?

 

Edit: I should add I am running ACE and don't know if that is/would effect anything.

Share this post


Link to post
Share on other sites
11 minutes ago, Rawshark said:

1) I don't know if this only executes locally and so would go unnoticed by other players? Would it be better to initialise the trigger as:

It will execute wherever the trigger is activated, if your condition is any player present, it will execute everywhere. No need to RemoteExec

 

12 minutes ago, Rawshark said:

2) When testing the sound, it seems to originate from the centre of the trigger as opposed to uniformly within the area of the trigger, as in, the sound gets louder when you approach where the centre of the trigger zone would be and fades away as you proceed further away from it. In my particular case though I want the sound to be at a consistent level throughout the trigger area and cant seem to tweak that in the coding.

That's what say3D does, use playSound instead, but you will have to make sure it only executes if the player is in the triggerArea or elese everyone on the server will hear it.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the reply. So if the trigger is set to activation type 'BLUFOR present' with the init: 

playSound "ambient1"

That should mean that player(s) within the trigger hear the sound, and not everyone on the server? 

Also, if I wanted to loop a 90second soundclip, do I just modify the init as
 

playSound "ambient1", sleep 90;

 

Share this post


Link to post
Share on other sites
6 minutes ago, Rawshark said:

Thanks for the reply. So if the trigger is set to activation type 'BLUFOR present' with the init: 


playSound "ambient1"

That should mean that player(s) within the trigger hear the sound, and not everyone on the server? 

Will play for everyone on the server.
should be
 

if (player inArea thisTrigger) then {
playSound "ambient1"
};

 

  • Like 1

Share this post


Link to post
Share on other sites
12 minutes ago, Rawshark said:

Also, if I wanted to loop a 90second soundclip, do I just modify the init as
 


playSound "ambient1", sleep 90;

No.
 

thisTrigger spawn {
if !(player inArea _this) exitwith{};
while {player inArea _this}do 
	{
      playSound "ambient1"
      sleep 90;
	};
};

 

Share this post


Link to post
Share on other sites

Thank you, that is pretty much what I have been after!

Share this post


Link to post
Share on other sites

Be careful I'd made a mistake in the code and edited it, make  sure you use the latest if you've copied it before posting

 

Share this post


Link to post
Share on other sites
1 minute ago, Mr H. said:

Be careful I'd made a mistake in the code and edited it, make  sure you use the latest if you've copied it before posting

 

 Cheers, I'll try the updated one in the editor now. One last thing, if I may, I assume that this would all be identical if it was a music track instead..only changing cfgsound to cfgmusic and in the trigger changing playSound with playMusic. Just wanted to check there wasn't any extra steps with the latter.

Thanks again for the help! 👍

Share this post


Link to post
Share on other sites
9 minutes ago, Rawshark said:

 Cheers, I'll try the updated one in the editor now. One last thing, if I may, I assume that this would all be identical if it was a music track instead..only changing cfgsound to cfgmusic and in the trigger changing playSound with playMusic. Just wanted to check there wasn't any extra steps with the latter.

Same thing indeed

  • Like 1

Share this post


Link to post
Share on other sites
29 minutes ago, Mr H. said:

 


thisTrigger spawn {
if !(player inArea _this) exitwith{};
while {player inArea _this}do 
	{
      playSound "ambient1"
      sleep 90;
	};
};

 

 

So I entered the code as is into the trigger activation and I get this error (https://imgur.com/DIB1mV6)..it says I am missing a ";" 

Edit: Nvm, the PlaySound "ambient1" needed the ";" at the end. All sorted, thanks for the help!

  • Thanks 1

Share this post


Link to post
Share on other sites
16 minutes ago, Rawshark said:

 

So I entered the code as is into the trigger activation and I get this error (https://imgur.com/DIB1mV6)..it says I am missing a ";" 

Edit: Nvm, the PlaySound "ambient1" needed the ";" at the end. All sorted, thanks for the help!

Indeed! My mistake sorry

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

×