Jump to content

How to play sounds in OnLockStateChanged block


Recommended Posts

I do this:

extends ObjectReference

Sound Property TriggerSound Auto

Event OnOpen(ObjectReference akRef)
	TriggerSound.play(self)
endEvent

this works

then I do this:

Event OnLockStateChanged()
		TriggerSound.play(self)
endEvent

this does not work

So I replace self with an object I just created

Event OnLockStateChanged()
		MyHazard = placeatme(TriggerHazard)
		TriggerSound.play(MyHazard)

Still no dice.

I know the event is firing because I get irradiated

How to play sounds?

Edit:

Event OnLockStateChanged()
	if !(DoOnce)
		MyHazard = placeatme(TriggerHazard)
		int soundId = TriggerSound.play(MyHazard)
		starttimer(5, 10)
		DoOnce = True
		if (soundId == 0)
			Debug.MessageBox("ID is zero")
		else
			Debug.MessageBox("ID is not zero")
		endIf
	endIf
endEvent

does not create any messageboxes (but it does create the hazard)

Edited by d4em
Link to comment
Share on other sites

Alternatively: how to fire script when a door starts opening instead of when the opening ends? Event OnOpen() fires when the door finishes opening, I need an event that fires at the start. OnLockStateChanged works, but I'm going to have to open the door manually so it still works with that "lockpick no auto activate" mod

Link to comment
Share on other sites

If the lock state changes because you're lockpicking it, maybe the lockpicking interface counts as being in "menu mode", and it is possible that the sound descriptor you're trying to play uses a sound category which pauses it during menu mode.

  • Thanks 1
  • 100% 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...