Equil
Member
Posts: 94
Threads: 8
Joined: Sep 2010
Reputation:
0
|
Scripting multiple levels help
I couldn't find any other threads about this so the solution to this problem is probably painfully obvious. I already have two maps with working level doors working fine, I can move through both the levels without problems.
However, I want the music to change between the two levels, so I made a script for each map. Here is what I have:
Map 1:
////////////////////////////
// Run when entering map
void OnEnter()
{
PlayMusic("12_amb.ogg", true, 1.0f, 0, 0, true);
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
StopMusic(5.0, 0);
}
Map 2:
////////////////////////////
// Run when entering map
void OnEnter()
{
PlayMusic("08_amb.ogg", true, 1.0f, 3, 0, true);
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
StopMusic(5.0, 0);
}
Once I enter Map2, the music stops, but the new music doesn't play. It DOES play if I re-enter Map1, so I tried using different music files and double checking the code, but it seems to be correct. Any help with this is much appreciated.
|
|
01-01-2011, 04:29 AM |
|
xiphirx
Senior Member
Posts: 662
Threads: 16
Joined: Nov 2010
Reputation:
5
|
RE: Scripting multiple levels help
You might want to stop the first music, then play the second.
|
|
01-01-2011, 04:48 AM |
|
Equil
Member
Posts: 94
Threads: 8
Joined: Sep 2010
Reputation:
0
|
RE: Scripting multiple levels help
I do have the function StopMusic(5.0, 0); in the OnLeave() section of the first map, which works. The problem is the music not starting on the second map. Do I have the function in the wrong place?
|
|
01-01-2011, 04:52 AM |
|
xiphirx
Senior Member
Posts: 662
Threads: 16
Joined: Nov 2010
Reputation:
5
|
RE: Scripting multiple levels help
PlayMusic("08_amb.ogg", true, 1.0f, 3, 0, true);
void PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);
You indicated fadeTime in this one... Try removing the fade time.
|
|
01-01-2011, 05:01 AM |
|
Equil
Member
Posts: 94
Threads: 8
Joined: Sep 2010
Reputation:
0
|
RE: Scripting multiple levels help
Quote:Code:
PlayMusic("08_amb.ogg", true, 1.0f, 3, 0, true);
void PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);
You indicated fadeTime in this one... Try removing the fade time.
I tried what you said.. no luck. So I tried messing around with it, I loaded the map directly, still no music. However, a debug message does appear saying:
Saving check point_auto music: "
Maybe there's something wrong with my script? This is the entire I script I have for Map 2:
////////////////////////////
// Run first time starting map
void OnStart()
{
}
////////////////////////////
// Run when entering map
void OnEnter()
{
PlayMusic("08_amb.ogg", true, 1.0f, 0, 0, true);
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
StopMusic(5.0, 0);
}
|
|
01-01-2011, 05:14 AM |
|
xiphirx
Senior Member
Posts: 662
Threads: 16
Joined: Nov 2010
Reputation:
5
|
RE: Scripting multiple levels help
I'm sorry, I haven't started scripting yet so I couldn't tell you...
Does it work when you put it in onStart?
|
|
01-01-2011, 05:18 AM |
|
Equil
Member
Posts: 94
Threads: 8
Joined: Sep 2010
Reputation:
0
|
RE: Scripting multiple levels help
Nope.. still nothing. Can anyone script savvy come in here and help?
|
|
01-01-2011, 07:06 AM |
|
ModManDann
Member
Posts: 61
Threads: 6
Joined: Dec 2010
Reputation:
0
|
RE: Scripting multiple levels help
In my knowledge the last played music automatically stops if you start a new one. Try removing the stop music function
Edit:
or try
(This post was last modified: 01-01-2011, 03:07 PM by ModManDann.)
|
|
01-01-2011, 02:34 PM |
|
Equil
Member
Posts: 94
Threads: 8
Joined: Sep 2010
Reputation:
0
|
RE: Scripting multiple levels help
*headdesk* .. I'm really sorry for troubling you guys, turned out to be a small typo problem in my .hps file. It had a ".map" at the end of it's name, working fine now after I removed it. How embarrassing.
Sorry for the trouble, appreciate the all the help anyway, thanks.
|
|
01-01-2011, 04:03 PM |
|
Frontcannon
Senior Member
Posts: 538
Threads: 10
Joined: Jul 2010
Reputation:
2
|
RE: Scripting multiple levels help
That's where AddDebugMessage helps you.. you'd have known that your script file didn't work!
╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
|
|
01-01-2011, 05:37 PM |
|
|