ROUND_TIMER = {}
ROUND_TIMER.RoundTime = {}
ROUND_TIMER.RoundTime[Assault] = 600
ROUND_TIMER.RoundTime[Preparation] = 8
ROUND_TIMER.Time_Began = CurTime()
ROUND_TIMER.Rounds = #ROUND_TIMER.RoundTime
ROUND_TIMER.Round = "Assault"
ROUND_TIMER.GetRound = function()
return ROUND_TIMER.Round
end
ROUND_TIMER.NextRound = function()
if ROUND_TIMER.Round == "Preparation" then
ROUND_TIMER.Round = "Assault"
else
ROUND_TIMER.Round = "Preparation"
end
if SERVER then
umsg.Start("ROUND_TIMER_UpdateClient")
umsg.Short(ROUND_TIMER.Round)
umsg.End()
end
hook.Call("RoundInitiated")
hook.Call("Round_Looping")
end
if SERVER then
ROUND_TIMER.Loop = function()
timer.Adjust("Round_Timer_Mod", ROUND_TIMER.RoundTime[ROUND_TIMER.Round], 0, function()
ROUND_TIMER:NextRound()
end)
end
hook.Add("Round_Looping", "Beginning the loop, this creates a never ending round system.", ROUND_TIMER.Loop)
timer.Create("Round_Timer_Mod", ROUND_TIMER.RoundTime["ROUND_TIMER.Round"], 0, function()end)
ROUND_TIMER:Loop()
ROUND_TIMER.DisableSpawning = function(pl)
if ROUND_TIMER.Round == "Assault" then
return false
end
end
hook.Add("PlayerDeathThink", "Disable spawning if the round is in progress.", ROUND_TIMER.DisableSpawning)
ROUND_TIMER.DeathCheck = function(pl, attacker, dmginfo)
if ROUND_TIMER.Round == "Assault" then
local Num = 0
for k, v in pairs(player.GetAll()) do
if !v:Alive() then
Num = Num+1
end
end
if Num >= #player.GetAll() then
ROUND_TIMER:NextRound()
end
end
end
hook.Add("PlayerDeathThink", "Disable spawning until new round.", ROUND_TIMER.DeathCheck)
ROUND_TIMER.Initiate_Round = function()
if ROUND_TIMER.Round == "Assault" then
for k, v in pairs(player.GetAll()) do
v:PrintMessage(HUD_PRINTCENTER, "A new round has begun!")
if !v:Alive() then
v:Spawn()
end
end
end
end
hook.Add("RoundInitiated", "Round has Initiated.", ROUND_TIMER.Initiate_Round)
elseif CLIENT then
surface.CreateFont("ROUND_TIMER_Display", {
font = "Arial",
size = 25,
weight = 1000
})
usermessage.Hook("ROUND_TIMER_UpdateClient", function(msg)
ROUND_TIMER.Round = msg:ReadShort()
ROUND_TIMER.Time_Began = CurTime()
end)
ROUND_TIMER.HUD = function()
draw.SimpleTextOutlined("Round ("..ROUND_TIMER.Round..") ends in: "..math.Round((ROUND_TIMER.Time_Began+ROUND_TIMER.RoundTime[ROUND_TIMER.Round])-CurTime()), "ROUND_TIMER_Display", ScrW()/2, 20, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black)
end
hook.Add("HUDPaint", "Draw Round Timer display.", ROUND_TIMER.HUD)
end
Timer doesn’t even show up. Basically supposed to show either “Assault Ends In: (time left)” or "Preparation Ends In: (time left)
Please help!