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
Music problem?
Zypherzemus Offline
Member

Posts: 94
Threads: 7
Joined: Jul 2011
Reputation: 0
#1
Music problem?

Ok, I'm trying to set up music between 4 different levels, hub level playing one track in the beginning when you first enter the map, then once you leave to another level, it stops (This part is true) Heres the problem, once I leave the first level and go back to the hub level, the music from the first level continues to play, even though I put the "StopMusic" command in the "OnLeave" section on the .hps file for that particular map. and I wouldn't know how to play a different track once you re-enter the hub level, help?
(This post was last modified: 07-07-2011, 07:36 PM by Zypherzemus.)
07-06-2011, 05:00 AM
Find
Juby Away
Senior Member

Posts: 290
Threads: 2
Joined: May 2011
Reputation: 5
#2
RE: Music problem?

You want to place the PlayMusic action in the OnEnter function. For the StopMusic action, make sure the priority of it is set to 1. Like this "StopMusic(4, 1);"


Insanity. Static.
07-06-2011, 11:21 AM
Find
Zypherzemus Offline
Member

Posts: 94
Threads: 7
Joined: Jul 2011
Reputation: 0
#3
RE: Music problem?

(07-06-2011, 11:21 AM)Juby Wrote: You want to place the PlayMusic action in the OnEnter function. For the StopMusic action, make sure the priority of it is set to 1. Like this "StopMusic(4, 1);"

Here's the thing though, I have the hub level set up to where, when you walk into a script area, the music starts to play (When you first start the map that is). When I leave the map, the music stops, would the same thing work if I used a different track?

ex: You first start the map, you walk into a scripted area and music plays, you leave map (music stops) you re-enter the map but a different track plays right when you spawn.
07-06-2011, 05:37 PM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#4
RE: Music problem?

You may need to use a globalvar
Try greating a global.hps file (if your map doesn't already have one) and add the line:

void OnGameStart()
{
SetGlobalVarInt("name" , 0);
}

then you can create a line in your map .hps file, under void onleave(), which sets this globalvariable to 1.

Finally under void OnEnter() create a couple of if statements:
if (globalvar == 0) play "music1"
else if (globalvar == 1) play "music2"

This way will definately work, but there may be a more efficient way of doing it
Tongue

07-06-2011, 05:50 PM
Find
Zypherzemus Offline
Member

Posts: 94
Threads: 7
Joined: Jul 2011
Reputation: 0
#5
RE: Music problem?

Basic set up of an global.hps file?

//void OnGameStart()
{

}

void OnGameEnter()
{

}

void OnGameLeave()
{

}

right?
07-06-2011, 11:00 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#6
RE: Music problem?

No Game word is needed, where did you get that? It should be OnStart, OnEnter, OnLeave.

07-06-2011, 11:07 PM
Website Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#7
RE: Music problem?

he's talking about the global.hps file - as far as im aware you only need:
void OnGameStart()

I dont think the global file uses the other two

(This post was last modified: 07-06-2011, 11:18 PM by DRedshot.)
07-06-2011, 11:18 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#8
RE: Music problem?

Oh, for global.hps only an OnGameStart is needed, yes.

07-06-2011, 11:25 PM
Website Find
Zypherzemus Offline
Member

Posts: 94
Threads: 7
Joined: Jul 2011
Reputation: 0
#9
RE: Music problem?

(07-06-2011, 05:50 PM)DRedshot Wrote: You may need to use a globalvar
Try greating a global.hps file (if your map doesn't already have one) and add the line:

void OnGameStart()
{
SetGlobalVarInt("name" , 0);
}

then you can create a line in your map .hps file, under void onleave(), which sets this globalvariable to 1.

Finally under void OnEnter() create a couple of if statements:
if (globalvar == 0) play "music1"
else if (globalvar == 1) play "music2"

This way will definately work, but there may be a more efficient way of doing it
Tongue


one last thing, by "name" you mean?
and the line in the OnLeave would be?
and they're both on the same hps file right?
just making sure
(This post was last modified: 07-07-2011, 01:29 AM by Zypherzemus.)
07-07-2011, 01:28 AM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#10
RE: Music problem?

"name" can be anything you want, it is the name of your GlobalVarInt
the line OnLeave would be:
SetGlobalVarInt("name" , 1);
The code under OnEnter and the code under OnLeave are in the same .hps yes, but the code under OnGameStart is in the Global.hps

also, that code under OnEnter is simplified and would not work, it should be
if (GetGlobalInt("name") == 0)
{
PlayMusic("Music1", true , float , float , int , true);
}
else if (GetGlobalInt("name") == 0)
{
PlayMusic("Music2", true , float , float , int , true);
}

07-07-2011, 01:41 AM
Find




Users browsing this thread: 1 Guest(s)