Daemon666 / CSB Pause Публичный

/pause freezes the match at the end of the round - maxspeed 1, blocked fire and a MATCH PAUSED HUD - with a countdown /unpause and a per-team limit.

v1.0.0 120 загрузок GPL-3.0 Обновлено Aug 23, 2026
csb_pause.sma v1.0.0 209 строк · 5.4 KB Исходный текст
1 /*
2 * CSB Pause
3 * Copyright (C) 2026 counter-strike-boost.com
4 *
5 * Match pause tool. /pause freezes the game at the end of the current round:
6 * players are clamped to maxspeed 1, firing is blocked with a Ham
7 * Weapon_PrimaryAttack supercede, and a "MATCH PAUSED" HUD is shown. /unpause
8 * runs a short countdown and resumes. Pauses are limited per team.
9 *
10 * This program is free software: you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License as published by the Free Software
12 * Foundation, either version 3 of the License, or (at your option) any later
13 * version. It is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 * A PARTICULAR PURPOSE. See <https://www.gnu.org/licenses/> for details.
16 */
17
18 #include <amxmodx>
19 #include <hamsandwich>
20 #include <fun>
21
22 new const PLUGIN[] = "CSB Pause"
23 new const VERSION[] = "1.0.0"
24 new const AUTHOR[] = "counter-strike-boost.com"
25
26 #define TASK_FREEZE 5300
27 #define TASK_RESUME 5400
28
29 new bool:g_bPaused
30 new bool:g_bPendingPause
31 new bool:g_bResuming
32 new g_iPauseUsed[3] /* index by team: 1 = T, 2 = CT */
33 new g_iResumeLeft
34
35 new g_pEnabled, g_pMaxPerTeam
36
37 new const g_szWeapons[][] =
38 {
39 "weapon_p228", "weapon_scout", "weapon_hegrenade", "weapon_xm1014",
40 "weapon_mac10", "weapon_aug", "weapon_smokegrenade", "weapon_elite",
41 "weapon_fiveseven", "weapon_ump45", "weapon_sg550", "weapon_galil",
42 "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp",
43 "weapon_mp5navy", "weapon_m249", "weapon_m3", "weapon_m4a1",
44 "weapon_tmp", "weapon_g3sg1", "weapon_deagle", "weapon_sg552",
45 "weapon_ak47", "weapon_knife", "weapon_p90", "weapon_flashbang"
46 }
47
48 public plugin_init()
49 {
50 register_plugin(PLUGIN, VERSION, AUTHOR)
51
52 g_pEnabled = register_cvar("csb_pause_enabled", "1")
53 g_pMaxPerTeam = register_cvar("csb_pause_maxperteam", "2")
54
55 register_clcmd("say /pause", "cmdPause")
56 register_clcmd("say_team /pause", "cmdPause")
57 register_clcmd("say /unpause", "cmdUnpause")
58 register_clcmd("say_team /unpause", "cmdUnpause")
59
60 for (new i = 0; i < sizeof(g_szWeapons); i++)
61 RegisterHam(Ham_Weapon_PrimaryAttack, g_szWeapons[i], "fwPrimaryAttack")
62
63 register_event("HLTV", "eNewRound", "a", "1=0", "2=0")
64 set_task(0.5, "taskFreeze", TASK_FREEZE, _, _, "b")
65 }
66
67 public cmdPause(id)
68 {
69 if (!get_pcvar_num(g_pEnabled))
70 return PLUGIN_HANDLED
71
72 new team = get_user_team(id)
73
74 if (team != 1 && team != 2)
75 {
76 client_print(id, print_chat, "[CSB] Only players in a team can pause.")
77 return PLUGIN_HANDLED
78 }
79
80 if (g_bPaused || g_bPendingPause)
81 {
82 client_print(id, print_chat, "[CSB] A pause is already active or pending.")
83 return PLUGIN_HANDLED
84 }
85
86 new maxPer = get_pcvar_num(g_pMaxPerTeam)
87
88 if (maxPer > 0 && g_iPauseUsed[team] >= maxPer)
89 {
90 client_print(id, print_chat, "[CSB] Your team has used all %d pause(s).", maxPer)
91 return PLUGIN_HANDLED
92 }
93
94 g_iPauseUsed[team]++
95 g_bPendingPause = true
96
97 new name[32]
98 get_user_name(id, name, charsmax(name))
99 chatAll("^x04[CSB]^x03 %s^x01 requested a pause - it will start at the end of this round.", name)
100
101 return PLUGIN_HANDLED
102 }
103
104 public cmdUnpause(id)
105 {
106 if (!g_bPaused || g_bResuming)
107 return PLUGIN_HANDLED
108
109 new team = get_user_team(id)
110
111 if (team != 1 && team != 2)
112 return PLUGIN_HANDLED
113
114 g_bResuming = true
115 g_iResumeLeft = 3
116
117 new name[32]
118 get_user_name(id, name, charsmax(name))
119 chatAll("^x04[CSB]^x03 %s^x01 un-paused - resuming in 3...", name)
120
121 set_task(1.0, "taskResume", TASK_RESUME, _, _, "a", 3)
122 return PLUGIN_HANDLED
123 }
124
125 public taskResume()
126 {
127 g_iResumeLeft--
128
129 if (g_iResumeLeft > 0)
130 {
131 client_print(0, print_center, "Resuming in %d...", g_iResumeLeft)
132 return
133 }
134
135 g_bPaused = false
136 g_bResuming = false
137 unfreezeAll()
138 chatAll("^x04[CSB]^x01 *** MATCH RESUMED *** GO!")
139 server_cmd("sv_restartround 1")
140 }
141
142 public eNewRound()
143 {
144 if (g_bPendingPause && !g_bPaused)
145 {
146 g_bPendingPause = false
147 g_bPaused = true
148 set_cvar_num("mp_freezetime", 9999)
149 chatAll("^x04[CSB]^x01 *** MATCH PAUSED *** type /unpause when both teams are ready.")
150 }
151 }
152
153 public taskFreeze()
154 {
155 if (!g_bPaused)
156 return
157
158 set_hudmessage(255, 40, 40, -1.0, 0.30, 0, 0.0, 0.6, 0.0, 0.0, -1)
159 show_hudmessage(0, "MATCH PAUSED^ntype /unpause to resume")
160
161 new players[32], num, pid
162 get_players(players, num, "ae")
163
164 for (new i = 0; i < num; i++)
165 {
166 pid = players[i]
167 set_user_maxspeed(pid, 1.0)
168 }
169 }
170
171 unfreezeAll()
172 {
173 set_cvar_num("mp_freezetime", 0)
174
175 new players[32], num, pid
176 get_players(players, num, "ae")
177
178 for (new i = 0; i < num; i++)
179 {
180 pid = players[i]
181 set_user_maxspeed(pid, -1.0) /* -1 restores the default weapon speed */
182 }
183 }
184
185 public fwPrimaryAttack(weapon)
186 {
187 if (g_bPaused)
188 return HAM_SUPERCEDE
189
190 return HAM_IGNORED
191 }
192
193 chatAll(const fmt[], any:...)
194 {
195 new msg[192]
196 vformat(msg, charsmax(msg), fmt, 2)
197
198 new players[32], num, msgid = get_user_msgid("SayText")
199 get_players(players, num, "ch")
200
201 for (new i = 0; i < num; i++)
202 {
203 message_begin(MSG_ONE, msgid, _, players[i])
204 write_byte(players[i])
205 write_string(msg)
206 message_end()
207 }
208 }
209