Daemon666 / CSB Overtime Handler Публичен

Detects a tied score at the end of regulation and starts a repeating overtime with fresh start money and a HUD scoreboard.

v1.0.0 150 изтегляния GPL-3.0 Последна актуализация Aug 24, 2026
csb_overtime_handler.sma v1.0.0 130 реда · 3.4 KB Суров
1 /*
2 * CSB Overtime Handler
3 * Copyright (C) 2026 counter-strike-boost.com
4 *
5 * Keeps its own copy of the round score (from the CT/T win audio events) and,
6 * when regulation ends on a tie, starts an overtime: it raises mp_maxrounds by
7 * an OT block, sets a fresh OT start money and restarts the round. Overtimes
8 * repeat until one side is ahead. The live score and the current OT number are
9 * shown in a HUD sync message.
10 *
11 * This program is free software: you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License as published by the Free Software
13 * Foundation, either version 3 of the License, or (at your option) any later
14 * version. It is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See <https://www.gnu.org/licenses/> for details.
17 */
18
19 #include <amxmodx>
20
21 new const PLUGIN[] = "CSB Overtime Handler"
22 new const VERSION[] = "1.0.0"
23 new const AUTHOR[] = "counter-strike-boost.com"
24
25 #define TEAM_T 0
26 #define TEAM_CT 1
27
28 new g_pEnabled, g_pOtRounds, g_pOtMoney
29 new g_iScore[2]
30 new g_iOT
31 new g_iSync
32 new bool:g_bOtActive
33
34 public plugin_init()
35 {
36 register_plugin(PLUGIN, VERSION, AUTHOR)
37
38 g_pEnabled = register_cvar("csb_ot_enabled", "1")
39 g_pOtRounds = register_cvar("csb_ot_rounds", "3")
40 g_pOtMoney = register_cvar("csb_ot_money", "10000")
41
42 /* who won the round, from the radio win audio */
43 register_event("SendAudio", "eventTerWin", "a", "2=%!MRAD_terwin")
44 register_event("SendAudio", "eventCtWin", "a", "2=%!MRAD_ctwin")
45
46 register_logevent("eventRestart", 2, "1=World triggered", "2=Restart_Round_(1_second)")
47
48 g_iSync = CreateHudSyncObj()
49 set_task(1.0, "taskHud", 0, _, _, "b")
50 }
51
52 public eventTerWin()
53 {
54 onWin(TEAM_T)
55 }
56
57 public eventCtWin()
58 {
59 onWin(TEAM_CT)
60 }
61
62 onWin(team)
63 {
64 if (!get_pcvar_num(g_pEnabled))
65 return
66
67 g_iScore[team]++
68 checkRegulationEnd()
69 }
70
71 checkRegulationEnd()
72 {
73 new maxr = get_cvar_num("mp_maxrounds")
74
75 if (maxr <= 0)
76 return
77
78 new played = g_iScore[TEAM_T] + g_iScore[TEAM_CT]
79
80 if (played < maxr)
81 return
82
83 /* regulation (or a previous OT) is over */
84 if (g_iScore[TEAM_T] == g_iScore[TEAM_CT])
85 startOvertime()
86 }
87
88 startOvertime()
89 {
90 g_iOT++
91 g_bOtActive = true
92
93 new otRounds = get_pcvar_num(g_pOtRounds)
94
95 if (otRounds < 1)
96 otRounds = 3
97
98 /* an OT block is played on both sides -> two half-blocks */
99 new newMax = get_cvar_num("mp_maxrounds") + otRounds * 2
100 set_cvar_num("mp_maxrounds", newMax)
101
102 new money = get_pcvar_num(g_pOtMoney)
103 set_cvar_num("mp_startmoney", money)
104
105 client_print(0, print_chat, "[CSB] Scores tied %d-%d. Starting OVERTIME #%d (MR%d, $%d start).",
106 g_iScore[TEAM_T], g_iScore[TEAM_CT], g_iOT, otRounds, money)
107
108 /* restart the round to apply money and freeze */
109 set_cvar_num("sv_restart", 1)
110 }
111
112 public eventRestart()
113 {
114 /* nothing to reset here; score is kept across restarts on purpose */
115 return
116 }
117
118 public taskHud()
119 {
120 if (!get_pcvar_num(g_pEnabled))
121 return
122
123 set_hudmessage(0, 200, 255, 0.02, 0.15, 0, 0.0, 1.2, 0.0, 0.0, -1)
124
125 if (g_bOtActive)
126 ShowSyncHudMsg(0, g_iSync, "OVERTIME #%d^nT %d - %d CT", g_iOT, g_iScore[TEAM_T], g_iScore[TEAM_CT])
127 else
128 ShowSyncHudMsg(0, g_iSync, "T %d - %d CT", g_iScore[TEAM_T], g_iScore[TEAM_CT])
129 }
130