Frictional Games Forum (read-only)
[SCRIPT] Sound wont stop playing - 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 - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Sound wont stop playing (/thread-46304.html)



Sound wont stop playing - serbusfish - 05-05-2016

I have made a sound play at an entity, but when I use the stop sound command it wont stop playing, is there some sort of trick to get this working because I have tried several things and none work?


RE: Sound wont stop playing - Mudbill - 05-05-2016

Did you use script to start the sound? How does your script look?


RE: Sound wont stop playing - serbusfish - 05-05-2016

(05-05-2016, 01:36 PM)Mudbill Wrote: Did you use script to start the sound? How does your script look?

First I have this:

Quote:AddEntityCollideCallback("Player", "ScriptArea_5", "Piano", true, 1);

void Piano(string &in asParent, string &in asChild, int alState)

{

PlaySoundAtEntity("", "amb_mansion_gallery_piano_2D.snt", "ScriptArea_6", 0, false);

}

Then:

Quote:AddEntityCollideCallback("Player", "ScriptArea_7", "PianoStop", true, 1);

void PianoStop(string &in asParent, string &in asChild, int alState)

{

StopSound("amb_mansion_gallery_piano_2D.snt", 0.5);

}



RE: Sound wont stop playing - Romulator - 05-05-2016

PHP Code:
PlaySoundAtEntity("amb_piano""amb_mansion_gallery_piano_2D.snt""ScriptArea_6"0false); 
PHP Code:
StopSound("amb_piano"0.5); 

That should fix it. Have a look at the two codes on the Engine Scripts Page.

PHP Code:
void PlaySoundAtEntity(stringasSoundNamestringasSoundFilestringasEntityfloat afFadeTimebool abSaveSound); 
PHP Code:
void StopSound(stringasSoundNamefloat afFadeTime); 

Both of the codes have a value called asSoundName, which you should think of as a name that you give the sound. The name is handled internally - so you define a name for the sound and then wish to mess around with it later, you reference the SoundName in StopSound();. In the case of the above, since you did not define a name of a sound to stop, it continues to play. I simply made the SoundName into amb_piano.

This does not just apply to sounds - other codes also use internal names when being modified in script. Some examples are SetLightVisible();, AddQuest();, CompleteQuest();, GiveItem(); and RemoveItem();.

Think of the internal name as the name of something in the Level Editor or a newly created object when created in Script (Start/StopSound). The internal name of your ScriptArea to start playing the sound is ScriptArea_5, thus, whenever you're referring to that ScriptArea, you simply type its name in the appropriate code string.


RE: Sound wont stop playing - serbusfish - 05-05-2016

(05-05-2016, 03:28 PM)Romulator Wrote: 'snip'

I cant believe I missed that Rolleyes Many thanks pal, its now working great Big Grin