Game Modding | Call of Duty: Black Ops 3 | Scripting
ModmeBot:
Thread By: ltschase
I would like to know how to start and stop an "ambient" sound. I was hoping that by using Nate Smith's ambient sounds method with the structs, that I could simply stop and start the sound by hiding and showing the structs, but that didn't work, so I am not sure how to do it. If you don't understand what am I wanting to do exactly, for example, I want to have the sound of a generator running, but the generator isn't always running, so the sound needs to turn on and off.
ModmeBot:
Reply By: ihmiskeho
I don't know how Nate's script works, but you could use PlayLoopSound(<sound>, fadetime) to start the sound and StopLoopSound(fadetime) to stop it.</sound>
There is info about these function (and basically about all BO3 functions) in the scriptapifunctions. That can be found in Black ops 3 root/deffiles/docs_modtools.
<h1> </h1>
ModmeBot:
Reply By: Abnormal202
ltschase
I would like to know how to start and stop an "ambient" sound. I was hoping that by using Nate Smith's ambient sounds method with the structs, that I could simply stop and start the sound by hiding and showing the structs, but that didn't work, so I am not sure how to do it. If you don't understand what am I wanting to do exactly, for example, I want to have the sound of a generator running, but the generator isn't always running, so the sound needs to turn on and off.
SoundOrg = util::spawn_model( "tag_origin", <location> );
SoundOrg PlayLoopSound("alias_name");
SoundOrg Delete();</location>
#using scripts\shared\util_shared;
ModmeBot:
Reply By: Symbo
Abnormal you got me curious. StopLoopSound always worked for me. I just found this function in sound_shared.gsc that suggest you can specify the alias you want to stop instead of the fadetime.
function loop_on_tag( alias, tag, bStopSoundOnDeath )
{
org = Spawn( "script_origin", ( 0, 0, 0 ) );
org endon( "death" );
if ( !isdefined( bStopSoundOnDeath ) )
{
bStopSoundOnDeath = true;
}
if ( bStopSoundOnDeath )
{
thread util::delete_on_death( org );
}
if( isdefined( tag ) )
{
org LinkTo( self, tag, ( 0, 0, 0 ), ( 0, 0, 0 ) );
}
else
{
org.origin = self.origin;
org.angles = self.angles;
org LinkTo( self );
}
// org endon( "death" );
org PlayLoopSound( alias );
// println( "playing loop sound ", alias, " on entity at origin ", self.origin, " at ORIGIN ", org.origin );
self waittill( "stop sound" + alias );
org StopLoopSound( alias );
org Delete();
}
#using scripts\shared\sound_shared;
entity thread sound::loop_on_tag( "alias_name");
entity notify( "stop sound" + "alias_name" );
ModmeBot:
Reply By: ltschase
Got it working using StopLoopSound.