Frictional Games Forum (read-only)

Full Version: Stopping a playing phonograph mid-piece
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to find a script that will stop whatever sound a phonograph is playing in the middle of said sound when a lever is pulled. I have tried using the StopSound and StopMusic scripts but they unfortunately do not work. When I pull the lever every other script functions perfectly but the phonograph still plays!

Here is the script I am using:

void PlayHorrorNoise(string &in asEntity, int alState)
{
if(alState == 1)
{
PlaySoundAtEntity("", "mors_praematura.snt", asEntity, 0, false);
}
}

/////the script that is activated when the phonograph is wound, and

void GalleryLights(string &in asEntity, int alState)
{
if (alState == 1)
{
StopSound("mors_praematura.snt", 1);
FadeLightTo("GalleryLight", 0.5, 0.395, 0.1, 1, -1, 6);
SetLeverStuckState("GalleryLever", 1, false);
SetLampLit("lamp_1", true, true);
SetLampLit("lamp_2", true, true);
}
}

/////the script that is activated when the lever is pulled.

I hope I did a decent job of explaining my conundrum. I'd be happy to provide any other information should it be needed and I welcome any and all suggestions. Thanks!

Problem solved!
When you launch the first play sound in the first brackets put a name, and in the stopsound put the name you've put in the brackets
(03-25-2014, 05:16 AM)triadtimes Wrote: [ -> ]StopSound works by using the internal name of a sound file. In your example
Code:
PlaySoundAtEntity("", "mors_praematura.snt", asEntity, 0, false);
you do not have an internal name set.

In the first pair of quotes you have to give it a name (ex. Rabbit, as Amn said).
Code:
PlaySoundAtEntity("Rabbit", "mors_praematura.snt", asEntity, 0, false);

Then, when you call StopSound you use the same internal name (ex. Rabbit again).
Code:
StopSound("Rabbit", 1);

I hope this helps.

This came from the identical thread, created by the same user.
Yeah I've been helped on the problem and...

well honestly I have no clue on how to close a thread. Tips?
A thread will be closed by a moderator, but they often won't unless requested Smile I wouldn't worry about it. You could always put a "Solved" in the title (by editing the Original Post) but it is not required!
Problem is solved so closing this! Remember not to make multiple threads for a same situation.