Promote server
Black Friday starts tomorrow 50% off a Master Server place and the Client list, which comes with LIFETIME PREMIUM
Starts in -- See the deals

Initial release 1.0.0

Browse Source
1.0.0 - Initial release.
Daemon666 committed commit 10ae8d59c2d8ad2a204fe13753a60073fcf38020
4 changed files with 409 additions and 0 deletions
+3 -0 CHANGELOG.md A
@@ -0,0 +1,3 @@
1 +## 1.0.0 (2025-10-08)
2 +
3 +1.0.0 - Initial release.
+1 -0 README.md A
@@ -0,0 +1 @@
1 +<p><strong>CSB Gag</strong> silences a player's <code>say</code>, <code>say_team</code> and radio commands by hooking <code>client_command()</code> and returning <code>PLUGIN_HANDLED_MAIN</code> while the gag is active &mdash; the message never reaches the engine, so no other plugin can leak it back into chat.</p><p>Gags are keyed by SteamID in a <code>Trie</code> for O(1) lookups and mirrored into <strong>nVault</strong>, so reconnecting does not clear the punishment. A gag of <code>0</code> minutes lasts until the map changes; anything else is a real timestamp and expires on its own.</p><p>Inspired by the well-known <em>Gag/Ungag</em> plugin by ConnorMcLeod. Independent GPL re-implementation; no original code is reused.</p><h2>Features</h2><ul><li><code>amx_gag &lt;target&gt; &lt;minutes&gt; [reason]</code> &mdash; 0 minutes = until map change.</li><li><code>amx_ungag &lt;target&gt;</code> and <code>amx_gaglist</code> (console table of who is gagged, for how long and why).</li><li>Blocks radio spam too (<code>csb_gag_radio 1</code>), which is what most gagged players fall back on.</li><li>Persists across reconnects via nVault; expired entries are removed on the next authorization.</li><li>The gagged player is told, in chat, how long is left and why &mdash; so they stop spamming <code>say</code>.</li><li>Respects <code>ADMIN_IMMUNITY</code> through <code>cmd_target()</code> and caps the duration with <code>csb_gag_max</code>.</li></ul><h2>Installation</h2><ol><li>Make sure the <code>nvault</code> module is enabled in <code>addons/amxmodx/configs/modules.ini</code>.</li><li>Compile, copy <code>csb_gag.amxx</code> into <code>addons/amxmodx/plugins/</code> and add it to <code>plugins.ini</code>.</li><li>Change the map. The vault file <code>csb_gag.vault</code> appears in <code>addons/amxmodx/data/vault/</code> on the first gag.</li></ol>
+348 -0 addons/amxmodx/scripting/csb_gag.sma A
@@ -0,0 +1,348 @@
1 +/*
2 + * CSB Gag
3 + * Copyright (C) 2026 counter-strike-boost.com
4 + *
5 + * Timed chat/radio gags that survive a reconnect. Gags are held in a Trie keyed
6 + * by SteamID for O(1) lookups and mirrored into nVault so a rage-quit does not
7 + * clear the punishment.
8 + *
9 + * Inspired by the well-known "Gag/Ungag" plugin by ConnorMcLeod. This is an
10 + * independent GPL re-implementation; no original code is reused.
11 + *
12 + * This program is free software: you can redistribute it and/or modify it under
13 + * the terms of the GNU General Public License as published by the Free Software
14 + * Foundation, either version 3 of the License, or (at your option) any later
15 + * version. It is distributed in the hope that it will be useful, but WITHOUT
16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 + * FOR A PARTICULAR PURPOSE. See <https://www.gnu.org/licenses/> for details.
18 + */
19 +
20 +#include <amxmodx>
21 +#include <amxmisc>
22 +#include <nvault>
23 +
24 +new const PLUGIN[] = "CSB Gag"
25 +new const VERSION[] = "1.0.0"
26 +new const AUTHOR[] = "counter-strike-boost.com"
27 +
28 +#define NO_VAULT (-1)
29 +
30 +new Trie:g_tGags
31 +new g_iVault = NO_VAULT
32 +
33 +new g_iGagUntil[33] /* unix timestamp, 0 = not gagged */
34 +new g_szGagReason[33][64]
35 +new g_szAuth[33][35]
36 +
37 +new g_pEnabled, g_pBlockRadio, g_pMaxMinutes
38 +
39 +new const g_szBlocked[][] =
40 +{
41 + "say",
42 + "say_team",
43 + "radio1",
44 + "radio2",
45 + "radio3"
46 +}
47 +
48 +public plugin_init()
49 +{
50 + register_plugin(PLUGIN, VERSION, AUTHOR)
51 +
52 + g_pEnabled = register_cvar("csb_gag_enabled", "1")
53 + g_pBlockRadio = register_cvar("csb_gag_radio", "1")
54 + g_pMaxMinutes = register_cvar("csb_gag_max", "1440")
55 +
56 + register_concmd("amx_gag", "cmdGag", ADMIN_KICK, "<name or #userid> <minutes, 0 = until map change> [reason]")
57 + register_concmd("amx_ungag", "cmdUngag", ADMIN_KICK, "<name or #userid>")
58 + register_concmd("amx_gaglist", "cmdGagList", ADMIN_KICK, "- lists the gagged players currently on the server")
59 +
60 + g_tGags = TrieCreate()
61 +}
62 +
63 +public plugin_cfg()
64 +{
65 + g_iVault = nvault_open("csb_gag")
66 +
67 + if (g_iVault == NO_VAULT)
68 + log_amx("[CSB Gag] could not open the nVault file 'csb_gag' - gags will not persist.")
69 +}
70 +
71 +public plugin_end()
72 +{
73 + if (g_iVault != NO_VAULT)
74 + nvault_close(g_iVault)
75 +
76 + TrieDestroy(g_tGags)
77 +}
78 +
79 +/* ---------- state ---------- */
80 +
81 +public client_authorized(id)
82 +{
83 + g_iGagUntil[id] = 0
84 + g_szGagReason[id][0] = 0
85 + g_szAuth[id][0] = 0
86 +
87 + if (is_user_bot(id) || is_user_hltv(id))
88 + return
89 +
90 + get_user_authid(id, g_szAuth[id], charsmax(g_szAuth[]))
91 +
92 + new expire = 0
93 +
94 + if (!TrieGetCell(g_tGags, g_szAuth[id], expire) && g_iVault != NO_VAULT)
95 + {
96 + new value[16]
97 +
98 + if (nvault_get(g_iVault, g_szAuth[id], value, charsmax(value)))
99 + expire = str_to_num(value)
100 + }
101 +
102 + /* 0 stored in the trie means "until map change", which is still active */
103 + if (expire == -1)
104 + {
105 + g_iGagUntil[id] = -1
106 + return
107 + }
108 +
109 + if (expire > get_systime())
110 + {
111 + g_iGagUntil[id] = expire
112 + TrieSetCell(g_tGags, g_szAuth[id], expire)
113 + }
114 + else if (expire > 0)
115 + {
116 + clearGag(g_szAuth[id])
117 + }
118 +}
119 +
120 +public client_disconnected(id)
121 +{
122 + g_iGagUntil[id] = 0
123 + g_szGagReason[id][0] = 0
124 + g_szAuth[id][0] = 0
125 +}
126 +
127 +/* ---------- blocking ---------- */
128 +
129 +public client_command(id)
130 +{
131 + if (!get_pcvar_num(g_pEnabled) || !isGagged(id))
132 + return PLUGIN_CONTINUE
133 +
134 + new cmd[24]
135 + read_argv(0, cmd, charsmax(cmd))
136 +
137 + new blockRadio = get_pcvar_num(g_pBlockRadio)
138 +
139 + for (new i = 0; i < sizeof(g_szBlocked); i++)
140 + {
141 + if (!equali(cmd, g_szBlocked[i]))
142 + continue
143 +
144 + if (i >= 2 && !blockRadio)
145 + return PLUGIN_CONTINUE
146 +
147 + if (i < 2)
148 + {
149 + new left[32]
150 +
151 + if (g_iGagUntil[id] == -1)
152 + copy(left, charsmax(left), "until the map changes")
153 + else
154 + formatex(left, charsmax(left), "for %d more minute(s)", ((g_iGagUntil[id] - get_systime()) / 60) + 1)
155 +
156 + client_print(id, print_chat, "[CSB] You are gagged %s. Reason: %s", left,
157 + g_szGagReason[id][0] ? g_szGagReason[id] : "no reason given")
158 + }
159 +
160 + return PLUGIN_HANDLED_MAIN
161 + }
162 +
163 + return PLUGIN_CONTINUE
164 +}
165 +
166 +bool:isGagged(id)
167 +{
168 + if (!g_iGagUntil[id])
169 + return false
170 +
171 + if (g_iGagUntil[id] == -1)
172 + return true
173 +
174 + if (g_iGagUntil[id] <= get_systime())
175 + {
176 + clearGag(g_szAuth[id])
177 + g_iGagUntil[id] = 0
178 + client_print(id, print_chat, "[CSB] Your gag has expired, you can talk again.")
179 + return false
180 + }
181 +
182 + return true
183 +}
184 +
185 +/* ---------- commands ---------- */
186 +
187 +public cmdGag(id, level, cid)
188 +{
189 + if (!cmd_access(id, level, cid, 2))
190 + return PLUGIN_HANDLED
191 +
192 + new arg[32], minsArg[8], reason[64]
193 + read_argv(1, arg, charsmax(arg))
194 + read_argv(2, minsArg, charsmax(minsArg))
195 + read_argv(3, reason, charsmax(reason))
196 +
197 + new target = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY)
198 +
199 + if (!target)
200 + return PLUGIN_HANDLED
201 +
202 + new mins = str_to_num(minsArg)
203 + new maxMins = get_pcvar_num(g_pMaxMinutes)
204 +
205 + if (mins < 0)
206 + mins = 0
207 +
208 + if (maxMins > 0 && mins > maxMins)
209 + mins = maxMins
210 +
211 + if (!reason[0])
212 + copy(reason, charsmax(reason), "no reason given")
213 +
214 + new expire = mins > 0 ? (get_systime() + mins * 60) : -1
215 +
216 + g_iGagUntil[target] = expire
217 + copy(g_szGagReason[target], charsmax(g_szGagReason[]), reason)
218 +
219 + if (g_szAuth[target][0])
220 + {
221 + TrieSetCell(g_tGags, g_szAuth[target], expire)
222 +
223 + if (g_iVault != NO_VAULT && expire > 0)
224 + {
225 + new value[16]
226 + num_to_str(expire, value, charsmax(value))
227 + nvault_pset(g_iVault, g_szAuth[target], value)
228 + }
229 + }
230 +
231 + new aname[32], tname[32], msg[192]
232 + getAdminName(id, aname, charsmax(aname))
233 + get_user_name(target, tname, charsmax(tname))
234 +
235 + if (mins > 0)
236 + formatex(msg, charsmax(msg), "^x04[CSB]^x03 %s^x01 gagged^x03 %s^x01 for^x04 %d^x01 minute(s) (%s)", aname, tname, mins, reason)
237 + else
238 + formatex(msg, charsmax(msg), "^x04[CSB]^x03 %s^x01 gagged^x03 %s^x01 until the map changes (%s)", aname, tname, reason)
239 +
240 + chatAll(msg)
241 + log_amx("[CSB Gag] %s gagged %s (%s) for %d min: %s", aname, tname, g_szAuth[target], mins, reason)
242 +
243 + return PLUGIN_HANDLED
244 +}
245 +
246 +public cmdUngag(id, level, cid)
247 +{
248 + if (!cmd_access(id, level, cid, 2))
249 + return PLUGIN_HANDLED
250 +
251 + new arg[32]
252 + read_argv(1, arg, charsmax(arg))
253 +
254 + new target = cmd_target(id, arg, 0)
255 +
256 + if (!target)
257 + return PLUGIN_HANDLED
258 +
259 + if (!g_iGagUntil[target])
260 + {
261 + console_print(id, "[CSB] That player is not gagged.")
262 + return PLUGIN_HANDLED
263 + }
264 +
265 + g_iGagUntil[target] = 0
266 + g_szGagReason[target][0] = 0
267 + clearGag(g_szAuth[target])
268 +
269 + new aname[32], tname[32], msg[192]
270 + getAdminName(id, aname, charsmax(aname))
271 + get_user_name(target, tname, charsmax(tname))
272 +
273 + formatex(msg, charsmax(msg), "^x04[CSB]^x03 %s^x01 ungagged^x03 %s^x01.", aname, tname)
274 + chatAll(msg)
275 + log_amx("[CSB Gag] %s ungagged %s", aname, tname)
276 +
277 + return PLUGIN_HANDLED
278 +}
279 +
280 +public cmdGagList(id, level, cid)
281 +{
282 + if (!cmd_access(id, level, cid, 1))
283 + return PLUGIN_HANDLED
284 +
285 + new players[32], num, pid, name[32], left[32], count = 0
286 + get_players(players, num, "ch")
287 +
288 + console_print(id, "[CSB] Gagged players:")
289 +
290 + for (new i = 0; i < num; i++)
291 + {
292 + pid = players[i]
293 +
294 + if (!g_iGagUntil[pid])
295 + continue
296 +
297 + get_user_name(pid, name, charsmax(name))
298 +
299 + if (g_iGagUntil[pid] == -1)
300 + copy(left, charsmax(left), "map change")
301 + else
302 + formatex(left, charsmax(left), "%d min", ((g_iGagUntil[pid] - get_systime()) / 60) + 1)
303 +
304 + console_print(id, " %-24s %-22s %-12s %s", name, g_szAuth[pid], left, g_szGagReason[pid])
305 + count++
306 + }
307 +
308 + if (!count)
309 + console_print(id, " (none)")
310 +
311 + return PLUGIN_HANDLED
312 +}
313 +
314 +/* ---------- helpers ---------- */
315 +
316 +clearGag(const authid[])
317 +{
318 + if (!authid[0])
319 + return
320 +
321 + if (TrieKeyExists(g_tGags, authid))
322 + TrieDeleteKey(g_tGags, authid)
323 +
324 + if (g_iVault != NO_VAULT)
325 + nvault_remove(g_iVault, authid)
326 +}
327 +
328 +getAdminName(id, name[], len)
329 +{
330 + if (id)
331 + get_user_name(id, name, len)
332 + else
333 + copy(name, len, "CONSOLE")
334 +}
335 +
336 +chatAll(const msg[])
337 +{
338 + new players[32], num, msgid = get_user_msgid("SayText")
339 + get_players(players, num, "ch")
340 +
341 + for (new i = 0; i < num; i++)
342 + {
343 + message_begin(MSG_ONE, msgid, _, players[i])
344 + write_byte(players[i])
345 + write_string(msg)
346 + message_end()
347 + }
348 +}
+57 -0 csb.json A
@@ -0,0 +1,57 @@
1 +{
2 + "name": "CSB Gag",
3 + "category": "admin",
4 + "tags": "gag, mute, chat",
5 + "image": "",
6 + "original_author": "ConnorMcLeod (Gag/Ungag)",
7 + "original_url": "",
8 + "license": "GPL-3.0",
9 + "title": "CSB Gag",
10 + "short_desc": "Timed chat and radio gags that survive a reconnect, stored in a Trie and persisted with nVault.",
11 + "version": "1.0.0",
12 + "amxx_min": "1.9",
13 + "amxx_compile_default": "1.9",
14 + "rehlds_ok": true,
15 + "hlds_ok": true,
16 + "regamedll_required": false,
17 + "metamod_flavor": "any",
18 + "reapi_required": false,
19 + "modules": "nvault",
20 + "install_notes": "1. Enable the nvault module in addons/amxmodx/configs/modules.ini\n2. Put csb_gag.amxx in addons/amxmodx/plugins/\n3. Add it to plugins.ini\n4. Change map",
21 + "known_conflicts": "Any other gag/mute plugin that also hooks say - run only one of them.",
22 + "cvars": [
23 + {
24 + "name": "csb_gag_enabled",
25 + "default": "1",
26 + "description": "Enable or disable gag enforcement."
27 + },
28 + {
29 + "name": "csb_gag_radio",
30 + "default": "1",
31 + "description": "Also block radio commands while gagged."
32 + },
33 + {
34 + "name": "csb_gag_max",
35 + "default": "1440",
36 + "description": "Maximum gag length in minutes an admin may set (0 = no cap)."
37 + }
38 + ],
39 + "commands": [
40 + {
41 + "name": "amx_gag",
42 + "access": "c (ADMIN_KICK)",
43 + "description": "amx_gag <name or #userid> <minutes, 0 = until map change> [reason]"
44 + },
45 + {
46 + "name": "amx_ungag",
47 + "access": "c (ADMIN_KICK)",
48 + "description": "amx_ungag <name or #userid>"
49 + },
50 + {
51 + "name": "amx_gaglist",
52 + "access": "c (ADMIN_KICK)",
53 + "description": "Lists the gagged players currently on the server."
54 + }
55 + ],
56 + "main": "addons/amxmodx/scripting/csb_gag.sma"
57 +}
0 58