Modme Forums
Menu:

[HELP] Music in certain areas

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


ModmeBot:

Thread By: Hamwunk
[BO3] Does anyone know how to play a music sound file when in a certain area of a map? (looping)


ModmeBot:

Reply By: Wild
Don't know if this is what you're looking for but it seems you can use this method and just use music.


ModmeBot:

Reply By: Hamwunk

AGC
Don't know if this is what you're looking for but it seems you can use this method and just use music.

What I meant is to have music play when walking in a room for example, and the leaving the room it will turnoff. The next time you enter, music will play again. This is similar to the BO3 maps and I was just wondering how you do that.


ModmeBot:

Reply By: Exofile
I had a similar thing made for a fun project of mine a while back by the help of lilrobot & lilrifa. Upon entering a room; music will play from struct(s), and wait an allocated time until it plays another, depending on whether the player is in the room or not. I'm sure you can edit the function to have it your way, but it's somewhat like what you're looking for.

function amb_radio()
{
    radio = getEntArray("ambient_radio", "targetname");
	trigger = getEnt("exo_bio_radio_1", "targetname");
	possible_songs = StrTok(radio[0].script_string, ",");
    for(;;)
	{
		trigger waittill("trigger", player);
		IPrintLn( "Player Entered" );
		wait(0.1);
		song = possible_songs[RandomIntRange(0, possible_songs.size)];
		IPrintLn( song );
		for(i=0;i<radio.size;i++) {="" radio[i]="" playsound(song);="" }="" wait(204);="" iprintln(="" "song="" done"="" );="" wait(randomintrange(30,="" 60));="" iprintln(="" "wait="" done"="" );="" }=""></radio.size;i++)>

Hope this helps?


ModmeBot:

Reply By: Hamwunk

Exofile
I had a similar thing made for a fun project of mine a while back by the help of lilrobot & lilrifa. Upon entering a room; music will play from struct(s), and wait an allocated time until it plays another, depending on whether the player is in the room or not. I'm sure you can edit the function to have it your way, but it's somewhat like what you're looking for. function amb_radio() { radio = getEntArray("ambient_radio", "targetname"); trigger = getEnt("exo_bio_radio_1", "targetname"); possible_songs = StrTok(radio[0].script_string, ","); for(;;) { trigger waittill("trigger", player); IPrintLn( "Player Entered" ); wait(0.1); song = possible_songs[RandomIntRange(0, possible_songs.size)]; IPrintLn( song ); for(i=0;i<radio.size;i++) {="" radio="" playsound(song);="" }="" wait(204);="" iprintln(="" "song="" done"="" );="" wait(randomintrange(30,="" 60));="" iprintln(="" "wait="" done"="" );="" }="" }="" ="" hope="" this="" helps?
=""></radio.size;i++)> I have a couple questions. First, what do you need to do in radiant? add a trigger? Also, does this go into the .gsc and does it go to the bottom of the script? Lastly, is this for BO3?


ModmeBot:

Reply By: Exofile

Hamwunk
I have a couple questions. First, what do you need to do in radiant? add a trigger? Also, does this go into the .gsc and does it go to the bottom of the script? Lastly, is this for BO3?


Add a script_origin, and give it the appropriate kvp's;
Targetname : ambient_radio
script_string : (aliases of sounds you want to play, if you want more than one possible then list them with a comma inbetween.)
Then you add in a trigger_multiple, and give it the appropriate kvp's;
targetname : exo_bio_radio_1


Of course this is basing it completely on my map, you might want to change the KVP's if you'd like depending on how you'd like it.

This goes into the bottom of your mapname.gsc- then thread it in your main function;
function main()
{
	zm_usermap::main();
	thread amb_radio();
	
	level._zombie_custom_add_weapons =&amp;custom_add_weapons;
	
	//Setup the levels Zombie Zone Volumes
	level.zones = [];
	level.zone_manager_init_func =&amp;usermap_test_zone_init;
	init_zones[0] = "start_zone";
	level thread zm_zonemgr::manage_zones( init_zones );

	level.pathdist_type = PATHDIST_ORIGINAL;
}


And yes, of course this is for Black Ops III.