Jump to content

Audio Looping with DoOnce - not supposed to


DSoS

Recommended Posts

For whatever reason my sound continues to play after SoundOnce has been set to 1 (verified in game with the debug). Yes, I've set DoOnce to True

 

I've checked multiple times to ensure my sound was not set as looping. This is a custom sound.

 

The sound loops while I'm in the trigger box, once I leave it stops, but if I enter again it plays again.

 

 

Everything works, other than the sound continues to play even after being told not to anymore.

Auto State Waiting
	Event OnTrigger(ObjectReference akTriggerRef)
		If OnTriggerObject == True
			If TriggerOnce == True
				If EnableOnly == True
					EnableObject.Enable()
					
				ElseIf DisableOnly == True
					DisableObject.Disable()
					If SoundPlayAudio == True
						SoundToPlay.PlayAndWait(SoundLocation)
						If SoundPlayOnce == True
							If SoundOnce == 0
								SoundToPlay.Play(SoundLocation)
								SoundOnce = 1
								debug.Notification("SoundOnce is" + SoundOnce)
							EndIf
						Else
							;SoundToPlay.PlayAndWait(SoundLocation)
						EndIf
					EndIf
					
				ElseIf EnableAndDisable == True
					EnableObject.Enable()
					DisableObject.Disable()
					
				EndIf
			Else
				;Do Nothing for now
			EndIf
		EndIf
	EndEvent
EndState

Any ideas?

 

I've had issues with sound scripts not working properly in the past, so I'm not sure if it's my scripting or just plain old bad luck :shrug:

Link to comment
Share on other sites

OMG...
 
Nearly 6 hours of dealing with this issue and I find it with a random quick glance :|

If SoundPlayAudio == True
	SoundToPlay.PlayAndWait(SoundLocation) <--------------------------------------------------------------- The issue! LOL
		If SoundPlayOnce == True
			If SoundOnce == 0
				SoundToPlay.Play(SoundLocation)
				SoundOnce = 1
				debug.Notification("SoundOnce is" + SoundOnce)
			EndIf
		Else
			;SoundToPlay.PlayAndWait(SoundLocation)
		EndIf
EndIf

The area with the <------ is a stray Play sound function which is outside of the SoundOnce (Play sound once and never again), so this was causing the sound to loop over and over again. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...