You have to create timers on server side and then somehow network them to clients (and also send them to new players). Example:[code]/*
SERVER
*/
local PREP_TIME = 60
local ROUND_TIME = 120
function StartRound(prepTime, roundTime)
SetGlobalInt("RoundSTimerEnd", CurTime() + prepTime)
SetGlobalBool("RoundSIsPrep", true)
timer.Start("RoundSPrep", prepTime, 1, function()
SetGlobalInt("RoundSTimerEnd", CurTime() + roundTime)
SetGlobalBool("RoundSIsPrep", false)
timer.Start("RoundSActive", roundTime, 1, function()
StartRound(roundTime, prepTime)
end)
end)
end
hook.Add("InitPostEntity", "RoundStart", function()
StartRound(PREP_TIME, ROUND_TIME)
end)
/*
CLIENT
*/
hook.Add("HUDPaint", "RoundS", function()
local timerEnd = GetGlobalInt("RoundSTimerEnd")
local isPrep = GetGlobalBool("RoundIsPrep")
local text = isPrep and "Preparing: " or "Active round: "
local time = string.NiceTime(timerEnd - CurTime())
local fullMsg = text .. time
draw.DrawText(fullMsg, "DermaDefault", 0, 0, color_white, TEXT_ALIGN_LEFT)
end)[/code](Idk if it works, I don't have gmod installed right now, so I can't test it)
[QUOTE=LoweChaser;52747266]You have to create timers on server side and then somehow network them to clients (and also send them to new players). Example:[code]/*
SERVER
*/
local PREP_TIME = 60
local ROUND_TIME = 120
function StartRound(prepTime, roundTime)
SetGlobalInt("RoundSTimerEnd", CurTime() + prepTime)
SetGlobalBool("RoundSIsPrep", true)
timer.Start("RoundSPrep", prepTime, 1, function()
SetGlobalInt("RoundSTimerEnd", CurTime() + roundTime)
SetGlobalBool("RoundSIsPrep", false)
timer.Start("RoundSActive", roundTime, 1, function()
StartRound(roundTime, prepTime)
end)
end)
end
hook.Add("InitPostEntity", "RoundStart", function()
StartRound(PREP_TIME, ROUND_TIME)
end)
/*
CLIENT
*/
hook.Add("HUDPaint", "RoundS", function()
local timerEnd = GetGlobalInt("RoundSTimerEnd")
local isPrep = GetGlobalBool("RoundIsPrep")
local text = isPrep and "Preparing: " or "Active round: "
local time = string.NiceTime(timerEnd - CurTime())
local fullMsg = text .. time
draw.DrawText(fullMsg, "DermaDefault", 0, 0, color_white, TEXT_ALIGN_LEFT)
end)[/code](Idk if it works, I don't have gmod installed right now, so I can't test it)[/QUOTE]
The timer just starts in the negatives and continues getting a lower vale ( -74, -75, etc )
This MIGHT be fixable by netmessages, but I don't know how :/
Sorry, you need to Log In to post a reply to this thread.