Jump to content

Starting / Stopping sounds help


crazytechnokid

Recommended Posts

Ok so i've got a script that starts a looping sound when you use a Chem. But how do you stop the sound after the chem effect is over? Here's my script as of now. ::

 

scn ActivatorSCRIPT

Begin ScriptEffectStart
Player.AddItem Activator 1
PlaySound MySound
End

Begin ScriptEffectFinish
;;StopSound MySound? I dont know how to do that
End

Link to comment
Share on other sites

Wouldn't you know it, but the developers never made a stopsound command - though I believe this has been asked of the FOSE team. At his point however, it does not exist.

 

I haven't tried this myself, but you might be able to fake it by making a quest that is started when the chem is used and then the quest is stopped when the effect wears off. But I'm not sure if stopping the quest will stop a looping sound that has been started via a quest script. I can think of some kludgey ways to do it, but nothing eloquent comes to mind. You could also make a copy of the looping sound and make it a non-looping sound and have a timing script that continually repeats the playsound command when the previous play is finished. Then when the effect wears off, the sound isn't repeated. This might be the best method.

 

Most of the time playing and stopping looping sounds is done by placing a sound object in the game and enabling or disabling it to start and stop the sound. But if you want the sound to travel with, the player...Well, I'm not sure except for the kludgey ways.

 

That kludgey way would be to script an invisible tiny NPC that floats above the NPC's head and you would make them be a radio,playing the same song continuously. Then just remove the invisible NPC to turn of the radio.

Link to comment
Share on other sites

Alright, and the idea of making a sound looping script is a good idea, same with the floating NPC idea, although i'm not quite sure how to do that one haha, but right now i'm having a problem that when i use my Chem the sound doesn't play at all, the other effect i coded in there happens be the sound doesn't.. =\. If i were to attach my .fomod file with the Chem mod in it could you possibly tell me why? I'll include all the scripts i wrote in .txt files for ease of access.
Link to comment
Share on other sites

You could also make a copy of the looping sound and make it a non-looping sound and have a timing script that continually repeats the playsound command when the previous play is finished. Then when the effect wears off, the sound isn't repeated. This might be the best method.

I think that this is a practical method. I used a similar script idea for custom alcohol/drug effects, but did not choose one of the looping sounds. My sounds only triggered one time at ingestion and had limited durations. Some non-looping sounds have long durations though.

 

If you make a chem that wears off in 30 seconds and add a timed script that causes a 5 second long sound to play every 5 seconds until the 30 seconds is done, then you can make a very long duration sound that doesn't degrade into a neverending cacophony.

 

Cipscis's timer tutorials should make the process clear if you want to try that method.

Link to comment
Share on other sites

Yes i did make a sound object in the GECK, but the "sound" is just a .wav music file, thats the only way i see it possible? I know for oblivion there is a StreamMusic command but it doesn't work in a variety of cases so it just won't do.

 

 

EDIT: Oh and yes it does play in the GECK, sorry i read over that question.

Link to comment
Share on other sites

A script timer to repeatedly play a non-looping Sound object might be the easiest way to make your sound play, but as said above, there is no way to stop a sound played with PlaySound at a specific moment.

 

Similar to what pkleiss suggested, you could place an "invisible" object at the Player that has a looping sound attached, then remove it when you want the sound to stop. It doesn't have to be an NPC or radio station though. A few types of objects have a "Looping Sound" button that lets you attach a Sound object that plays continuously while that object is loaded in the scene (I'm not completely sure if the the Sound itself needs to be set to loop or not - you should be able to figure that out). You could try using a Movable Static, or an Activator if you also want to attach a script to it. Since you're playing music, I'm assuming you don't want the sound to be spatially localized, so you probably want to flag the Sound object as 2D.

 

When you want the sound to start, you'd do something like:

 

	set rMySoundPlayer to Player.PlaceAtMe MySoundPlayerObject 1

...then when you want it to stop:

	rMySoundPlayer.Disable
rMySoundPlayer.MarkForDelete

 

Ideally for the MySoundPlayerObject, you'll want to assign a model that has no collision and is invisible (but you could use any model to test with). A vanilla model you could use is at the path "Effects\FXNullExplosionArt.nif".

Link to comment
Share on other sites

Alright I tried placing an object at the player that has a sound attached but yet again no sound. The object spawned fine but no sound was coming from it. (the model i used was bobbleheadAGL) are there certain models that don't project sound? and yes the sound is set up as 2D. Heres the script as of now::

scn ESMActivatorsSCRIPT

ref rMusicFollower

begin ScriptEffectStart
Player.AddItem ESMActivator 1
set rMusicFollower to Player.PlaceAtMe ESMMusicFollower 1
sgtm .4	
End

Begin ScriptEffectFinish
sgtm 1
End

Link to comment
Share on other sites

  • Recently Browsing   0 members

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