Promotiraj s'rv'r

Initial release 1.0.0

Browse Source
1.0.0 - Initial release.
Daemon666 committed commit ef58681a3ff0b7c28a0228346b198b8a1ecbaf4e
4 changed files with 162 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 Command Access</strong> lets a server owner gate any console or say-based command behind an access flag without touching the plugin that owns it. Rules live in <code>configs/csb_cmdaccess.ini</code> as <code>&lt;command&gt; &lt;flags&gt;</code>; each mapped command is registered, and when a player without the flags runs it the plugin returns <code>PLUGIN_HANDLED</code> and prints a denial.</p><p>Say-based commands are handled too: the plugin rebuilds the full <code>say /whatever</code> line so you can restrict things like <code>say /rtv</code> to reserved slots. A default ini with a worked example is written on first load.</p><h2>Features</h2><ul><li>Command-to-flag rules from <code>configs/csb_cmdaccess.ini</code>.</li><li>Works for console commands and <code>say</code> / <code>say_team</code> commands alike.</li><li>Blocks with a clear message; allows and passes through for anyone with the flag.</li><li>Up to 48 rules, matched case-insensitively.</li></ul><h2>Installation</h2><ol><li>Compile <code>csb_command_access.sma</code> and copy it to <code>addons/amxmodx/plugins/</code>.</li><li>Add it to <code>plugins.ini</code> and change the map.</li><li>Edit <code>addons/amxmodx/configs/csb_cmdaccess.ini</code>.</li></ol><p>Because it registers the listed commands itself, load this plugin so its rules are read at map start; a map change re-reads the file.</p>
+127 -0 addons/amxmodx/scripting/csb_command_access.sma A
@@ -0,0 +1,127 @@
1 +/*
2 + * CSB Command Access
3 + * Copyright (C) 2026 counter-strike-boost.com
4 + *
5 + * Maps arbitrary console/chat commands to access flags from
6 + * configs/csb_cmdaccess.ini. Each mapped command is registered and, when a
7 + * player without the flag runs it, the plugin blocks it (PLUGIN_HANDLED) and
8 + * prints a denial. Lets owners restrict third-party or say-based commands
9 + * without recompiling them.
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 +#include <amxmisc>
21 +
22 +#define MAX_RULES 48
23 +
24 +new const PLUGIN[] = "CSB Command Access"
25 +new const VERSION[] = "1.0.0"
26 +new const AUTHOR[] = "counter-strike-boost.com"
27 +
28 +new g_szCmd[MAX_RULES][40]
29 +new g_iFlags[MAX_RULES]
30 +new g_iRuleCount = 0
31 +
32 +new g_pEnabled
33 +
34 +public plugin_init()
35 +{
36 + register_plugin(PLUGIN, VERSION, AUTHOR)
37 +
38 + g_pEnabled = register_cvar("csb_cmdaccess_enabled", "1")
39 +
40 + loadRules()
41 +}
42 +
43 +loadRules()
44 +{
45 + new dir[128]
46 + get_localinfo("amxx_configsdir", dir, charsmax(dir))
47 +
48 + new path[160]
49 + formatex(path, charsmax(path), "%s/csb_cmdaccess.ini", dir)
50 +
51 + if (!file_exists(path))
52 + {
53 + write_file(path, "; CSB Command Access - one rule per line: <command> <flags>")
54 + write_file(path, "; the command is blocked for anyone missing the flags.")
55 + write_file(path, "; example: restrict the say-based command /rtv to reserved slots")
56 + write_file(path, "; say /rtv a")
57 + }
58 +
59 + new f = fopen(path, "rt")
60 +
61 + if (!f)
62 + {
63 + log_amx("[CSB CmdAccess] could not open %s", path)
64 + return
65 + }
66 +
67 + new line[96], cmd[40], flagStr[24]
68 +
69 + while (!feof(f) && g_iRuleCount < MAX_RULES)
70 + {
71 + fgets(f, line, charsmax(line))
72 + trim(line)
73 +
74 + if (!line[0] || line[0] == ';' || line[0] == '#')
75 + continue
76 +
77 + strtok(line, cmd, charsmax(cmd), flagStr, charsmax(flagStr), ' ')
78 + trim(cmd)
79 + trim(flagStr)
80 +
81 + if (!cmd[0] || !flagStr[0])
82 + continue
83 +
84 + copy(g_szCmd[g_iRuleCount], charsmax(g_szCmd[]), cmd)
85 + g_iFlags[g_iRuleCount] = read_flags(flagStr)
86 +
87 + register_clcmd(cmd, "blockCheck")
88 + g_iRuleCount++
89 + }
90 +
91 + fclose(f)
92 +
93 + log_amx("[CSB CmdAccess] loaded %d rule(s).", g_iRuleCount)
94 +}
95 +
96 +public blockCheck(id)
97 +{
98 + if (!get_pcvar_num(g_pEnabled))
99 + return PLUGIN_CONTINUE
100 +
101 + new cmd[40]
102 + read_argv(0, cmd, charsmax(cmd))
103 +
104 + /* say-based commands arrive as "say" + argv1; rebuild the full command */
105 + if (equali(cmd, "say") || equali(cmd, "say_team"))
106 + {
107 + new rest[64]
108 + read_args(rest, charsmax(rest))
109 + remove_quotes(rest)
110 + trim(rest)
111 + formatex(cmd, charsmax(cmd), "%s %s", equali(cmd, "say") ? "say" : "say_team", rest)
112 + }
113 +
114 + for (new i = 0; i < g_iRuleCount; i++)
115 + {
116 + if (!equali(cmd, g_szCmd[i]))
117 + continue
118 +
119 + if (get_user_flags(id) & g_iFlags[i])
120 + return PLUGIN_CONTINUE
121 +
122 + client_print(id, print_chat, "[CSB] You do not have access to that command.")
123 + return PLUGIN_HANDLED
124 + }
125 +
126 + return PLUGIN_CONTINUE
127 +}
+31 -0 csb.json A
@@ -0,0 +1,31 @@
1 +{
2 + "name": "CSB Command Access",
3 + "category": "admin",
4 + "tags": "flags, access, commands",
5 + "image": "",
6 + "original_author": "",
7 + "original_url": "",
8 + "license": "GPL-3.0",
9 + "title": "CSB Command Access",
10 + "short_desc": "Maps arbitrary console/chat commands to access flags in an ini and blocks anyone without the flag - no recompiling.",
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": "",
20 + "install_notes": "1. Put csb_command_access.amxx in addons/amxmodx/plugins/\n2. Add it to addons/amxmodx/configs/plugins.ini\n3. Change map\n4. Edit addons/amxmodx/configs/csb_cmdaccess.ini",
21 + "known_conflicts": "If another plugin also registers one of the gated say-commands, load order decides which handler runs first.",
22 + "cvars": [
23 + {
24 + "name": "csb_cmdaccess_enabled",
25 + "default": "1",
26 + "description": "Enable or disable command gating."
27 + }
28 + ],
29 + "commands": [],
30 + "main": "addons/amxmodx/scripting/csb_command_access.sma"
31 +}
0 32