UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

easy random song/ sfx function

broken avatar :(
Created 1 year ago
by treyhexagon
0 Members and 1 Guest are viewing this topic.
253 views
broken avatar :(
×
broken avatar :(
Location: uspgh
Date Registered: 12 October 2020
Last active: 1 year ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
treyhexagon's Groups
treyhexagon's Contact & Social Links
this script is used to play a random song , sfx, or vo clip it is very basic but can be easily expanded and implimented into your map.
will need to be modified for black ops 3 if you plan to use it in that game as the gsc language changed a bit but will work fine as is in WAW and BO1
Code Snippet
Plaintext
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//Can use trigger damage or radius.// will need edited for trigger use
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//thread rand_sound();//put with thread calls//level.IsPlaying = false;//put with thread calls default is false
//use level.IsPlaying in any other audio eggs as a flag to prevent songs from overlapping and check with an
// if statement before allowing playback
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//this function can be used for music tracks, sound fx, voice overs, or whatever other kinds of sound you
//want to play
////////////////////////////////////////////////////////////////////////////////////////////////////////
rand_sound()
{


trig = getent("play_rand_song" , "targetname");

songs[songs.size] = "";//alias name in ""
songs[songs.size] = "";
songs[songs.size] = "";
songs[songs.size] = "";
songs[songs.size] = "";


song = undefined;
time = undefined;

players = getplayers();

for(;;)
{
trig waittill("trigger");
 if(level.IsPlaying == false)
{
   
    for(i = 0; i < songs.size; i++)
    {
    songs = array_randomize(songs);
    song = songs[i];
    if(song == "") time = ;// add in the alias name and set the time to be = to the length of the song in seconds for each song
    if(song == "") time = ;
    if(song == "") time = ;
    if(song == "") time = ;
    if(song == "") time = ;
        }
        for(x = 0; x < players.size; x++)
        {
        players[x] playsound(song);
       
        }

        level.IsPlaying = true;
        wait(time);
        level.IsPlaying = false;    

}

}
//thread rand_sound(); // uncomment this to reuse
}



 
 again this is a pretty basic function and was written to be a stand alone function but you could remove the trigger part of the code and set that up in another function then call this one to play a random song
Last Edit: March 05, 2023, 12:36:15 am by treyhexagon

 
Loading ...