Modme Forums

Sound script help

Game Modding | Call of Duty: Black Ops 3 | Scripting


Pepergogo:

Thread By: Pepergogo
Hi
So, I'm using a sound trigger created by IceGranade, but if I use more than one I need to activate the first one before the next.
Anyone know if is possible to activate any trigger at anytime without activate the previous?

I will be really greatful :D

//Trigger sound
    Trig = getEnt("radio_trig", "targetname"); //Trigger targetname 
    Trig setHintString("Press &&1 to enable radio"); //Message in game
    Trig waittill("trigger", action);
    action playsound("snail_jingle"); //Audio ID
    level.radio_playing = true;
	wait(59);
	level.radio_playing = false;

	

	Trig = getEnt("radio_trig1", "targetname"); //Trigger targetname
    Trig waittill("trigger", action);
    action playsound("cryo_jingle"); //Audio ID
    level.radio_playing = true;
	wait(90);
	level.radio_playing = false;


tom5300:

Reply By: tom5300

Pepergogo
Hi So, I'm using a sound trigger created by IceGranade, but if I use more than one I need to activate the first one before the next. Anyone know if is possible to activate any trigger at anytime without activate the previous? I will be really greatful :D //Trigger sound Trig = getEnt("radio_trig", "targetname"); //Trigger targetname Trig setHintString("Press &&1 to enable radio"); //Message in game Trig waittill("trigger", action); action playsound("snail_jingle"); //Audio ID level.radio_playing = true; wait(59); level.radio_playing = false; Trig = getEnt("radio_trig1", "targetname"); //Trigger targetname Trig waittill("trigger", action); action playsound("cryo_jingle"); //Audio ID level.radio_playing = true; wait(90); level.radio_playing = false;

You would have to use threaded functions.
Something like this in mapname.gsc:
In main() somewhere after zm_usermap::main(); add:

level thread radio_play_sound("radio_trig", "snail_jingle");
level thread radio_play_sound("radio_trig1", "cryo_jingle");

and underneath the main() function add:

function radio_play_sound(trigger_string, sound_string)
{
	trig = getEnt(trigger_string, "targetname");
	trig setHintString("Press &&1 to enable radio");
	trig waittill("trigger", player);
	player playsound(sound_string);
	level.radio_playing = true;
	wait(SoundGetPlaybackTime(sound_string)*0.001);
	level.radio_playing = false;
}

The above function takes the targetname of a trigger as the first parameter and the name of the sound alias you want to play as the second parameter.
So to add another radio, you would just add another line in the main()
Ex: level thread radio_play_sound("new_radio_trigger", "custom_radio_vox");

I did not test this code, but hopefully it works for your purpose.


Pepergogo:

Reply By: tom5300

You would have to use threaded functions.
Something like this in mapname.gsc:
In main() somewhere after zm_usermap::main(); add:

level thread radio_play_sound("radio_trig", "snail_jingle");
level thread radio_play_sound("radio_trig1", "cryo_jingle");

and underneath the main() function add:

function radio_play_sound(trigger_string, sound_string)
{
    trig = getEnt(trigger_string, "targetname");
    trig setHintString("Press &&1 to enable radio");
    trig waittill("trigger", player);
    player playsound(sound_string);
    level.radio_playing = true;
    wait(SoundGetPlaybackTime(sound_string)*0.001);
    level.radio_playing = false;
}

The above function takes the targetname of a trigger as the first parameter and the name of the sound alias you want to play as the second parameter.
So to add another radio, you would just add another line in the main()
Ex: level thread radio_play_sound("new_radio_trigger", "custom_radio_vox");

I did not test this code, but hopefully it works for your purpose.

It work!
Thanks a lot, you're an absolute hero