End Round Music

Hello, I’ve recently adapted some code for start round music and some other code for end round music together to make it play a different song for each time the Ts win etc.

This is the code. I’ve not tested it but would this work?


-- You can add up to 3 sounds for this. Add or delete resource.addfile as you need
resource.AddFile("sound/yourmusic.whatever")
resource.AddFile("sound/yourmusic.whatever")
resource.AddFile("sound/yourmusic.whatever")

-- Remember to change the name of the sounds to the sound you want from above
local function PlayMusic(wintype)
   if wintype == WIN_INNOCENT then
      local List = {} // Make table
      List[1] = "itrack1.mp3" // Add to table 
      List[2] = "itrack2.mp3"   
 
      local function PlayMusic()
      BroadcastLua('surface.PlaySound("'..List[math.random(1,#List)]..'")') // Run this string with a random sound path from the list
      end

   elseif wintype == WIN_TRAITOR then
      local List = {} // Make table
      List[1] = "ttrack1.mp3" // Add to table 
      List[2] = "ttrack2.mp3"   
 
      local function PlayMusic()
      BroadcastLua('surface.PlaySound("'..List[math.random(1,#List)]..'")') // Run this string with a random sound path from the list
      end
   elseif wintype == WIN_TIMELIMIT then
      local List = {} // Make table
      List[1] = "timetrack1.mp3" // Add to table 
      List[2] = "timetrack2.mp3"   
 
      local function PlayMusic()
      BroadcastLua('surface.PlaySound("'..List[math.random(1,#List)]..'")') // Run this string with a random sound path from the list
      end
   end
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)

Seriously GlenSH… you’re starting to sound like this kid.

You should be testing code for yourself not asking others to do it for you.

Last thread: http://forum.facepunch.com/showthread.php?t=1248883

I find it funny that you didn’t even read the bloody comments in the script I gave you.
If you did … you’ll have seen:
a) If you aren’t going to use the parameters … you don’t need to include them in the function.
b) Used the small 4-lines, that adds all the files from the list to resource.AddFile
c) Used ctrl + c, ctrl + v and just edited “TTTBeginRound” to “TTTEndRound”

A and b are explained in the comments and the discussion we had in your old thread.

Sorry if I sound mad … but I get slightly annoyed when people ask for stuff … tho’ not reading it properly and just act lazy.
… oh and test your own stuff, unless you found a bug.

Son I’m disappoint