Frictional Games Forum (read-only)
Music problem? - 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: Music problem? (/thread-8985.html)

Pages: 1 2


RE: Music problem? - Zypherzemus - 07-07-2011

Code:
////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "girlsdormkey_1", "girlsdorm", "UsedKeyOnDoor_5", true);
if (GetGlobalInt("music") == 0)
{
PlayMusic("02_amb_safe.ogg", true, 100.0, 0.0, 1, true);
}
else if (GetGlobalInt("music") == 1)
{
PlayMusic("09_amb_safe.ogg", true, 100.0, 0.0, 1, true);
}
}



void UsedKeyOnDoor_5(string &in asItem, string &in asEntity)
{
    SetLevelDoorLocked("girlsdormdoor", false);
    PlaySoundAtEntity("", "unlock_door", "girlsdormdoor", 0, false);
    RemoveUseItemCallback("girlsdormkey_1");
}


////////////////////////////
// Run when leaving map
void OnLeave()
{
StopMusic(1.0f, 1);
SetGlobalVarInt("music", 1);
}

I get an Error:
(108, 5): No Matching signatures
(112, 10) No matching signatures

I put everything in the correct place


RE: Music problem? - DRedshot - 07-07-2011

sorry that was my mistake, instead of GetGlobalInt it should be GetGlobalVarInt, that should work, make sure you do that for all three instances of GetGlobalVarInt, even the one in your Global.hps


RE: Music problem? - Zypherzemus - 07-07-2011

Thanks so much guys, it works! Big Grin


RE: Music problem? - Zypherzemus - 07-07-2011

Oh, I failed to mention this:
Whenever I leave a level and go back to the hub level, the music from the previous level continues to play even though I have the "StopMusic" command in the OnLeave section of the .hps file for that map

I have it set up in a particular way though:
Ex: "You interact with an entity and the music begins to play, then when you leave the map, the music continues to play even though it's not supposed to.




RE: Music problem? - DRedshot - 07-08-2011

I'm not sure how to fix that, but it may be to do with the priority levels of your music / stopmusic, try changing some of those around ( closer to 0 = higher priority ) maybe make the priority of the stopmusic = 0, if that doesn't work try adding a debug message to find out what your globalvarint is doing:
AddDebugMessage("Global Variable 'Music' = "GetGlobalVarInt("Music"));
if that doesn't work, i wont be able to help you, because ive never had that problem before.