Modme Forums

Ambient start when power is on

Game Modding | Call of Duty: Black Ops 3 | General Discussion


ModmeBot:

Thread By: Christians_Gaming
So want to have some of my ambient sounds to play, when I have the power on. Is that possible? It's because I have a flickering light ambient, and it doesn't make sense, if it's on when the power is of, then people will be confused! Help?

Sry for bad english ;(


ModmeBot:

Reply By: mathfag
Place script_structs with targetname-"cher_sound"
script_string-"sound alias"
If you want it to play a sound after power add script_noteworthy-"power"
And paste this to the bottom of your script. No threading necessary.

function autoexec sound()
{
level waittill("initial_blackscreen_passed");
structs = struct::get_array("cher_sound", "targetname");

foreach(str in structs)
	{
	if(!isdefined(str.script_noteworthy) && str.script_noteworthy != "power")
		{
		spot = Spawn("script_model",str.origin);
		spot PlayLoopSound(str.script_string,15);
		}
	}

level waittill("power_on");

foreach(str in structs)
	{
	if(isdefined(str.script_noteworthy) && str.script_noteworthy == "power")
		{
		spot = Spawn("script_model",str.origin);
		spot PlayLoopSound(str.script_string,15);
		}
	}
}


ModmeBot:

Reply By: Harry Bo21

mathfag
Place script_structs with targetname-"cher_sound" script_string-"sound alias" If you want it to play a sound after power add script_noteworthy-"power" And paste this to the bottom of your script. No threading necessary. function autoexec sound() { level waittill("initial_blackscreen_passed"); structs = struct::get_array("cher_sound", "targetname"); foreach(str in structs) { if(!isdefined(str.script_noteworthy) && str.script_noteworthy != "power") { spot = Spawn("script_model",str.origin); spot PlayLoopSound(str.script_string,15); } } level waittill("power_on"); foreach(str in structs) { if(isdefined(str.script_noteworthy) && str.script_noteworthy == "power") { spot = Spawn("script_model",str.origin); spot PlayLoopSound(str.script_string,15); } } }


*EDIT* no i mis read

still a mistake tho, youre not deleting the first entity with its sound, just spawning another

you also must assign a model like "tag_origin" or something before you can do anything to or on a model. Or it will bug out

theres a slightly more improved spawn model function in util_shared.gsc id recommend in future


e_model = util::spawn_model( "model_name", v_origin, v_angles );


"Name: spawn_model(, [origin], [angles], [spawnflags])"
"Summary: Spawns a model at an origin and angles."
"Module: Utility"
"MandatoryArg:  the model name."
"OptionalArg: [origin] the origin to spawn the model at."
"OptionalArg: [angles] the angles to spawn the model at."
"OptionalArg: [spawnflags] the spawnflags for the model."
"OptionalArg: [b_throttle] respect the global spawn throttle."
"Example: fx_model = spawn_model("tag_origin", org, ang);"


ModmeBot:

Reply By: Christians_Gaming

mathfag
Place script_structs with targetname-"cher_sound" script_string-"sound alias" If you want it to play a sound after power add script_noteworthy-"power" And paste this to the bottom of your script. No threading necessary. function autoexec sound() { level waittill("initial_blackscreen_passed"); structs = struct::get_array("cher_sound", "targetname"); foreach(str in structs) { if(!isdefined(str.script_noteworthy) && str.script_noteworthy != "power") { spot = Spawn("script_model",str.origin); spot PlayLoopSound(str.script_string,15); } } level waittill("power_on"); foreach(str in structs) { if(isdefined(str.script_noteworthy) && str.script_noteworthy == "power") { spot = Spawn("script_model",str.origin); spot PlayLoopSound(str.script_string,15); } } }

Is it in gsc or? Sry I'm a beginner xD


ModmeBot:

Reply By: mathfag

Christians_Gaming
mathfag Place script_structs with targetname-"cher_sound" script_string-"sound alias" If you want it to play a sound after power add script_noteworthy-"power" And paste this to the bottom of your script. No threading necessary. function autoexec sound() { level waittill("initial_blackscreen_passed"); structs = struct::get_array("cher_sound", "targetname"); foreach(str in structs) { if(!isdefined(str.script_noteworthy) && str.script_noteworthy != "power") { spot = Spawn("script_model",str.origin); spot PlayLoopSound(str.script_string,15); } } level waittill("power_on"); foreach(str in structs) { if(isdefined(str.script_noteworthy) && str.script_noteworthy == "power") { spot = Spawn("script_model",str.origin); spot PlayLoopSound(str.script_string,15); } } } Is it in gsc or? Sry I'm a beginner xD

gsc. Everything is gsc unless it says otherwise


ModmeBot:

Reply By: Christians_Gaming

mathfag
Christians_Gaming mathfag Place script_structs with targetname-"cher_sound" script_string-"sound alias" If you want it to play a sound after power add script_noteworthy-"power" And paste this to the bottom of your script. No threading necessary. function autoexec sound() { level waittill("initial_blackscreen_passed"); structs = struct::get_array("cher_sound", "targetname"); foreach(str in structs) { if(!isdefined(str.script_noteworthy) && str.script_noteworthy != "power") { spot = Spawn("script_model",str.origin); spot PlayLoopSound(str.script_string,15); } } level waittill("power_on"); foreach(str in structs) { if(isdefined(str.script_noteworthy) && str.script_noteworthy == "power") { spot = Spawn("script_model",str.origin); spot PlayLoopSound(str.script_string,15); } } } Is it in gsc or? Sry I'm a beginner xD gsc. Everything is gsc unless it says otherwise

It doesn't work m8 :(


ModmeBot:

Reply By: mathfag

Christians_Gaming
mathfag Christians_Gaming mathfag Place script_structs with targetname-"cher_sound" script_string-"sound alias" If you want it to play a sound after power add script_noteworthy-"power" And paste this to the bottom of your script. No threading necessary. function autoexec sound() { level waittill("initial_blackscreen_passed"); structs = struct::get_array("cher_sound", "targetname"); foreach(str in structs) { if(!isdefined(str.script_noteworthy) && str.script_noteworthy != "power") { spot = Spawn("script_model",str.origin); spot PlayLoopSound(str.script_string,15); } } level waittill("power_on"); foreach(str in structs) { if(isdefined(str.script_noteworthy) && str.script_noteworthy == "power") { spot = Spawn("script_model",str.origin); spot PlayLoopSound(str.script_string,15); } } } Is it in gsc or? Sry I'm a beginner xD gsc. Everything is gsc unless it says otherwise It doesn't work m8 :(

Have you tried this?