Initial release 1.0.0
Browse Source1.0.0 - Initial release.
4 changed files
with 206 additions and 0 deletions
A
CHANGELOG.md
+3 -0
A
README.md
+1 -0
A
addons/amxmodx/scripting/csb_admin_password.sma
+160 -0
A
csb.json
+42 -0
CHANGELOG.md
A
| @@ -0,0 +1,3 @@ | ||
| 1 | +## 1.0.0 (2026-05-24) | |
| 2 | + | |
| 3 | +1.0.0 - Initial release. |
README.md
A
| @@ -0,0 +1 @@ | ||
| 1 | +<p><strong>CSB Admin Password</strong> is the fast way to close a server for a clan war or a private match. <code>amx_lock [password]</code> sets <code>sv_password</code> to the string you give it, or generates a short random one (ambiguous characters like 0/O and 1/I are left out), and prints the password <em>only</em> to admins. <code>amx_unlock</code> clears it again. While the server is locked a HUD reminder with the current password is shown to admins so nobody forgets it is on.</p><h2>Features</h2><ul><li><code>amx_lock [password]</code> — use your own password or get a generated one.</li><li>Random length set by <code>csb_lock_len</code> (clamped 4–20), from a confusion-free charset.</li><li>Password revealed only in the admin chat channel, never to regular players.</li><li>Recurring HUD reminder to admins while locked, kept in sync if <code>sv_password</code> is changed by hand.</li><li><code>amx_unlock</code> clears the password; both actions are logged.</li></ul><h2>Installation</h2><ol><li>Compile <code>csb_admin_password.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></ol><p>Both commands need the <code>ADMIN_PASSWORD</code> flag (<code>i</code>) by default. Remember the server must have <code>sv_lan 0</code> to appear in the master list; a password does not remove it from the list, it just gates joining.</p> |
addons/amxmodx/scripting/csb_admin_password.sma
A
| @@ -0,0 +1,160 @@ | ||
| 1 | +/* | |
| 2 | + * CSB Admin Password | |
| 3 | + * Copyright (C) 2026 counter-strike-boost.com | |
| 4 | + * | |
| 5 | + * amx_lock [password] sets sv_password to a given or randomly generated string | |
| 6 | + * and prints it only to admins; amx_unlock clears it. Handy for locking a server | |
| 7 | + * for a clan war. While locked, a HUD reminder is shown to admins and the state | |
| 8 | + * change is written to the AMXX log. | |
| 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 | + | |
| 21 | +new const PLUGIN[] = "CSB Admin Password" | |
| 22 | +new const VERSION[] = "1.0.0" | |
| 23 | +new const AUTHOR[] = "counter-strike-boost.com" | |
| 24 | + | |
| 25 | +new const CHARSET[] = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789" | |
| 26 | + | |
| 27 | +new g_pLen | |
| 28 | +new bool:g_bLocked = false | |
| 29 | +new g_szCurrent[32] | |
| 30 | + | |
| 31 | +public plugin_init() | |
| 32 | +{ | |
| 33 | + register_plugin(PLUGIN, VERSION, AUTHOR) | |
| 34 | + | |
| 35 | + g_pLen = register_cvar("csb_lock_len", "6") | |
| 36 | + | |
| 37 | + register_concmd("amx_lock", "cmdLock", ADMIN_PASSWORD, "[password] - lock the server (random if omitted)") | |
| 38 | + register_concmd("amx_unlock", "cmdUnlock", ADMIN_PASSWORD, "- unlock the server") | |
| 39 | + | |
| 40 | + set_task(30.0, "taskReminder", 0, _, _, "b") | |
| 41 | +} | |
| 42 | + | |
| 43 | +randomPassword(out[], len) | |
| 44 | +{ | |
| 45 | + new setLen = charsmax(CHARSET) /* index of terminator = length-1 */ | |
| 46 | + new i = 0 | |
| 47 | + | |
| 48 | + for (; i < len; i++) | |
| 49 | + out[i] = CHARSET[random_num(0, setLen - 1)] | |
| 50 | + | |
| 51 | + out[i] = 0 | |
| 52 | +} | |
| 53 | + | |
| 54 | +public cmdLock(id, level, cid) | |
| 55 | +{ | |
| 56 | + if (!cmd_access(id, level, cid, 1)) | |
| 57 | + return PLUGIN_HANDLED | |
| 58 | + | |
| 59 | + new pw[32] | |
| 60 | + | |
| 61 | + if (read_argc() > 1) | |
| 62 | + { | |
| 63 | + read_argv(1, pw, charsmax(pw)) | |
| 64 | + } | |
| 65 | + else | |
| 66 | + { | |
| 67 | + new n = get_pcvar_num(g_pLen) | |
| 68 | + if (n < 4) n = 4 | |
| 69 | + if (n > 20) n = 20 | |
| 70 | + randomPassword(pw, n) | |
| 71 | + } | |
| 72 | + | |
| 73 | + set_cvar_string("sv_password", pw) | |
| 74 | + copy(g_szCurrent, charsmax(g_szCurrent), pw) | |
| 75 | + g_bLocked = true | |
| 76 | + | |
| 77 | + new aname[32] | |
| 78 | + getName(id, aname, charsmax(aname)) | |
| 79 | + | |
| 80 | + announceAdmins("^x04[CSB]^x03 %s^x01 locked the server. Password:^x04 %s", aname, pw) | |
| 81 | + log_amx("[CSB Lock] %s locked the server", aname) | |
| 82 | + return PLUGIN_HANDLED | |
| 83 | +} | |
| 84 | + | |
| 85 | +public cmdUnlock(id, level, cid) | |
| 86 | +{ | |
| 87 | + if (!cmd_access(id, level, cid, 1)) | |
| 88 | + return PLUGIN_HANDLED | |
| 89 | + | |
| 90 | + set_cvar_string("sv_password", "") | |
| 91 | + g_bLocked = false | |
| 92 | + g_szCurrent[0] = 0 | |
| 93 | + | |
| 94 | + new aname[32] | |
| 95 | + getName(id, aname, charsmax(aname)) | |
| 96 | + | |
| 97 | + announceAdmins("^x04[CSB]^x03 %s^x01 unlocked the server.", aname) | |
| 98 | + log_amx("[CSB Lock] %s unlocked the server", aname) | |
| 99 | + return PLUGIN_HANDLED | |
| 100 | +} | |
| 101 | + | |
| 102 | +public taskReminder() | |
| 103 | +{ | |
| 104 | + if (!g_bLocked) | |
| 105 | + return | |
| 106 | + | |
| 107 | + /* the current sv_password may have been changed by hand - resync state */ | |
| 108 | + new live[32] | |
| 109 | + get_cvar_string("sv_password", live, charsmax(live)) | |
| 110 | + | |
| 111 | + if (!live[0]) | |
| 112 | + { | |
| 113 | + g_bLocked = false | |
| 114 | + return | |
| 115 | + } | |
| 116 | + | |
| 117 | + new players[32], num, pid | |
| 118 | + get_players(players, num, "ch") | |
| 119 | + | |
| 120 | + for (new i = 0; i < num; i++) | |
| 121 | + { | |
| 122 | + pid = players[i] | |
| 123 | + | |
| 124 | + if (!(get_user_flags(pid) & ADMIN_PASSWORD)) | |
| 125 | + continue | |
| 126 | + | |
| 127 | + set_hudmessage(255, 80, 80, 0.02, 0.05, 0, 0.0, 4.0, 0.0, 0.0, -1) | |
| 128 | + show_hudmessage(pid, "SERVER LOCKED - password: %s", live) | |
| 129 | + } | |
| 130 | +} | |
| 131 | + | |
| 132 | +announceAdmins(const fmt[], any:...) | |
| 133 | +{ | |
| 134 | + new msg[192] | |
| 135 | + vformat(msg, charsmax(msg), fmt, 2) | |
| 136 | + | |
| 137 | + new players[32], num, pid, msgid = get_user_msgid("SayText") | |
| 138 | + get_players(players, num, "ch") | |
| 139 | + | |
| 140 | + for (new i = 0; i < num; i++) | |
| 141 | + { | |
| 142 | + pid = players[i] | |
| 143 | + | |
| 144 | + if (!(get_user_flags(pid) & ADMIN_PASSWORD)) | |
| 145 | + continue | |
| 146 | + | |
| 147 | + message_begin(MSG_ONE, msgid, _, pid) | |
| 148 | + write_byte(pid) | |
| 149 | + write_string(msg) | |
| 150 | + message_end() | |
| 151 | + } | |
| 152 | +} | |
| 153 | + | |
| 154 | +getName(id, name[], len) | |
| 155 | +{ | |
| 156 | + if (id) | |
| 157 | + get_user_name(id, name, len) | |
| 158 | + else | |
| 159 | + copy(name, len, "CONSOLE") | |
| 160 | +} |
csb.json
A
| @@ -0,0 +1,42 @@ | ||
| 1 | +{ | |
| 2 | + "name": "CSB Admin Password", | |
| 3 | + "category": "admin", | |
| 4 | + "tags": "password, lock, server", | |
| 5 | + "image": "", | |
| 6 | + "original_author": "", | |
| 7 | + "original_url": "", | |
| 8 | + "license": "GPL-3.0", | |
| 9 | + "title": "CSB Admin Password", | |
| 10 | + "short_desc": "amx_lock sets sv_password (random or given) and shows it to admins only; amx_unlock clears it. A HUD reminder keeps admins aware the server is locked.", | |
| 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_admin_password.amxx in addons/amxmodx/plugins/\n2. Add it to addons/amxmodx/configs/plugins.ini\n3. Change map", | |
| 21 | + "known_conflicts": "Any plugin or RCON script that also manages sv_password can override the lock.", | |
| 22 | + "cvars": [ | |
| 23 | + { | |
| 24 | + "name": "csb_lock_len", | |
| 25 | + "default": "6", | |
| 26 | + "description": "Length of the generated password when amx_lock is used with no argument (clamped 4-20)." | |
| 27 | + } | |
| 28 | + ], | |
| 29 | + "commands": [ | |
| 30 | + { | |
| 31 | + "name": "amx_lock", | |
| 32 | + "access": "i (ADMIN_PASSWORD)", | |
| 33 | + "description": "amx_lock [password] - lock the server (random password if omitted)." | |
| 34 | + }, | |
| 35 | + { | |
| 36 | + "name": "amx_unlock", | |
| 37 | + "access": "i (ADMIN_PASSWORD)", | |
| 38 | + "description": "Unlock the server (clears sv_password)." | |
| 39 | + } | |
| 40 | + ], | |
| 41 | + "main": "addons/amxmodx/scripting/csb_admin_password.sma" | |
| 42 | +} | |
| 0 | 43 |









