Frictional Games Forum (read-only)

Full Version: How do i play music on a level?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Yes i have tried many times but it just doens't seem to work.
Can someone here please tell me how to script the thing?

Thanks!
void PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);

Plays music.

asMusicFile - the music to play + extension .ogg
abLoop - determines whether a music track should loop
afVolume - volume of the music
afFadeTime - time in seconds until music reaches full volume
alPrio - priority of the music. Note that only the music with the highest priority can be heard! 0 - highest, 1 - lower, etc

Simply:
PlayMusic("some_music", true or false, any float number, any float number, priority number higher is prior, true or false);

For this and more: http://wiki.frictionalgames.com/hpl2/amn..._functions
(10-03-2011, 09:31 AM)Tanshaydar Wrote: [ -> ]void PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);

Plays music.

asMusicFile - the music to play + extension .ogg
abLoop - determines whether a music track should loop
afVolume - volume of the music
afFadeTime - time in seconds until music reaches full volume
alPrio - priority of the music. Note that only the music with the highest priority can be heard! 0 - highest, 1 - lower, etc

Simply:
PlayMusic("some_music", true or false, any float number, any float number, priority number higher is prior, true or false);

For this and more: http://wiki.frictionalgames.com/hpl2/amn..._functions
I'm kind of new to scripting just so you know. so where do i insert: "void PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);"
?
If you could display an example of this script that would be great!
Sorry to bother you guys with these "noob" problems. like i said before. Im new to this.

Thanks again!
Do you have a function for when you want to play the music?
Erm, starting from here will be helpful I think.
http://wiki.frictionalgames.com/hpl2/start

An example for that could be this:
PlayMusic("entranc", true, 1, 5, 1, true);
So if you would type that down below, how would it look?

Sorry about the weird insert. im new to this forum.

////////////////////////////
// Run first time starting map
void OnStart()
{
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}

////////////////////////////
// Run when leaving map
void OnLeave()
{
}
someone?
You would want to put it into your OnStart function. So...

void OnStart()
{
PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);
}
(10-03-2011, 03:40 PM)Obliviator27 Wrote: [ -> ]You would want to put it into your OnStart function. So...

void OnStart()
{
PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);
}
Thank you!
One more question. how much volume should i set it at?



nevermind. i will just try stuff out.
If you want the music to just play in sertain areas in your map, create a script area so when the player enters the music start



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


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