/*
* CSB Round Timer
* Copyright (C) 2026 counter-strike-boost.com
*
* Draws a round countdown HUD computed from mp_roundtime and the time the round
* actually started (freezetime is added on top so the count matches the real
* clock). The timer turns red in the last 30 seconds and hides itself once the
* bomb is planted, so the C4 countdown can take over the screen.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version. It is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See for details.
*/
#include
new const PLUGIN[] = "CSB Round Timer"
new const VERSION[] = "1.0.0"
new const AUTHOR[] = "counter-strike-boost.com"
new Float:g_fRoundStart
new bool:g_bBombPlanted
new g_iSync
new g_pEnabled, g_pRoundTime, g_pFreezeTime
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_pEnabled = register_cvar("csb_timer_enabled", "1")
g_pRoundTime = get_cvar_pointer("mp_roundtime")
g_pFreezeTime = get_cvar_pointer("mp_freezetime")
g_iSync = CreateHudSyncObj()
register_logevent("eventRoundStart", 2, "1=Round_Start")
register_logevent("eventBombPlanted", 3, "2=Planted_The_Bomb")
set_task(0.5, "taskTimer", 0, _, _, "b")
}
public eventRoundStart()
{
g_fRoundStart = get_gametime()
g_bBombPlanted = false
}
public eventBombPlanted()
{
g_bBombPlanted = true
}
Float:roundLenSecs()
{
new Float:mins = 5.0
if (g_pRoundTime)
mins = get_pcvar_float(g_pRoundTime)
if (mins <= 0.0)
mins = 5.0
new Float:freeze = 0.0
if (g_pFreezeTime)
freeze = get_pcvar_float(g_pFreezeTime)
return mins * 60.0 + freeze
}
public taskTimer()
{
if (!get_pcvar_num(g_pEnabled) || g_bBombPlanted)
return
if (g_fRoundStart <= 0.0)
return
new Float:remain = roundLenSecs() - (get_gametime() - g_fRoundStart)
if (remain < 0.0)
remain = 0.0
new secs = floatround(remain, floatround_ceil)
new mm = secs / 60
new ss = secs % 60
/* red in the final 30 seconds, otherwise a calm cyan */
new r = 0, g = 200, b = 200
if (secs <= 30)
{
r = 255
g = 40
b = 40
}
set_hudmessage(r, g, b, 0.44, 0.02, 0, 0.0, 0.6, 0.0, 0.0, -1)
ShowSyncHudMsg(0, g_iSync, "%d:%02d", mm, ss)
}