Frictional Games Forum (read-only)

Full Version: Sound doesn't fade (Solved)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Alright so I'm working on a test map where im just fooling around figuring out the scripting and everything. I'm coming a long nicely thanks to lots of help, but I've run in to a problem. At the void OnStart() at the beginning one of my callbacks is

AddEntityCollideCallback("Player", "ScriptArea_1", "PlayCreepySound", true, 1);

now the script for that call back in the void OnEnter() is

void PlayCreepySound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "scare_steps_big.snt", "ScriptArea_1", 0, false);
StartScreenShake(0.3, 4, 2, 2);
PlaySoundAtEntity("", "general_rock_rumble.snt", "ScriptArea_1", 0, false);
}

Now when I enter the script area the sounds play the screen shakes and everything works, but the rock rumble sound never stops playing.
Anyone know whats up???

Thanks in advance.
Seems like that is a looped sound. Use StopSound or edit the .snt file itself.
(01-08-2011, 09:34 PM)Frontcannon Wrote: [ -> ]Seems like that is a looped sound. Use StopSound or edit the .snt file itself.

I tried it. I'm very confused as to how to do it. When i put StopSound in to the same block as the initial sound, the sound doesn't play. That makes sense i guess. So I just tried like 30 minutes of experimenting and came up with something that looks like this.

void PlayCreepySound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "scare_steps_big.snt", "ScriptArea_1", 0, false);
StartScreenShake(0.3, 4, 2, 2);
PlaySoundAtEntity("Rocks1", "general_rock_rumble.snt", "ScriptArea_1", 0, false);
AddTimer("Rocks1", 2.0f, "StopCreepySound");
}

void StopCreepySound(string &in asTimer)
{
StopSound("general_rock_rumble.snt", 2.0f);
}

My idea when i did this was to put the timer in so that it would delay the next block from being executed, so the sound would play then get stopped. But the stop sound wasn't executed. The sound continues to loop. If you can explain how the script would look it would be greatly appreciated.
(01-09-2011, 12:24 AM)Cataclysm Wrote: [ -> ]PlaySoundAtEntity("Rocks1", "general_rock_rumble.snt", "ScriptArea_1", 0, false);
AddTimer("Rocks1", 2.0f, "StopCreepySound");
}

void StopCreepySound(string &in asTimer)
{
StopSound("general_rock_rumble.snt", 2.0f);
}

My idea when i did this was to put the timer in so that it would delay the next block from being executed, so the sound would play then get stopped. But the stop sound wasn't executed. The sound continues to loop. If you can explain how the script would look it would be greatly appreciated.

This is exactly what sound names are for Smile
If blocking a sound would be working like this, you'd have to unblock it to be able to use it again...

So corrected script:

Code:
void PlayCreepySound(string &in asParent, string &in asChild, int alState)
{
    PlaySoundAtEntity("", "scare_steps_big.snt", "ScriptArea_1", 0, false);    
    StartScreenShake(0.3, 4, 2, 2);
    PlaySoundAtEntity("Rocks1", "general_rock_rumble.snt", "ScriptArea_1", 0, false);
    AddTimer("RocksTime", 2.0f, "StopCreepySound");
}

void StopCreepySound(string &in asTimer)
{
    StopSound("Rocks1", 2.0f);
}
(01-09-2011, 12:48 AM)Frontcannon Wrote: [ -> ]
(01-09-2011, 12:24 AM)Cataclysm Wrote: [ -> ]PlaySoundAtEntity("Rocks1", "general_rock_rumble.snt", "ScriptArea_1", 0, false);
AddTimer("Rocks1", 2.0f, "StopCreepySound");
}

void StopCreepySound(string &in asTimer)
{
StopSound("general_rock_rumble.snt", 2.0f);
}

My idea when i did this was to put the timer in so that it would delay the next block from being executed, so the sound would play then get stopped. But the stop sound wasn't executed. The sound continues to loop. If you can explain how the script would look it would be greatly appreciated.

This is exactly what sound names are for Smile
If blocking a sound would be working like this, you'd have to unblock it to be able to use it again...

So corrected script:

Code:
void PlayCreepySound(string &in asParent, string &in asChild, int alState)
{
    PlaySoundAtEntity("", "scare_steps_big.snt", "ScriptArea_1", 0, false);    
    StartScreenShake(0.3, 4, 2, 2);
    PlaySoundAtEntity("Rocks1", "general_rock_rumble.snt", "ScriptArea_1", 0, false);
    AddTimer("RocksTime", 2.0f, "StopCreepySound");
}

void StopCreepySound(string &in asTimer)
{
    StopSound("Rocks1", 2.0f);
}

Man thanks haha. I'm glad I came pretty close. Thanks a lot for that though it's been bothering me for a while