Gmod Assault/Round timer?

Basically, I just need code to say Assault for 20 mins, then say Prepare for Attack for 15 minutes ( preferably timer on HUD, not mandatory ) Thanks!!

It’s pinned (you sound like you’re making a request, sorry if im wrong)

More of help, I’ve been trying to make it for a while and I can’t figure it out :confused:

Post your code then

function StartRound(startmins, endmins)
draw.DrawText( “Assault In Progress”, “TargetID”, ScrW() * 0.5, ScrH() * 0.25, Color( 255, 255, 255, 255 ), TEXT_ALIGN_TOP )
end )
timer.Create(“RoundCountdown1”, startmins * 60, 1, function()
end )
timer.Create(“RoundCountdown2”, endmins * 60, 1, function()
draw.DrawText( “Preparation Period”, “TargetID”, ScrW() * 0.5, ScrH() * 0.25, Color( 255, 255, 255, 255 ), TEXT_ALIGN_TOP )
end)

end)

end

You have to create timers on server side and then somehow network them to clients (and also send them to new players). Example:


/*
  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)

(Idk if it works, I don’t have gmod installed right now, so I can’t test it)

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 :confused: