12-25-2012, 08:16 PM
I'm having lots of trouble getting a sound to stop in one of my maps. When the player enters a certain area, I want a prisoner chained to the wall to start muttering. However, since the muttering has such a wide range I want it to stop when the player leaves the area, but the sound won't stop.
"Prisoner" is the offending sound:
Every other script works when the player leaves; Sepia and Radial Blur return to normal, but the muttering continues. When the player then re-enters the area, a second muttering sound will start and overlap the original.
"Prisoner" is the offending sound:
PHP Code:
void OnStart{
AddEntityCollideCallback("Player", "TerrorArea", "CollideTerrorArea", false, 0);
}
void CollideTerrorArea(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
FadeSepiaColorTo(0.75f, 0.7f);
FadeRadialBlurTo(0.025f, 0.02f);
AddTimer("terror", 0, "TimerTerrorDrain");
SetLocalVarInt("InTerror", 1);
PlaySoundAtEntity("Prisoner", "24_mb_02.snt", "chained_prisoner_3", 1.0f, true);
}
else if(alState == -1)
{
FadeSepiaColorTo(0.0f, 1.0f);
FadeRadialBlurTo(0.0f, 0.02f);
RemoveTimer("terror");
SetLocalVarInt("InTerror", 0);
StopSound("Prisoner", 1.0f);
}
}
Every other script works when the player leaves; Sepia and Radial Blur return to normal, but the muttering continues. When the player then re-enters the area, a second muttering sound will start and overlap the original.