daisy8 Posted November 15, 2021 Share Posted November 15, 2021 Hi all I have a klaxon sound that loops that is triggered by a change in quest stage using a player sets quest stage trigger box. The fragment on the quest stage is : klaxonsound.play(speaker02) This uses 2 properties, the sound and a loudspeaker ref as the emitter and works great ! But I want the sound to stop once the quest advances to the next stage and I have been trying to understand the StopInstance function. I have not been able to understand how this 'playback instance' INT works. Is this right ? Once the sound plays a unique INT (playback instance) is generated ? and then to stop the sound I stop it with reference to the playback instance INT ? How do I script this in a quest with fragments ? Thanksdaisy Link to comment Share on other sites More sharing options...
LarannKiar Posted November 15, 2021 Share Posted November 15, 2021 (edited) You need to store the ID of the sound instance first. First fragment: GlobalVariable Property mySoundInstanceGlobal Auto Const Sound Property KlaxonSound Auto Const ObjectReference Property Speaker02 Auto Const mySoundInstanceGlobal.SetValueInt(KlaxonSound.Play(Speaker02)) Second fragment: GlobalVariable Property mySoundInstanceGlobal Auto Const Sound Property KlaxonSound Auto Const ObjectReference Property Speaker02 Auto Const Sound.StopInstance(mySoundInstanceGlobal.GetValueInt()) If it doesn't work, you can attach a quest script to your quest and use a script variable instad of a global variable: Scriptname YOURSCRIPTNAME extends Quest Sound Property KlaxonSound Auto Const ObjectReference Property Speaker02 Auto Const Int SoundInstanceID Event OnStageSet(int auiStageID, int auiItemID) ;*** First Stage If auiStageID == 5 SoundInstanceID = KlaxonSound.Play(Speaker02) EndIf ;*** Second Stage If auiStageID == 10 Sound.StopInstance(SoundInstanceID) EndIf EndEvent Don't forget to change the auiStageIDs. Edited November 15, 2021 by LarannKiar Link to comment Share on other sites More sharing options...
SKKmods Posted November 15, 2021 Share Posted November 15, 2021 You cant do it in a script fragment with local variables as the INT needs to be persistent, that needs a quest (or object) attached script. Scriptname MySoundScript extends Quest Sound Property pMySound Auto Const Mandatory ObjectReference Property pMyObject Auto Int iSoundInstance = -1 Event OnStageSet(int auiStageID, int auiItemID) If (auiStageID == 10) ;stage to turn sound on iSoundInstance = pMySound.Play(pMyObject) ElseIf (auiStageID == 20) ;stage to turn sound off Sound.StopInstance(iSoundInstance) pMyObject = none EndIf EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts