Guest User

Untitled

a guest
Jul 31st, 2013
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. --///////////////////////////////////////// ----FEATURE LIST---- ///////////////////////////////////////////--
  2. --//// ////--
  3. --//// No need to manually resource.AddFile ////--
  4. --//// ////--
  5. --//// Three tables to add the different sounds to the different type of wins. ////--
  6. --//// ////--
  7. --//// No need to add "" in the tables, if you do, you'll actually be screwing up the resource.addfile ////--
  8. --//// ////--
  9. --//// Sounds are randomly chosen inside the table matching the proper win method ////--
  10. --//// ////--
  11. --//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
  12.  
  13. --///////////////////////////////////////// ----WARNINGS AND TIPS---- ///////////////////////////////////////////--
  14. --//// ////--
  15. --//// Remember that you can only use "/" and not "\" ////--
  16. --//// ////--
  17. --//// Remember to keep a table actually not fully empty to avoid code breaking. You can even just leave a wrong path in it ////--
  18. --//// ////--
  19. --//// For a guide on how to add new sounds, check the workshop page ////--
  20. --//// ////--
  21. --//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
  22.  
  23. -- Sounds played when the innocent win
  24. local InnocentWinSounds = {
  25. "galaxy_bounce.wav",
  26. "now_your_man.wav",
  27. "we_are_champs.wav"
  28. }
  29.  
  30. -- Sounds played when the traitors win
  31. local TraitorWinSounds = {
  32. "t_ace_of_spades.wav",
  33. "t_killing_in_name.wav",
  34. "t_voodoo_people.wav"
  35. }
  36.  
  37. -- Sounds played when time is up
  38. local OutOfTimeSounds = {
  39. "endofround.wav"
  40. }
  41.  
  42. for k, v in pairs (InnocentWinSounds) do
  43. resource.AddFile("roundmusic/galaxy_bounce.wav"..v)
  44. util.PrecacheSound("roundmusic/galaxy_bounce.wav"..v)
  45. resource.AddFile("roundmusic/now_your_man.wav"..v)
  46. util.PrecacheSound("roundmusic/now_your_man.wav"..v)
  47. resource.AddFile("roundmusic/we_are_champs.wav"..v)
  48. util.PrecacheSound("roundmusic/we_are_champs.wav"..v)
  49. end
  50.  
  51. for k, v in pairs (TraitorWinSounds) do
  52. resource.AddFile("roundmusic/t_ace_of_spade.wav"..v)
  53. util.PrecacheSound("roundmusic/t_ace_of_spade.wav"..v)
  54. resource.AddFile("roundmusic/t_killing_in_name.wav"..v)
  55. util.PrecacheSound("roundmusic/t_killing_in_name.wav"..v)
  56. resource.AddFile("roundmusic/t_voodoo_people.wav"..v)
  57. util.PrecacheSound("roundmusic/t_voodoo_people.wav"..v)
  58. end
  59.  
  60. for k, v in pairs (OutOfTimeSounds) do
  61. resource.AddFile("roundmusic/endofround.wav"..v)
  62. util.PrecacheSound("roundmusic/endofround.wav"..v)
  63. end
  64.  
  65. local function PlaySoundClip(win)
  66. if win == WIN_INNOCENT then
  67. BroadcastLua('surface.PlaySound("'..InnocentWinSounds[math.random(1, #InnocentWinSounds)]..'")')
  68. elseif win == WIN_TRAITOR then
  69. BroadcastLua('surface.PlaySound("'..TraitorWinSounds[math.random(1, #TraitorWinSounds)]..'")')
  70. elseif win == WIN_TIMELIMIT then
  71. BroadcastLua('surface.PlaySound("'..OutOfTimeSounds[math.random(1, #OutOfTimeSounds)]..'")')
  72. end
  73. end
  74. hook.Add("TTTEndRound", "SoundClipEndRound", PlaySoundClip)
Advertisement
Add Comment
Please, Sign In to add comment