09-24-2012, 08:01 PM
I've been looking for an answer around the internet, but unfortunately without any succes.
So this is what I want to do:
You hear a sound playing (ambience) and when you walk into an abondoned looking house, the ambience suddenly changes. then when you walk out of the house, the ambience changes back to the ambience that it was before.
I've tried setting an area with StopSound(''Soundfile'', 0); at the entrance of the house. But it doesn't seem to work. I'll post the script here. (This is a map that I just started.)
////////////////////////////
// Run first time starting map
void OnStart()
{
}
void OnEnter()
{
PlaySoundAtEntity("", "07_amb_breath.snt", "Player", 1, true);
AddEntityCollideCallback("Player", "HouseAmbience", "Kaas", false, 1);
AddEntityCollideCallback("Player", "stopmusicamb", "stophammertime", true, 0);
}
void Kaas(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "00_loop.snt", "Player", 1, true);
}
void stophammertime(string &in asParent, string &in asChild, int alState)
{
StopSound("00_loop.snt", 0);
}
How do I do this?
So this is what I want to do:
You hear a sound playing (ambience) and when you walk into an abondoned looking house, the ambience suddenly changes. then when you walk out of the house, the ambience changes back to the ambience that it was before.
I've tried setting an area with StopSound(''Soundfile'', 0); at the entrance of the house. But it doesn't seem to work. I'll post the script here. (This is a map that I just started.)
////////////////////////////
// Run first time starting map
void OnStart()
{
}
void OnEnter()
{
PlaySoundAtEntity("", "07_amb_breath.snt", "Player", 1, true);
AddEntityCollideCallback("Player", "HouseAmbience", "Kaas", false, 1);
AddEntityCollideCallback("Player", "stopmusicamb", "stophammertime", true, 0);
}
void Kaas(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "00_loop.snt", "Player", 1, true);
}
void stophammertime(string &in asParent, string &in asChild, int alState)
{
StopSound("00_loop.snt", 0);
}
How do I do this?