Jump to content
Sign in to follow this  
frosties

Play sound with trigger?

Recommended Posts

Hello,

Is it possible to have a trigger that plays a sound when a player enters it?

Like say, 25 meters around a VIP you would hear "help me" or something like that?

Share this post


Link to post
Share on other sites

Try using the Say command rather than playsound. It will force the sound from the object that is saying it and affect the hearing direction of the player rather than just playing the sound globally.

You could also insert the code

(player distance VIP <= 25)

into the condition field of a trigger and you would not need a radius. This would allow you to make the VIP placement random and thus different for every restart. It will also allow you to place the VIP into a building on a higher level and the player would not activate the trigger until he/she is within 25 or whatever distance seems more appropriate of the VIP. A radius would allow the trigger to be tripped as soon as the player entered it's perimeter whether that be in the air or on the ground.

Good luck and happy editing!

Share this post


Link to post
Share on other sites

@savedbygrace

Well that sounded like a good idea.. but how do i use say commnad instead of playsound?

EDIT:

Like this:

player say ["wolf1", 100];

Share this post


Link to post
Share on other sites

VIP say "sound_file"

OR

VIP say ["sound_file",5]

if you have subtitles attached to your sound file in the description. That would only allow the subtitle to be displayed if the player was within 5 meters. Change it of course to your choosing.

If you really want to get dynamic, add multiple sound files that are played at specific distances. Perhaps a shouting "Help" at>>>

(player distance VIP >= 25) && (player distance VIP <= 35)

. A softer cry for help or grunt or something at>>>

(player distance VIP < 25) && (player distance VIP >= 10)

. Perhaps struggled breathing at>>>

(player distance VIP > 1) && (player distance VIP < 10)

. That would be three different Triggers. Or to eliminate the need for more triggers just execute a script when the player gets within a certain distance which loops and checks the distance and plays different sound files, exiting once the player reaches the VIP.

Just some thoughts. Not trying to make it complicated just mentioning possibilities.

Share this post


Link to post
Share on other sites

Cant get it to work...

When i get close to the VIP the trigger goes off.. but it says it cant find the file... ?

Share this post


Link to post
Share on other sites

My apologies, I thought you understood Carl Gustaffa above. (Thanks Janat)

In addition, your actual sound(the one you include to be used) must be placed into the mission folder. Most folks create a sound folder inside the mission folder and then place their sounds there. It helps to keep your mission folder organized. Make sure that the sound entry within the description.ext points to that folder. For example...

class CfgSounds
{                   this is the introductory bracket for the sounds class
sounds[] = {}; 
 class help1 //This begins a new sound class
 {              //This is needed to introduce the class
  name = "Frosties_Help1";   // What the sound is labeled as in a trigger (e.g. trigger effects)
  sound[] = {"[u]Sound\[/u]help1.ogg", 1, 1};   // filename, volume, pitch
  titles[] = {};//The text(subtitle) that will appear when the file is played.
 };            //This is needed to close the class
 class help2
 {
  name = "Frosties_Help2";   // What the sound is labeled as in a trigger (e.g. trigger effects)
  sound[] = {"[u]Sound\[/u]help2.ogg", 1, 1};   // filename, volume, pitch
  titles[] = {};//The text(subtitle) that will appear when the file is played.
 };               
};                  //this is the closing bracket for the Sounds class

The underlined text is the directory to where your sound is located. It can be as long as you like, named whatever you like as long as it is correct. For uniformity though, it's best to maintain some sort of standard that the community recognizes such as a simple "sound" folder.

The description.ext file is simply created with notepad and then saved as Description.ext. It also goes inside your mission folder.

Edited by savedbygrace

Share this post


Link to post
Share on other sites

oh, i did miss that part !

Got it to work now :) Thanks guys!

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  

×