Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do i play music on a level?
oscar1007 Offline
Member

Posts: 64
Threads: 24
Joined: Oct 2011
Reputation: 0
#1
How do i play music on a level?

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!

Money can't buy you happiness. But I rather cry in my ferrari.

PROJECT:
http://www.moddb.com/mods/oscar1007
10-03-2011, 09:28 AM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#2
RE: How do i play music on a level?

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
Website Find
oscar1007 Offline
Member

Posts: 64
Threads: 24
Joined: Oct 2011
Reputation: 0
#3
RE: How do i play music on a level?

(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!

Money can't buy you happiness. But I rather cry in my ferrari.

PROJECT:
http://www.moddb.com/mods/oscar1007
10-03-2011, 09:36 AM
Find
Gamemakingdude Offline
Senior Member

Posts: 470
Threads: 82
Joined: Nov 2010
Reputation: 9
#4
RE: How do i play music on a level?

Do you have a function for when you want to play the music?

Rep if like me or im helpful or you love my stories!
Stephanos house
10-03-2011, 09:59 AM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#5
RE: How do i play music on a level?

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);

10-03-2011, 10:01 AM
Website Find
oscar1007 Offline
Member

Posts: 64
Threads: 24
Joined: Oct 2011
Reputation: 0
#6
RE: How do i play music on a level?

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()
{
}

Money can't buy you happiness. But I rather cry in my ferrari.

PROJECT:
http://www.moddb.com/mods/oscar1007
10-03-2011, 11:23 AM
Find
oscar1007 Offline
Member

Posts: 64
Threads: 24
Joined: Oct 2011
Reputation: 0
#7
RE: How do i play music on a level?

someone?

Money can't buy you happiness. But I rather cry in my ferrari.

PROJECT:
http://www.moddb.com/mods/oscar1007
10-03-2011, 03:24 PM
Find
Obliviator27 Offline
Posting Freak

Posts: 792
Threads: 10
Joined: Jul 2011
Reputation: 66
#8
RE: How do i play music on a level?

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
Find
oscar1007 Offline
Member

Posts: 64
Threads: 24
Joined: Oct 2011
Reputation: 0
#9
RE: How do i play music on a level?

(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.

Money can't buy you happiness. But I rather cry in my ferrari.

PROJECT:
http://www.moddb.com/mods/oscar1007
(This post was last modified: 10-03-2011, 04:03 PM by oscar1007.)
10-03-2011, 03:59 PM
Find
Prelauncher Offline
Senior Member

Posts: 451
Threads: 11
Joined: May 2011
Reputation: 13
#10
RE: How do i play music on a level?

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);
}

Socialism (noun): A great way to run out of other people's money.
10-03-2011, 05:11 PM
Find




Users browsing this thread: 1 Guest(s)