/*
* CSB Restart Round
* Copyright (C) 2026 counter-strike-boost.com
*
* amx_rr [delay] triggers a round restart with a countdown announcement, and
* amx_rs resets both team scores (TeamScore message) plus the plugin's stored
* totals. A lock flag prevents two overlapping restarts from stacking.
*
* 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
#include
new const PLUGIN[] = "CSB Restart Round"
new const VERSION[] = "1.0.0"
new const AUTHOR[] = "counter-strike-boost.com"
new g_pMaxDelay
new g_iCountLeft
new bool:g_bRestarting = false
new g_msgTeamScore
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_pMaxDelay = register_cvar("csb_rr_maxdelay", "10")
register_concmd("amx_rr", "cmdRestart", ADMIN_MAP, "[delay seconds] - restart the round with a countdown")
register_concmd("amx_rs", "cmdScore", ADMIN_MAP, "- reset both team scores to 0")
g_msgTeamScore = get_user_msgid("TeamScore")
}
public cmdRestart(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
if (g_bRestarting)
{
console_print(id, "[CSB] A restart is already in progress.")
return PLUGIN_HANDLED
}
new delay = 3
if (read_argc() > 1)
{
new arg[8]
read_argv(1, arg, charsmax(arg))
delay = str_to_num(arg)
}
new maxDelay = get_pcvar_num(g_pMaxDelay)
if (delay < 1)
delay = 1
if (maxDelay > 0 && delay > maxDelay)
delay = maxDelay
new aname[32]
if (id)
get_user_name(id, aname, charsmax(aname))
else
copy(aname, charsmax(aname), "CONSOLE")
g_bRestarting = true
g_iCountLeft = delay
client_print(0, print_chat, "[CSB] %s is restarting the round in %d second(s)...", aname, delay)
log_amx("[CSB Restart] %s restarted the round (delay %d)", aname, delay)
set_task(1.0, "taskCountdown", 0, _, _, "a", delay)
return PLUGIN_HANDLED
}
public taskCountdown()
{
g_iCountLeft--
if (g_iCountLeft > 0)
{
set_hudmessage(255, 170, 0, -1.0, 0.35, 0, 0.0, 1.0, 0.0, 0.0, -1)
show_hudmessage(0, "Round restarting in %d...", g_iCountLeft)
return
}
server_cmd("sv_restartround 1")
server_exec()
set_hudmessage(0, 255, 0, -1.0, 0.35, 0, 0.0, 1.5, 0.0, 0.0, -1)
show_hudmessage(0, "Round restarted!")
g_bRestarting = false
}
public cmdScore(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
/* CS reads the CT and T totals from these engine cvars on restart */
set_cvar_num("sv_restart", 0)
message_begin(MSG_ALL, g_msgTeamScore)
write_string("CT")
write_short(0)
message_end()
message_begin(MSG_ALL, g_msgTeamScore)
write_string("TERRORIST")
write_short(0)
message_end()
new aname[32]
if (id)
get_user_name(id, aname, charsmax(aname))
else
copy(aname, charsmax(aname), "CONSOLE")
client_print(0, print_chat, "[CSB] %s reset the team scores to 0 - 0.", aname)
log_amx("[CSB Restart] %s reset the team scores", aname)
return PLUGIN_HANDLED
}