Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Sound wont stop playing
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#1
Smile  Sound wont stop playing

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?

05-05-2016, 12:24 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Sound wont stop playing

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

05-05-2016, 01:36 PM
Find
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#3
RE: Sound wont stop playing

(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);

}

05-05-2016, 01:46 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#4
RE: Sound wont stop playing

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

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

PHP Code: (Select All)
void PlaySoundAtEntity(stringasSoundNamestringasSoundFilestringasEntityfloat afFadeTimebool abSaveSound); 
PHP Code: (Select All)
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.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 05-05-2016, 03:29 PM by Romulator.)
05-05-2016, 03:28 PM
Find
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#5
RE: Sound wont stop playing

(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

05-05-2016, 04:44 PM
Find




Users browsing this thread: 3 Guest(s)