Frictional Games Forum (read-only)
Ending a Looping sound [NEED HELP] - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Ending a Looping sound [NEED HELP] (/thread-7889.html)

Pages: 1 2


RE: Ending a Looping sound [NEED HELP] - Simpanra - 05-09-2011

(05-09-2011, 09:44 AM)Apjjm Wrote:
(05-09-2011, 06:52 AM)Simpanra Wrote: what is the function for changing the bool value of the sound function? =)

Use "GetLocalVarInt" using 0 for false (not 0 for true). You could use a "bool x = false;" outside the function, but the status of that variable wouldn't be saved as it is with the function based approach. In the case of your code, you would do something like this:

Code:
void onStart()
{
AddEntityCollideCallback("Player", "StartSoundsArea", "PlaySounds");
SetLocalVarInt("breakSndLoop", 0);
}

void PlaySounds(Parent, Child, State)
{
PlaySoundAtEntity("EnemyGrunting", "Player");
if(GetLocalVarInt("breakSndLoop") == 0) AddTimer(1.5f, "PlaySounds2");
}

void PlaySounds2( Timer)
{
PlaySoundAtEntity("EnemyGrowling", "Player");
if(GetLocalVarInt("breakSndLoop") == 0)  AddTimer( 1.5f, "PlaySounds3");
}

void PlaySounds3( Timer)
{
PlaySoundAtEntity("EnemyGrunting", "Player");
if(GetLocalVarInt("breakSndLoop") == 0)  AddTimer( 1.5f, "PlaySounds2");
}

void StopLoop()
{
SetLocalVarInt("breakSndLoop", 1);
//If wanted, a removeTimer() and stopSound() can be used too here
//But it shouldn't be necessary - and may sound very sudden.
}

Your great! =D Thanks man =) Can't wait for your super secret project....that i dont know about...*shifty eyes*...


RE: Ending a Looping sound [NEED HELP] - Kyle - 05-11-2011

I think I figured it out! Have you tried to use it like this:

PlaySoundAtEntity("sound01", "react_sigh.snt", "Player", 0, false);

With this:

StopSound("sound01", 0);


RE: Ending a Looping sound [NEED HELP] - Simpanra - 05-11-2011

(05-11-2011, 09:07 PM)Kyle Wrote: I think I figured it out! Have you tried to use it like this:

PlaySoundAtEntity("sound01", "react_sigh.snt", "Player", 0, false);

With this:

StopSound("sound01", 0);
hmmmm, no i havent =D i shall try ^_^