Initial release 1.0.0
Browse Source1.0.0 - Initial release.
4 changed files
with 272 additions and 0 deletions
A
CHANGELOG.md
+3 -0
A
README.md
+1 -0
A
addons/amxmodx/scripting/csb_cvar_checker.sma
+222 -0
A
csb.json
+46 -0
CHANGELOG.md
A
| @@ -0,0 +1,3 @@ | ||
| 1 | +## 1.0.0 (2025-12-17) | |
| 2 | + | |
| 3 | +1.0.0 - Initial release. |
README.md
A
| @@ -0,0 +1 @@ | ||
| 1 | +<p><strong>CSB CVar Checker</strong> queries client-side cvars with <code>query_client_cvar</code> a few seconds after a player joins and checks each answer against a rules file. Rules can require an exact value, forbid a value, enforce a numeric minimum or maximum, or simply demand that the client answers at all - a client returning <code>Bad CVAR request</code> is either missing the cvar or blocking the query.</p><h2>Features</h2><ul><li>Rules file with five modes: <code>eq</code>, <code>neq</code>, <code>max</code>, <code>min</code>, <code>any</code></li><li>Catches brightness / fog / interp style tweaks (<code>gl_fog</code>, <code>r_lightmap</code>, <code>ex_interp</code>, <code>cl_lw</code>, ...)</li><li>Log-only or kick modes</li><li>A default rules file is written on first run</li></ul><h2>Installation</h2><ol><li>Put <code>csb_cvar_checker.amxx</code> in <code>addons/amxmodx/plugins/</code></li><li>Add it to <code>plugins.ini</code></li><li>Edit <code>addons/amxmodx/configs/csb_cvar_checker.ini</code></li></ol> |
addons/amxmodx/scripting/csb_cvar_checker.sma
A
| @@ -0,0 +1,222 @@ | ||
| 1 | +/* | |
| 2 | + * CSB CVar Checker | |
| 3 | + * Copyright (C) 2026 counter-strike-boost.com | |
| 4 | + * | |
| 5 | + * Queries client-side cvars with query_client_cvar a few seconds after a player | |
| 6 | + * joins and checks each answer against a rules file. Rules can require an exact | |
| 7 | + * value, forbid a value, enforce a numeric minimum or maximum, or demand that | |
| 8 | + * the client answers at all (a client that returns "Bad CVAR request" is either | |
| 9 | + * missing the cvar or blocking the query). Offenders are logged and optionally | |
| 10 | + * kicked. Handy for catching brightness / fog / interp cheats. | |
| 11 | + * | |
| 12 | + * Inspired by the community "CVar Checker" plugins for AMX Mod X. This is an | |
| 13 | + * independent GPL re-implementation; no original code is reused. | |
| 14 | + * | |
| 15 | + * This program is free software: you can redistribute it and/or modify it under | |
| 16 | + * the terms of the GNU General Public License as published by the Free Software | |
| 17 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 18 | + * version. It is distributed in the hope that it will be useful, but WITHOUT | |
| 19 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 20 | + * FOR A PARTICULAR PURPOSE. See <https://www.gnu.org/licenses/> for details. | |
| 21 | + */ | |
| 22 | + | |
| 23 | +#include <amxmodx> | |
| 24 | + | |
| 25 | +new const PLUGIN[] = "CSB CVar Checker" | |
| 26 | +new const VERSION[] = "1.0.0" | |
| 27 | +new const AUTHOR[] = "counter-strike-boost.com" | |
| 28 | + | |
| 29 | +#define MAX_RULES 48 | |
| 30 | + | |
| 31 | +#define MODE_EQ 0 /* value must match exactly */ | |
| 32 | +#define MODE_NEQ 1 /* value must NOT match */ | |
| 33 | +#define MODE_MAX 2 /* numeric value must be <= expected */ | |
| 34 | +#define MODE_MIN 3 /* numeric value must be >= expected */ | |
| 35 | +#define MODE_ANY 4 /* client must simply answer the query */ | |
| 36 | + | |
| 37 | +new g_szRuleCvar[MAX_RULES][32] | |
| 38 | +new g_szRuleVal[MAX_RULES][32] | |
| 39 | +new g_iRuleMode[MAX_RULES] | |
| 40 | +new g_iNumRules | |
| 41 | + | |
| 42 | +new g_pEnabled, g_pDelay, g_pAction, g_pKickMsg | |
| 43 | + | |
| 44 | +public plugin_init() | |
| 45 | +{ | |
| 46 | + register_plugin(PLUGIN, VERSION, AUTHOR) | |
| 47 | + | |
| 48 | + g_pEnabled = register_cvar("csb_cc_enabled", "1") | |
| 49 | + g_pDelay = register_cvar("csb_cc_delay", "15") | |
| 50 | + g_pAction = register_cvar("csb_cc_action", "1") /* 0 = log only, 1 = kick */ | |
| 51 | + g_pKickMsg = register_cvar("csb_cc_kickmsg", "Disallowed client setting detected") | |
| 52 | +} | |
| 53 | + | |
| 54 | +public plugin_cfg() | |
| 55 | +{ | |
| 56 | + loadRules() | |
| 57 | +} | |
| 58 | + | |
| 59 | +public client_putinserver(id) | |
| 60 | +{ | |
| 61 | + if (is_user_bot(id) || is_user_hltv(id) || !get_pcvar_num(g_pEnabled) || g_iNumRules < 1) | |
| 62 | + return | |
| 63 | + | |
| 64 | + new Float:delay = get_pcvar_float(g_pDelay) | |
| 65 | + if (delay < 3.0) | |
| 66 | + delay = 3.0 | |
| 67 | + | |
| 68 | + set_task(delay, "queryAll", id) | |
| 69 | +} | |
| 70 | + | |
| 71 | +public queryAll(id) | |
| 72 | +{ | |
| 73 | + if (!is_user_connected(id)) | |
| 74 | + return | |
| 75 | + | |
| 76 | + for (new i = 0; i < g_iNumRules; i++) | |
| 77 | + query_client_cvar(id, g_szRuleCvar[i], "cvarResult") | |
| 78 | +} | |
| 79 | + | |
| 80 | +public cvarResult(id, const cvar[], const value[]) | |
| 81 | +{ | |
| 82 | + if (!is_user_connected(id)) | |
| 83 | + return | |
| 84 | + | |
| 85 | + new idx = findRule(cvar) | |
| 86 | + if (idx == -1) | |
| 87 | + return | |
| 88 | + | |
| 89 | + new bool:bad = false | |
| 90 | + new bool:noanswer = equal(value, "Bad CVAR request") | |
| 91 | + | |
| 92 | + switch (g_iRuleMode[idx]) | |
| 93 | + { | |
| 94 | + case MODE_EQ: bad = noanswer || !equal(value, g_szRuleVal[idx]) | |
| 95 | + case MODE_NEQ: bad = !noanswer && equal(value, g_szRuleVal[idx]) | |
| 96 | + case MODE_MAX: bad = noanswer || (str_to_float(value) > str_to_float(g_szRuleVal[idx])) | |
| 97 | + case MODE_MIN: bad = noanswer || (str_to_float(value) < str_to_float(g_szRuleVal[idx])) | |
| 98 | + case MODE_ANY: bad = noanswer | |
| 99 | + } | |
| 100 | + | |
| 101 | + if (!bad) | |
| 102 | + return | |
| 103 | + | |
| 104 | + new name[32], authid[35] | |
| 105 | + get_user_name(id, name, charsmax(name)) | |
| 106 | + get_user_authid(id, authid, charsmax(authid)) | |
| 107 | + | |
| 108 | + log_amx("[CSB CVarCheck] %s <%s> failed rule: %s = '%s' (mode %d, expected '%s')", | |
| 109 | + name, authid, cvar, value, g_iRuleMode[idx], g_szRuleVal[idx]) | |
| 110 | + | |
| 111 | + if (get_pcvar_num(g_pAction) == 1) | |
| 112 | + { | |
| 113 | + new msg[96] | |
| 114 | + get_pcvar_string(g_pKickMsg, msg, charsmax(msg)) | |
| 115 | + server_cmd("kick #%d ^"%s (%s)^"", get_user_userid(id), msg, cvar) | |
| 116 | + } | |
| 117 | +} | |
| 118 | + | |
| 119 | +findRule(const cvar[]) | |
| 120 | +{ | |
| 121 | + for (new i = 0; i < g_iNumRules; i++) | |
| 122 | + if (equali(g_szRuleCvar[i], cvar)) | |
| 123 | + return i | |
| 124 | + | |
| 125 | + return -1 | |
| 126 | +} | |
| 127 | + | |
| 128 | +loadRules() | |
| 129 | +{ | |
| 130 | + g_iNumRules = 0 | |
| 131 | + | |
| 132 | + new dir[128] | |
| 133 | + get_localinfo("amxx_configsdir", dir, charsmax(dir)) | |
| 134 | + | |
| 135 | + new path[160] | |
| 136 | + formatex(path, charsmax(path), "%s/csb_cvar_checker.ini", dir) | |
| 137 | + | |
| 138 | + if (!file_exists(path)) | |
| 139 | + writeDefaults(path) | |
| 140 | + | |
| 141 | + new fp = fopen(path, "rt") | |
| 142 | + if (!fp) | |
| 143 | + { | |
| 144 | + log_amx("[CSB CVarCheck] could not open %s", path) | |
| 145 | + return | |
| 146 | + } | |
| 147 | + | |
| 148 | + new line[128], cvar[32], mode[8], value[32] | |
| 149 | + | |
| 150 | + while (!feof(fp) && g_iNumRules < MAX_RULES) | |
| 151 | + { | |
| 152 | + fgets(fp, line, charsmax(line)) | |
| 153 | + trim(line) | |
| 154 | + | |
| 155 | + if (!line[0] || line[0] == ';' || (line[0] == '/' && line[1] == '/')) | |
| 156 | + continue | |
| 157 | + | |
| 158 | + /* format: cvarname mode value (value optional for "any") */ | |
| 159 | + new pos = 0 | |
| 160 | + pos = readToken(line, pos, cvar, charsmax(cvar)) | |
| 161 | + if (pos == -1) continue | |
| 162 | + pos = readToken(line, pos, mode, charsmax(mode)) | |
| 163 | + if (pos == -1) continue | |
| 164 | + readToken(line, pos, value, charsmax(value)) | |
| 165 | + | |
| 166 | + new m | |
| 167 | + if (equali(mode, "eq")) m = MODE_EQ | |
| 168 | + else if (equali(mode, "neq")) m = MODE_NEQ | |
| 169 | + else if (equali(mode, "max")) m = MODE_MAX | |
| 170 | + else if (equali(mode, "min")) m = MODE_MIN | |
| 171 | + else if (equali(mode, "any")) m = MODE_ANY | |
| 172 | + else continue | |
| 173 | + | |
| 174 | + copy(g_szRuleCvar[g_iNumRules], charsmax(g_szRuleCvar[]), cvar) | |
| 175 | + copy(g_szRuleVal[g_iNumRules], charsmax(g_szRuleVal[]), value) | |
| 176 | + g_iRuleMode[g_iNumRules] = m | |
| 177 | + g_iNumRules++ | |
| 178 | + } | |
| 179 | + | |
| 180 | + fclose(fp) | |
| 181 | + log_amx("[CSB CVarCheck] loaded %d rule(s)", g_iNumRules) | |
| 182 | +} | |
| 183 | + | |
| 184 | +writeDefaults(const path[]) | |
| 185 | +{ | |
| 186 | + new fp = fopen(path, "wt") | |
| 187 | + if (!fp) | |
| 188 | + return | |
| 189 | + | |
| 190 | + fputs(fp, "; CSB CVar Checker rules: <cvar> <mode> <value>^n") | |
| 191 | + fputs(fp, "; modes: eq (must equal), neq (must not equal), max (<=), min (>=), any (must answer)^n") | |
| 192 | + fputs(fp, "gl_fog max 1^n") | |
| 193 | + fputs(fp, "r_lightmap eq 0^n") | |
| 194 | + fputs(fp, "ex_interp max 0.1^n") | |
| 195 | + fputs(fp, "cl_lw min 1^n") | |
| 196 | + fputs(fp, "gl_max_size min 512^n") | |
| 197 | + fputs(fp, "r_drawentities eq 1^n") | |
| 198 | + fputs(fp, "cl_showevents any^n") | |
| 199 | + fclose(fp) | |
| 200 | +} | |
| 201 | + | |
| 202 | +/* Read one whitespace-delimited token starting at 'start'; returns next pos or -1. */ | |
| 203 | +readToken(const src[], start, out[], len) | |
| 204 | +{ | |
| 205 | + new i = start | |
| 206 | + | |
| 207 | + while (src[i] == ' ' || src[i] == '^t') | |
| 208 | + i++ | |
| 209 | + | |
| 210 | + if (!src[i]) | |
| 211 | + { | |
| 212 | + out[0] = 0 | |
| 213 | + return -1 | |
| 214 | + } | |
| 215 | + | |
| 216 | + new j = 0 | |
| 217 | + while (src[i] && src[i] != ' ' && src[i] != '^t' && j < len) | |
| 218 | + out[j++] = src[i++] | |
| 219 | + | |
| 220 | + out[j] = 0 | |
| 221 | + return i | |
| 222 | +} |
csb.json
A
| @@ -0,0 +1,46 @@ | ||
| 1 | +{ | |
| 2 | + "name": "CSB CVar Checker", | |
| 3 | + "category": "anticheat", | |
| 4 | + "tags": "cvars, query, cheat", | |
| 5 | + "image": "", | |
| 6 | + "original_author": "", | |
| 7 | + "original_url": "", | |
| 8 | + "license": "GPL-3.0", | |
| 9 | + "title": "CSB CVar Checker", | |
| 10 | + "short_desc": "Queries client cvars and checks them against a rules file, kicking or logging clients with disallowed values or that refuse to answer.", | |
| 11 | + "version": "1.0.0", | |
| 12 | + "amxx_min": "1.8.2", | |
| 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": "", | |
| 20 | + "install_notes": "1. Put csb_cvar_checker.amxx in addons/amxmodx/plugins/\n2. Add it to plugins.ini\n3. Edit configs/csb_cvar_checker.ini (a default is written on first run)", | |
| 21 | + "known_conflicts": "Other cvar-enforcement / anti-cheat plugins that query the same cvars.", | |
| 22 | + "cvars": [ | |
| 23 | + { | |
| 24 | + "name": "csb_cc_enabled", | |
| 25 | + "default": "1", | |
| 26 | + "description": "Enable the plugin." | |
| 27 | + }, | |
| 28 | + { | |
| 29 | + "name": "csb_cc_delay", | |
| 30 | + "default": "15", | |
| 31 | + "description": "Seconds after join before the client is queried (minimum 3)." | |
| 32 | + }, | |
| 33 | + { | |
| 34 | + "name": "csb_cc_action", | |
| 35 | + "default": "1", | |
| 36 | + "description": "0 = log only, 1 = kick offenders." | |
| 37 | + }, | |
| 38 | + { | |
| 39 | + "name": "csb_cc_kickmsg", | |
| 40 | + "default": "Disallowed client setting detected", | |
| 41 | + "description": "Message shown when a client is kicked." | |
| 42 | + } | |
| 43 | + ], | |
| 44 | + "commands": [], | |
| 45 | + "main": "addons/amxmodx/scripting/csb_cvar_checker.sma" | |
| 46 | +} | |
| 0 | 47 |









