Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --///////////////////////////////////////// ----FEATURE LIST---- ///////////////////////////////////////////--
- --//// ////--
- --//// No need to manually resource.AddFile ////--
- --//// ////--
- --//// Three tables to add the different sounds to the different type of wins. ////--
- --//// ////--
- --//// No need to add "" in the tables, if you do, you'll actually be screwing up the resource.addfile ////--
- --//// ////--
- --//// Sounds are randomly chosen inside the table matching the proper win method ////--
- --//// ////--
- --//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
- --///////////////////////////////////////// ----WARNINGS AND TIPS---- ///////////////////////////////////////////--
- --//// ////--
- --//// Remember that you can only use "/" and not "\" ////--
- --//// ////--
- --//// Remember to keep a table actually not fully empty to avoid code breaking. You can even just leave a wrong path in it ////--
- --//// ////--
- --//// For a guide on how to add new sounds, check the workshop page ////--
- --//// ////--
- --//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
- -- Sounds played when the innocent win
- local InnocentWinSounds = {
- "galaxy_bounce.wav",
- "now_your_man.wav",
- "we_are_champs.wav"
- }
- -- Sounds played when the traitors win
- local TraitorWinSounds = {
- "t_ace_of_spades.wav",
- "t_killing_in_name.wav",
- "t_voodoo_people.wav"
- }
- -- Sounds played when time is up
- local OutOfTimeSounds = {
- "endofround.wav"
- }
- for k, v in pairs (InnocentWinSounds) do
- resource.AddFile("roundmusic/galaxy_bounce.wav"..v)
- util.PrecacheSound("roundmusic/galaxy_bounce.wav"..v)
- resource.AddFile("roundmusic/now_your_man.wav"..v)
- util.PrecacheSound("roundmusic/now_your_man.wav"..v)
- resource.AddFile("roundmusic/we_are_champs.wav"..v)
- util.PrecacheSound("roundmusic/we_are_champs.wav"..v)
- end
- for k, v in pairs (TraitorWinSounds) do
- resource.AddFile("roundmusic/t_ace_of_spade.wav"..v)
- util.PrecacheSound("roundmusic/t_ace_of_spade.wav"..v)
- resource.AddFile("roundmusic/t_killing_in_name.wav"..v)
- util.PrecacheSound("roundmusic/t_killing_in_name.wav"..v)
- resource.AddFile("roundmusic/t_voodoo_people.wav"..v)
- util.PrecacheSound("roundmusic/t_voodoo_people.wav"..v)
- end
- for k, v in pairs (OutOfTimeSounds) do
- resource.AddFile("roundmusic/endofround.wav"..v)
- util.PrecacheSound("roundmusic/endofround.wav"..v)
- end
- local function PlaySoundClip(win)
- if win == WIN_INNOCENT then
- BroadcastLua('surface.PlaySound("'..InnocentWinSounds[math.random(1, #InnocentWinSounds)]..'")')
- elseif win == WIN_TRAITOR then
- BroadcastLua('surface.PlaySound("'..TraitorWinSounds[math.random(1, #TraitorWinSounds)]..'")')
- elseif win == WIN_TIMELIMIT then
- BroadcastLua('surface.PlaySound("'..OutOfTimeSounds[math.random(1, #OutOfTimeSounds)]..'")')
- end
- end
- hook.Add("TTTEndRound", "SoundClipEndRound", PlaySoundClip)
Advertisement
Add Comment
Please, Sign In to add comment