Modme Forums

Can I play music from a struct when I turn on the power?

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


ModmeBot:

Thread By: Zombier
I want to play music from a struct when I turn on the power.


ModmeBot:

Reply By: mathfag
add to map.zone

xmodel,tag_origin


top of script
#precache( "model", "tag_origin");


bottom of script
function autoexec music()
{
struct = struct::get("music_struct", "targetname");
struct = Spawn("script_model", struct.origin);
struct SetModel("tag_origin");

level waittill("power_on");
struct PlaySound("sound name");
}


ModmeBot:

Reply By: Zombier

mathfag
add to map.zone xmodel,tag_origin top of script #precache( "model", "tag_origin"); bottom of script function autoexec music() { struct = struct::get("music_struct", "targetname"); struct = Spawn("script_model", struct.origin); struct SetModel("tag_origin"); level waittill("power_on"); struct PlaySound("sound name"); }

Thank you very much! I will try it.


ModmeBot:

Reply By: Zombier
There is one more question, how can you let the script script_label loop at Radiant and another sound alias play in this way?


ModmeBot:

Reply By: mathfag

Zombier
There is one more question, how can you let the script script_label loop at Radiant and another sound alias play in this way?

What?


ModmeBot:

Reply By: Zombier
I think that this is only certain music. I want to play different music with many structs.


ModmeBot:

Reply By: mathfag

Zombier
I think that this is only certain music. I want to play different music with many structs.


function autoexec music()
{
struct = struct::get_array("music_struct", "targetname");


level waittill("power_on");

for( i=0;i<struct.size;i++ )="" {="" struct[i]="Spawn("script_model"," struct[i].origin);="" struct[i]="" setmodel("tag_origin");="" struct[i]="" playsound("sound="" name"+i);="" }=""></struct.size;i++>


Now every struct will play a different sound.
Your aliases must be identical except at the end you must change the number, starting with 0 so your aliases should be:
panzer_dab0,,,custom\dab_effect.wav,,,UIN_MOD,,,,,,,,,0,0,95,100,0,500,700,,,,,,,,,,,,,,,,2d,,,LOOPING,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
panzer_dab1,,,custom\69pussy.wav,,,UIN_MOD,,,,,,,,,0,0,95,100,0,500,700,,,,,,,,,,,,,,,,2d,,,LOOPING,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
panzer_dab2,,,custom\richtofen_is_gay.wav,,,UIN_MOD,,,,,,,,,0,0,95,100,0,500,700,,,,,,,,,,,,,,,,2d,,,LOOPING,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
(sorry for immaturity) :)


ModmeBot:

Reply By: Zombier
Please tell me the struct KVP.


ModmeBot:

Reply By: Harry Bo21

Zombier
Please tell me the struct KVP.



struct = struct::get_array("music_struct", "targetname");


its right there in his post....

although note :

struct[i] = Spawn("script_model", struct.origin);
struct[i] SetModel("tag_origin");
struct[i] PlaySound("sound name"+i);


this is appalling behavior, redefining a already defined variable WITHIN the loop checking the defined variable - and spawning something through it, also typo in the first line... ("struct.origin") - and further more - not deleting the ent you spawned either, quickest way to cause impossible to find gspawns


ModmeBot:

Reply By: mathfag

Zombier
Please tell me the struct KVP.

every structs targetname is
music_struct


ModmeBot:

Reply By: Zombier
I am sorry for it many times. How can I use different sounds?


ModmeBot:

Reply By: mathfag

Zombier
I am sorry for it many times. How can I use different sounds?


panzer_dab0,,,custom\dab_effect.wav,,,UIN_MOD,,,,,,,,,0,0,95,100,0,500,700,,,,,,,,,,,,,,,,2d,,,LOOPING,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
panzer_dab1,,,custom\69pussy.wav,,,UIN_MOD,,,,,,,,,0,0,95,100,0,500,700,,,,,,,,,,,,,,,,2d,,,LOOPING,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
panzer_dab2,,,custom\richtofen_is_gay.wav,,,UIN_MOD,,,,,,,,,0,0,95,100,0,500,700,,,,,,,,,,,,,,,,2d,,,LOOPING,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,


ModmeBot:

Reply By: Zombier
Sound alias I have

power_sound0,,,zombie\ambs\perk_siren.wav,,,UIN_MOD,,,,,,,,,0,0,85,85,0,900,1000,,,,,,,,,,,,,,,,3d,,,LOOPING,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
power_sound1,,,zombie\ambs\numbers.wav,,,UIN_MOD,,,,,,,,,0,0,85,85,0,900,1000,,,,,,,,,,,,,,,,3d,,,LOOPING,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
power_sound2,,,zombie\test.wav,,,UIN_MOD,,,,,,,,,0,0,95,100,0,500,700,,,,,,,,,,,,,,,,3d,,,LOOPING,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,



Is this a power_sound for song name?
Should I do this like this?
struct[i] PlaySound("power_sound"+i);


ModmeBot:

Reply By: mathfag

Zombier
Sound alias I have power_sound0,,,zombie\ambs\perk_siren.wav,,,UIN_MOD,,,,,,,,,0,0,85,85,0,900,1000,,,,,,,,,,,,,,,,3d,,,LOOPING,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, power_sound1,,,zombie\ambs\numbers.wav,,,UIN_MOD,,,,,,,,,0,0,85,85,0,900,1000,,,,,,,,,,,,,,,,3d,,,LOOPING,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, power_sound2,,,zombie\test.wav,,,UIN_MOD,,,,,,,,,0,0,95,100,0,500,700,,,,,,,,,,,,,,,,3d,,,LOOPING,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Is this a power_sound for song name? Should I do this like this? structPlaySound("power_sound"+i);
I noticed you have LOOPING in the alias. This works for NONLOOPING only but if you want looping you can just change PlaySound() to PlayLoopSound(). Stuff inside stays the same.


ModmeBot:

Reply By: Zombier
Does it work with script_sound?