Продвинуть сервер

Initial release 1.0.0

Browse Source
1.0.0 - Initial release.
Daemon666 committed commit 91af5b7e5bb75f02a0bb20c9c3552468787289bd
4 changed files with 270 additions and 0 deletions
+3 -0 CHANGELOG.md A
@@ -0,0 +1,3 @@
1 +## 1.0.0 (2026-02-08)
2 +
3 +1.0.0 - Initial release.
+1 -0 README.md A
@@ -0,0 +1 @@
1 +<p><strong>CSB Warn System</strong> turns "final warning" into something the server actually remembers. <code>amx_warn &lt;target&gt; [reason]</code> records a warning against the player's SteamID in <strong>nVault</strong>. Reaching <code>csb_warn_kick</code> warnings kicks them; reaching the higher <code>csb_warn_ban</code> threshold bans them for <code>csb_warn_bantime</code> minutes using the engine <code>banid</code> command (and writes the ban list to disk). Warnings expire after <code>csb_warn_expire</code> days, so an old mistake does not haunt a player forever, and <code>say /warns</code> lets anyone check their own standing.</p><h2>Features</h2><ul><li><code>amx_warn &lt;name or #userid&gt; [reason]</code> &mdash; adds a warning and announces it.</li><li>Warnings persist per SteamID in nVault across map changes and restarts.</li><li>Auto-kick at one threshold, auto-ban (with <code>banid</code> + <code>writeid</code>) at a higher one.</li><li>Warnings older than <code>csb_warn_expire</code> days no longer count.</li><li><code>amx_warns &lt;target&gt;</code> for admins and <code>say /warns</code> for players to check a count.</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 <code>csb_warn_system.sma</code>, copy it to <code>addons/amxmodx/plugins/</code> and add it to <code>plugins.ini</code>.</li><li>Change the map. The vault file <code>csb_warns.vault</code> appears under <code>addons/amxmodx/data/vault/</code>.</li></ol>
+199 -0 addons/amxmodx/scripting/csb_warn_system.sma A
@@ -0,0 +1,199 @@
1 +/*
2 + * CSB Warn System
3 + * Copyright (C) 2026 counter-strike-boost.com
4 + *
5 + * amx_warn records a warning against a player's SteamID in nVault. Reaching a
6 + * cvar-defined count kicks the player; a higher count bans them for a set time
7 + * with the engine banid command. Warnings expire after N days, and say /warns
8 + * (or amx_warns) shows a player's current count.
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
14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 + * FOR A PARTICULAR PURPOSE. See <https://www.gnu.org/licenses/> for details.
16 + */
17 +
18 +#include <amxmodx>
19 +#include <amxmisc>
20 +#include <nvault>
21 +
22 +new const PLUGIN[] = "CSB Warn System"
23 +new const VERSION[] = "1.0.0"
24 +new const AUTHOR[] = "counter-strike-boost.com"
25 +
26 +#define NO_VAULT (-1)
27 +
28 +new g_iVault = NO_VAULT
29 +new g_pEnabled, g_pKickAt, g_pBanAt, g_pBanTime, g_pExpireDays
30 +
31 +public plugin_init()
32 +{
33 + register_plugin(PLUGIN, VERSION, AUTHOR)
34 +
35 + g_pEnabled = register_cvar("csb_warn_enabled", "1")
36 + g_pKickAt = register_cvar("csb_warn_kick", "3")
37 + g_pBanAt = register_cvar("csb_warn_ban", "5")
38 + g_pBanTime = register_cvar("csb_warn_bantime", "60")
39 + g_pExpireDays = register_cvar("csb_warn_expire", "7")
40 +
41 + register_concmd("amx_warn", "cmdWarn", ADMIN_KICK, "<target> [reason] - give a player a warning")
42 + register_concmd("amx_warns", "cmdWarns", ADMIN_KICK, "<target> - show a player's warning count")
43 +
44 + register_clcmd("say /warns", "cmdMyWarns")
45 + register_clcmd("say_team /warns", "cmdMyWarns")
46 +}
47 +
48 +public plugin_cfg()
49 +{
50 + g_iVault = nvault_open("csb_warns")
51 +
52 + if (g_iVault == NO_VAULT)
53 + log_amx("[CSB Warn] could not open nVault 'csb_warns' - warnings disabled.")
54 +}
55 +
56 +public plugin_end()
57 +{
58 + if (g_iVault != NO_VAULT)
59 + nvault_close(g_iVault)
60 +}
61 +
62 +/* returns the current, non-expired warning count for a SteamID */
63 +loadWarns(const authid[])
64 +{
65 + if (g_iVault == NO_VAULT)
66 + return 0
67 +
68 + new value[32]
69 +
70 + if (!nvault_get(g_iVault, authid, value, charsmax(value)))
71 + return 0
72 +
73 + new countStr[16], timeStr[16]
74 + strtok(value, countStr, charsmax(countStr), timeStr, charsmax(timeStr), ' ')
75 +
76 + new count = str_to_num(countStr)
77 + new last = str_to_num(timeStr)
78 +
79 + new expireDays = get_pcvar_num(g_pExpireDays)
80 +
81 + if (expireDays > 0 && last > 0)
82 + {
83 + new age = get_systime() - last
84 +
85 + if (age > expireDays * 86400)
86 + return 0
87 + }
88 +
89 + return count
90 +}
91 +
92 +saveWarns(const authid[], count)
93 +{
94 + if (g_iVault == NO_VAULT)
95 + return
96 +
97 + new value[32]
98 + formatex(value, charsmax(value), "%d %d", count, get_systime())
99 + nvault_pset(g_iVault, authid, value)
100 +}
101 +
102 +public cmdWarn(id, level, cid)
103 +{
104 + if (!cmd_access(id, level, cid, 1))
105 + return PLUGIN_HANDLED
106 +
107 + if (!get_pcvar_num(g_pEnabled))
108 + {
109 + console_print(id, "[CSB] Warnings are disabled.")
110 + return PLUGIN_HANDLED
111 + }
112 +
113 + new arg[32]
114 + read_argv(1, arg, charsmax(arg))
115 +
116 + new target = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY)
117 +
118 + if (!target)
119 + return PLUGIN_HANDLED
120 +
121 + new reason[64]
122 + read_argv(2, reason, charsmax(reason))
123 + trim(reason)
124 +
125 + if (!reason[0])
126 + copy(reason, charsmax(reason), "No reason given")
127 +
128 + new authid[35], tname[32]
129 + get_user_authid(target, authid, charsmax(authid))
130 + get_user_name(target, tname, charsmax(tname))
131 +
132 + new count = loadWarns(authid) + 1
133 + saveWarns(authid, count)
134 +
135 + new aname[32]
136 + if (id)
137 + get_user_name(id, aname, charsmax(aname))
138 + else
139 + copy(aname, charsmax(aname), "CONSOLE")
140 +
141 + new kickAt = get_pcvar_num(g_pKickAt)
142 + new banAt = get_pcvar_num(g_pBanAt)
143 +
144 + client_print(0, print_chat, "^x04[CSB]^x03 %s^x01 warned^x03 %s^x01 (%d/%d): %s",
145 + aname, tname, count, banAt, reason)
146 + log_amx("[CSB Warn] %s warned %s <%s> (%d) - %s", aname, tname, authid, count, reason)
147 +
148 + if (banAt > 0 && count >= banAt)
149 + {
150 + new banMin = get_pcvar_num(g_pBanTime)
151 + client_print(0, print_chat, "[CSB] %s reached %d warnings and was banned for %d minutes.", tname, count, banMin)
152 + server_cmd("banid %d #%d kick", banMin, get_user_userid(target))
153 + server_cmd("writeid")
154 + return PLUGIN_HANDLED
155 + }
156 +
157 + if (kickAt > 0 && count >= kickAt)
158 + {
159 + client_print(0, print_chat, "[CSB] %s reached %d warnings and was kicked.", tname, count)
160 + server_cmd("kick #%d ^"Too many warnings^"", get_user_userid(target))
161 + }
162 +
163 + return PLUGIN_HANDLED
164 +}
165 +
166 +public cmdWarns(id, level, cid)
167 +{
168 + if (!cmd_access(id, level, cid, 1))
169 + return PLUGIN_HANDLED
170 +
171 + new arg[32]
172 + read_argv(1, arg, charsmax(arg))
173 +
174 + new target = cmd_target(id, arg, CMDTARGET_ALLOW_SELF)
175 +
176 + if (!target)
177 + return PLUGIN_HANDLED
178 +
179 + new authid[35], tname[32]
180 + get_user_authid(target, authid, charsmax(authid))
181 + get_user_name(target, tname, charsmax(tname))
182 +
183 + new count = loadWarns(authid)
184 +
185 + console_print(id, "[CSB] %s has %d active warning(s) (ban at %d).", tname, count, get_pcvar_num(g_pBanAt))
186 + return PLUGIN_HANDLED
187 +}
188 +
189 +public cmdMyWarns(id)
190 +{
191 + new authid[35]
192 + get_user_authid(id, authid, charsmax(authid))
193 +
194 + new count = loadWarns(authid)
195 +
196 + client_print(id, print_chat, "[CSB] You have %d active warning(s). Ban at %d, kick at %d.",
197 + count, get_pcvar_num(g_pBanAt), get_pcvar_num(g_pKickAt))
198 + return PLUGIN_HANDLED
199 +}
+67 -0 csb.json A
@@ -0,0 +1,67 @@
1 +{
2 + "name": "CSB Warn System",
3 + "category": "admin",
4 + "tags": "warn, punish, nvault",
5 + "image": "",
6 + "original_author": "",
7 + "original_url": "",
8 + "license": "GPL-3.0",
9 + "title": "CSB Warn System",
10 + "short_desc": "amx_warn stores warnings per SteamID in nVault; reaching a count kicks, a higher count bans for a set time. Warnings expire after N days.",
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_warn_system.amxx in addons/amxmodx/plugins/ and add it to plugins.ini\n3. Change map",
21 + "known_conflicts": "Other ban systems may store bans separately from the engine banid list used here.",
22 + "cvars": [
23 + {
24 + "name": "csb_warn_enabled",
25 + "default": "1",
26 + "description": "Enable the warn command."
27 + },
28 + {
29 + "name": "csb_warn_kick",
30 + "default": "3",
31 + "description": "Warning count that triggers a kick."
32 + },
33 + {
34 + "name": "csb_warn_ban",
35 + "default": "5",
36 + "description": "Warning count that triggers a ban."
37 + },
38 + {
39 + "name": "csb_warn_bantime",
40 + "default": "60",
41 + "description": "Ban length in minutes at the ban threshold."
42 + },
43 + {
44 + "name": "csb_warn_expire",
45 + "default": "7",
46 + "description": "Days after which a warning stops counting (0 = never)."
47 + }
48 + ],
49 + "commands": [
50 + {
51 + "name": "amx_warn",
52 + "access": "c (ADMIN_KICK)",
53 + "description": "amx_warn <target> [reason] - give a player a warning."
54 + },
55 + {
56 + "name": "amx_warns",
57 + "access": "c (ADMIN_KICK)",
58 + "description": "amx_warns <target> - show a player's warning count."
59 + },
60 + {
61 + "name": "say /warns",
62 + "access": "",
63 + "description": "Show your own active warning count."
64 + }
65 + ],
66 + "main": "addons/amxmodx/scripting/csb_warn_system.sma"
67 +}
0 68