Skip to content

Instantly share code, notes, and snippets.

Created Sep 12, 2016
Embed
What would you like to do?
if SERVER then
util.AddNetworkString("EndRoundSong")
util.AddNetworkString("EndRoundSongStop")
EndRoundMusic = EndRoundMusic or {}
EndRoundMusic.InnocentSongs = {}
EndRoundMusic.TraitorSongs = {}
EndRoundMusic.TimeLimitSongs = {}
--Check if EndRound folder exist
if file.Exists( "sound/endround/", "GAME" ) then
--Innocent
if file.Exists( "sound/endround/innocent/", "GAME" ) then
local files, directories = file.Find("sound/endround/innocent/*", "GAME")
for _,v in pairs(files) do
local path = "sound/endround/innocent/"..v
table.insert(EndRoundMusic.InnocentSongs, path)
resource.AddFile( "sound/endround/innocent/"..v )
end
--Create the innocent file if it isnt there
else
end
--Traitor
if file.Exists( "sound/endround/traitor/", "GAME" ) then
local files, directories = file.Find("sound/endround/traitor/*", "GAME")
for _,v in pairs(files) do
local path = "sound/endround/traitor/"..v
table.insert(EndRoundMusic.TraitorSongs, path)
resource.AddFile( "sound/endround/traitor/"..v )
end
--Create the Traitor file if it isnt there
else
end
--Time Limit
if file.Exists( "sound/endround/timelimit/", "GAME" ) then
local files, directories = file.Find("sound/endround/timelimit/*", "GAME")
for _,v in pairs(files) do
local path = "sound/endround/timelimit/"..v
table.insert(EndRoundMusic.TimeLimitSongs, path)
resource.AddFile( "sound/endround/timelimit/"..v )
end
--Create the Time Limit file if it isnt there
else
end
hook.Add( "TTTEndRound", "EndRoundMusicStart", function( result )
if result == "WIN_TRAITOR" then
EndRoundMusic.song = EndRoundMusic.TraitorSongs[math.random( 1, #EndRoundMusic.TraitorSongs )] or ""
elseif result == "WIN_INNOCENT" then
EndRoundMusic.song = EndRoundMusic.InnocentSongs[math.random( 1, #EndRoundMusic.InnocentSongs )] or ""
elseif result == "WIN_TIMELIMIT" then
EndRoundMusic.song = EndRoundMusic.TimeLimitSongs[math.random( 1, #EndRoundMusic.TimeLimitSongs )] or ""
end
net.Start( "EndRoundSong" )
net.WriteString( EndRoundMusic.song )
net.WriteString( result )
net.Broadcast()
end)
hook.Add( "TTTBeginRound", "EndRoundMusicStop", function()
net.Start( "EndRoundSongStop" )
net.WriteString( "stop" )
net.Broadcast()
end)
--Create EndRound folder
else
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment