Play sound on enter

Post » Sun Aug 08, 2010 12:54 pm

Im trying to get a sound file to play once when the player enters an area, Im terrible at scripting and the farthest iv managed to get is for the sound to play every time I use a door. Can some one help me because the wiki seems to be missing this topic.
User avatar
Alister Scott
 
Posts: 3441
Joined: Sun Jul 29, 2007 2:56 am

Post » Sun Aug 08, 2010 7:04 pm

You could set up a trigger zone like the dart traps using http://cs.elderscrolls.com/constwiki/index.php/OnTriggerActor.

short doOncebegin OnTriggerActor player	if doOnce == 0		set doOnce to 1		playSound mySoundObject	endifend

User avatar
Cathrin Hummel
 
Posts: 3399
Joined: Mon Apr 16, 2007 7:16 pm

Post » Sun Aug 08, 2010 11:56 am

You could set up a trigger zone like the dart traps using http://cs.elderscrolls.com/constwiki/index.php/OnTriggerActor.

short doOncebegin OnTriggerActor player	if doOnce == 0		set doOnce to 1		playSound mySoundObject	endifend




I made a trigger using your script but nothing happens when I walk through the trigger zone, Thanks for the info tho, now I know im on the right track.
User avatar
Lalla Vu
 
Posts: 3411
Joined: Wed Jul 19, 2006 9:40 am

Post » Sun Aug 08, 2010 8:07 pm

Well the Doonce in the script may be clamping the effect off before you hear it play.

Sometimes you may not necessarily hear sounds played via scripting each and every time you call them for various reasons related to the sound card and how busy your CPU is. So you need a reset on the trigger to undo the Doonce just for testing this.

Just to TEST this try:

short doOncebegin OnTriggerActor player	if doOnce == 0 && player.issneaking == 0		set doOnce to 1		playSound mySoundObject                  endifendBegin Gamemode   if Doonce == 1 && player.issneaking == 1      set Doonce to 0   endifend



NOW for this test walk into the zone, if you do not hear the sound crouch down into SNEAK and then UN- crouch out of sneak to reset the script for another try at hearing the sound.

Do this a few times to be sure.

If this works then we know something is blocking the sound from playing the first time. If it does not work then we need to look at the possibility you are not actually IN the trigger zone. Because it is not visible in the game you cannot be sure where it is at in the game. Also did your make a NEW trigger zone with its own FormID or did you just drag an exsiting one into the cell window in the CS?

You should be making a new one not using a drag and drop copy of the vanilla base object.

I made a trigger using your script but nothing happens when I walk through the trigger zone, Thanks for the info tho, now I know im on the right track.

User avatar
Wayland Neace
 
Posts: 3430
Joined: Sat Aug 11, 2007 9:01 am

Post » Sun Aug 08, 2010 1:56 pm

I made a trigger using your script but nothing happens when I walk through the trigger zone

Then I would say you did not attach the script to a real 'trigger zone' object and place 'that' object in the cell your testing. Or you are using a dirty save game which can have detrimental effects on your mod testing.

You also need to make sure the sound object actually even works in the game. If its set up wrong, it will not play anyway. You can test this by making the sound the trigger zone plays one of the vanilla sounds.
User avatar
carley moss
 
Posts: 3331
Joined: Tue Jun 20, 2006 5:05 pm

Post » Sun Aug 08, 2010 10:04 pm

Then I would say you did not attach the script to a real 'trigger zone' object and place 'that' object in the cell your testing. Or you are using a dirty save game which can have detrimental effects on your mod testing.

You also need to make sure the sound object actually even works in the game. If its set up wrong, it will not play anyway. You can test this by making the sound the trigger zone plays one of the vanilla sounds.


I set up a trigger like you guys showed me useing a default sound and it worked, so the problem is my sound file, I thought I did everything right seeing as how I had it playing in game at one point when the player used an object but I guess somethings changed. Thanks for all the input tho. its been a big help.
User avatar
Dustin Brown
 
Posts: 3307
Joined: Sun Sep 30, 2007 6:55 am


Return to IV - Oblivion