Frictional Games Forum (read-only)

Full Version: Music in a certain area
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ok i need some help with music in a certain area. I have a big hall called castle halls which i want to have the soothing music while you are in this big hall. But the thing is it has many doors and level doors so im wondering how to make the music sound just in that hall.

Sorry for the nooby question :3
I think there was a Sound space. On the line where you can also pick entities and stuff.

Sorry i cannot tell more, I never used it.
If i get you correctly make a script and name it like "play_music_hall"
Then make a script with the function:

Code:
PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);
(05-28-2011, 08:57 PM)xtron Wrote: [ -> ]If i get you correctly make a script and name it like "play_music_hall"
Then make a script with the function:

Code:
PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);

Thank you! :3
Your welcome bud ^^
You can use scripted collisions to control the music. Create an area that is as wide and long (height will not matter, as long as the player will walk through it) as the giant hall you are speaking of. Let's say you call it "grand_hall_area". In your OnStart() function put this:

AddEntityCollideCallback("Player", "grand_hall_area", "MusicControl", false, 0);


Then create the MusicControl function like this:

void MusicControl(string &in asParent, string &in asChild, int alState)
{
if(alState == 1) PlayMusic("soothingmusicfile.ogg", true, 1.0f, 0, 0, true);
if(alState == -1) StopMusic(0, 2);
}

This way, whenever the player enters the area (when alState is 1), the music will begin. When the player exits the area (alState is -1), the music will stop with a fade time of two seconds.
(05-29-2011, 10:28 AM)palistov Wrote: [ -> ]You can use scripted collisions to control the music. Create an area that is as wide and long (height will not matter, as long as the player will walk through it) as the giant hall you are speaking of. Let's say you call it "grand_hall_area". In your OnStart() function put this:

AddEntityCollideCallback("Player", "grand_hall_area", "MusicControl", false, 0);


Then create the MusicControl function like this:

void MusicControl(string &in asParent, string &in asChild, int alState)
{
if(alState == 1) PlayMusic("soothingmusicfile.ogg", true, 1.0f, 0, 0, true);
if(alState == -1) StopMusic(0, 2);
}

This way, whenever the player enters the area (when alState is 1), the music will begin. When the player exits the area (alState is -1), the music will stop with a fade time of two seconds.

Um for me it doesnt work, so im wondering if that is the whole script? Oh and ive changed the soothingmusicfile.ogg to amb_09safe
Did you create the grand_hall_area? Also, I mixed up the numbers in StopMusic :X sorry!

The whole script will look like this

void OnStart()
{
AddEntityCollideCallback("Player", "grand_hall_area", "MusicControl", false, 0);

//more of your stuff here
}


void MusicControl(string &in asParent, string &in asChild, int alState)
{
if(alState == 1) PlayMusic("soothingmusicfile.ogg", true, 1.0f, 0, 0, true);
if(alState == -1) StopMusic(2, 0);
}