Frictional Games Forum (read-only)
[SCRIPT] How to stop music playing? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] How to stop music playing? (/thread-16913.html)



How to stop music playing? - Chap - 07-12-2012

Hey,

I'm having a problem with my script to play music. I have six levels and in the first one, there's a script that starts music. When entering the second level, there is a script to stop music.

The code is as follows:
Code:
void OnEnter(){     PlayMusic("02_amb_strange.ogg",true ,0.4f,0.2f,1,false);}


On the next level, I have a statement that should stop the music from playing which is as follows:
Code:
void OnEnter(){    StopMusic(2.0f,0);}


However, there is a problem. When I enter the second level, the music continues to play. On the last 3 levels, the music is supposed to stop but it doesn't on any of them. I've tried putting StopMusic statements in 'OnLeave' in addition and that doesn't work.

Is there something I'm missing?


RE: How to stop music playing? - SilentStriker - 07-12-2012

To stop the music you can just put StopMusic in OnLeave() and also to stop the music you need to have the same priority on both. You have priority 1 on PlayMusic then you also need Priority 1 on StopMusic Smile


RE: How to stop music playing? - Chap - 07-12-2012

Ah it works both ways now - It was just the priority, haha I can't believe that was all.

Thanks for your help SilentStriker!


RE: How to stop music playing? - SilentStriker - 07-12-2012

Your welcome Smile

Welcome to the forum Smile