Initial release 1.0.0
Browse Source1.0.0 - Initial release.
4 changed files
with 325 additions and 0 deletions
A
CHANGELOG.md
+3 -0
A
README.md
+1 -0
A
addons/amxmodx/scripting/csb_captains_pick.sma
+274 -0
A
csb.json
+47 -0
CHANGELOG.md
A
| @@ -0,0 +1,3 @@ | ||
| 1 | +## 1.0.0 (2026-04-02) | |
| 2 | + | |
| 3 | +1.0.0 - Initial release. |
README.md
A
| @@ -0,0 +1 @@ | ||
| 1 | +<p><strong>CSB Captains Pick</strong> runs a classic captain draft. An admin starts it with <code>amx_captains</code>; the two highest-ranked players (by frags) become the T and CT captains. They then take turns picking from a menu of the remaining players - each pick is moved onto the captain's team with <code>cs_set_user_team</code> - until everyone is assigned. A HUD shows whose turn it is, which side they pick for and how many players are left, and the match restarts when the draft is done.</p><h2>Features</h2><ul><li><code>amx_captains</code> starts the draft; top two frags become captains.</li><li>Menu-driven alternating picks, moved with <code>cs_set_user_team</code>.</li><li>Turn / roster HUD for the whole server.</li><li>Captain disconnect cancels the draft cleanly.</li></ul><h2>Installation</h2><ol><li>Enable the <code>cstrike</code> module in <code>modules.ini</code>.</li><li>Compile <code>csb_captains_pick.sma</code>, copy it to <code>addons/amxmodx/plugins/</code> and add it to <code>plugins.ini</code>.</li><li>Change the map.</li></ol> |
addons/amxmodx/scripting/csb_captains_pick.sma
A
| @@ -0,0 +1,274 @@ | ||
| 1 | +/* | |
| 2 | + * CSB Captains Pick | |
| 3 | + * Copyright (C) 2026 counter-strike-boost.com | |
| 4 | + * | |
| 5 | + * Captain draft. Two captains are chosen (the two highest-ranked players by | |
| 6 | + * frags, or named by an admin) and pick the remaining players alternately from a | |
| 7 | + * menu until both teams are full. Each pick is moved with cs_set_user_team, and a | |
| 8 | + * HUD shows whose turn it is together with the current rosters. | |
| 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 <cstrike> | |
| 21 | + | |
| 22 | +new const PLUGIN[] = "CSB Captains Pick" | |
| 23 | +new const VERSION[] = "1.0.0" | |
| 24 | +new const AUTHOR[] = "counter-strike-boost.com" | |
| 25 | + | |
| 26 | +new g_pEnabled | |
| 27 | +new bool:g_bActive | |
| 28 | +new g_iCapT, g_iCapCT | |
| 29 | +new g_iTurn /* 1 = T captain picks, 2 = CT captain picks */ | |
| 30 | +new bool:g_bAssigned[33] | |
| 31 | +new g_iSync | |
| 32 | + | |
| 33 | +public plugin_init() | |
| 34 | +{ | |
| 35 | + register_plugin(PLUGIN, VERSION, AUTHOR) | |
| 36 | + | |
| 37 | + g_pEnabled = register_cvar("csb_captains_enabled", "1") | |
| 38 | + | |
| 39 | + register_concmd("amx_captains", "cmdStart", ADMIN_MAP, "- start a captain draft") | |
| 40 | + register_concmd("amx_captains_stop", "cmdStop", ADMIN_MAP, "- cancel the current draft") | |
| 41 | + | |
| 42 | + register_clcmd("say /pick", "cmdPick") | |
| 43 | + register_clcmd("say_team /pick", "cmdPick") | |
| 44 | + | |
| 45 | + g_iSync = CreateHudSyncObj() | |
| 46 | + set_task(1.0, "taskHud", 0, _, _, "b") | |
| 47 | +} | |
| 48 | + | |
| 49 | +public client_disconnected(id) | |
| 50 | +{ | |
| 51 | + if (!g_bActive) | |
| 52 | + return | |
| 53 | + | |
| 54 | + if (id == g_iCapT || id == g_iCapCT) | |
| 55 | + { | |
| 56 | + client_print(0, print_chat, "^x04[CSB Draft]^x01 A captain left. Draft cancelled.") | |
| 57 | + resetDraft() | |
| 58 | + } | |
| 59 | +} | |
| 60 | + | |
| 61 | +resetDraft() | |
| 62 | +{ | |
| 63 | + g_bActive = false | |
| 64 | + g_iCapT = 0 | |
| 65 | + g_iCapCT = 0 | |
| 66 | + g_iTurn = 0 | |
| 67 | + | |
| 68 | + for (new i = 1; i <= 32; i++) | |
| 69 | + g_bAssigned[i] = false | |
| 70 | +} | |
| 71 | + | |
| 72 | +public cmdStart(id, level, cid) | |
| 73 | +{ | |
| 74 | + if (!cmd_access(id, level, cid, 1)) | |
| 75 | + return PLUGIN_HANDLED | |
| 76 | + | |
| 77 | + if (!get_pcvar_num(g_pEnabled)) | |
| 78 | + { | |
| 79 | + console_print(id, "[CSB] Captain draft is disabled.") | |
| 80 | + return PLUGIN_HANDLED | |
| 81 | + } | |
| 82 | + | |
| 83 | + new players[32], num | |
| 84 | + get_players(players, num, "c") | |
| 85 | + | |
| 86 | + if (num < 4) | |
| 87 | + { | |
| 88 | + console_print(id, "[CSB] Need at least 4 players.") | |
| 89 | + return PLUGIN_HANDLED | |
| 90 | + } | |
| 91 | + | |
| 92 | + resetDraft() | |
| 93 | + | |
| 94 | + /* two highest frag counts become captains */ | |
| 95 | + new best1 = 0, best2 = 0 | |
| 96 | + | |
| 97 | + for (new i = 0; i < num; i++) | |
| 98 | + { | |
| 99 | + new pl = players[i] | |
| 100 | + | |
| 101 | + if (!best1 || get_user_frags(pl) > get_user_frags(best1)) | |
| 102 | + { | |
| 103 | + best2 = best1 | |
| 104 | + best1 = pl | |
| 105 | + } | |
| 106 | + else if (!best2 || get_user_frags(pl) > get_user_frags(best2)) | |
| 107 | + { | |
| 108 | + best2 = pl | |
| 109 | + } | |
| 110 | + } | |
| 111 | + | |
| 112 | + g_iCapT = best1 | |
| 113 | + g_iCapCT = best2 | |
| 114 | + | |
| 115 | + cs_set_user_team(g_iCapT, CS_TEAM_T) | |
| 116 | + cs_set_user_team(g_iCapCT, CS_TEAM_CT) | |
| 117 | + | |
| 118 | + g_bAssigned[g_iCapT] = true | |
| 119 | + g_bAssigned[g_iCapCT] = true | |
| 120 | + | |
| 121 | + g_bActive = true | |
| 122 | + g_iTurn = 1 | |
| 123 | + | |
| 124 | + client_print(0, print_chat, "^x04[CSB Draft]^x01 Captains: ^x03%n^x01 (T) and ^x03%n^x01 (CT). Type /pick on your turn.", g_iCapT, g_iCapCT) | |
| 125 | + | |
| 126 | + openPickMenu(g_iCapT) | |
| 127 | + return PLUGIN_HANDLED | |
| 128 | +} | |
| 129 | + | |
| 130 | +public cmdStop(id, level, cid) | |
| 131 | +{ | |
| 132 | + if (!cmd_access(id, level, cid, 1)) | |
| 133 | + return PLUGIN_HANDLED | |
| 134 | + | |
| 135 | + resetDraft() | |
| 136 | + client_print(0, print_chat, "^x04[CSB Draft]^x01 Draft cancelled by admin.") | |
| 137 | + return PLUGIN_HANDLED | |
| 138 | +} | |
| 139 | + | |
| 140 | +currentPicker() | |
| 141 | +{ | |
| 142 | + return (g_iTurn == 1) ? g_iCapT : g_iCapCT | |
| 143 | +} | |
| 144 | + | |
| 145 | +public cmdPick(id) | |
| 146 | +{ | |
| 147 | + if (!g_bActive) | |
| 148 | + return PLUGIN_HANDLED | |
| 149 | + | |
| 150 | + if (id != currentPicker()) | |
| 151 | + { | |
| 152 | + client_print(id, print_chat, "^x04[CSB Draft]^x01 It is not your turn.") | |
| 153 | + return PLUGIN_HANDLED | |
| 154 | + } | |
| 155 | + | |
| 156 | + openPickMenu(id) | |
| 157 | + return PLUGIN_HANDLED | |
| 158 | +} | |
| 159 | + | |
| 160 | +openPickMenu(cap) | |
| 161 | +{ | |
| 162 | + if (!is_user_connected(cap)) | |
| 163 | + return | |
| 164 | + | |
| 165 | + new title[64] | |
| 166 | + formatex(title, charsmax(title), "\yCSB Draft^n\wPick a player (%s):", (g_iTurn == 1) ? "T" : "CT") | |
| 167 | + | |
| 168 | + new menu = menu_create(title, "pickHandler") | |
| 169 | + | |
| 170 | + new players[32], num, added = 0 | |
| 171 | + get_players(players, num, "c") | |
| 172 | + | |
| 173 | + for (new i = 0; i < num; i++) | |
| 174 | + { | |
| 175 | + new pl = players[i] | |
| 176 | + | |
| 177 | + if (g_bAssigned[pl]) | |
| 178 | + continue | |
| 179 | + | |
| 180 | + new entry[48], info[8] | |
| 181 | + formatex(entry, charsmax(entry), "%n", pl) | |
| 182 | + num_to_str(pl, info, charsmax(info)) | |
| 183 | + menu_additem(menu, entry, info, 0) | |
| 184 | + added++ | |
| 185 | + } | |
| 186 | + | |
| 187 | + if (!added) | |
| 188 | + { | |
| 189 | + menu_destroy(menu) | |
| 190 | + finishDraft() | |
| 191 | + return | |
| 192 | + } | |
| 193 | + | |
| 194 | + menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER) | |
| 195 | + menu_display(cap, menu, 0) | |
| 196 | +} | |
| 197 | + | |
| 198 | +public pickHandler(id, menu, item) | |
| 199 | +{ | |
| 200 | + if (item == MENU_EXIT || !g_bActive || id != currentPicker()) | |
| 201 | + { | |
| 202 | + menu_destroy(menu) | |
| 203 | + return PLUGIN_HANDLED | |
| 204 | + } | |
| 205 | + | |
| 206 | + new info[8], name[32], access, callback | |
| 207 | + menu_item_getinfo(menu, item, access, info, charsmax(info), name, charsmax(name), callback) | |
| 208 | + menu_destroy(menu) | |
| 209 | + | |
| 210 | + new pick = str_to_num(info) | |
| 211 | + | |
| 212 | + if (pick < 1 || pick > 32 || !is_user_connected(pick) || g_bAssigned[pick]) | |
| 213 | + { | |
| 214 | + openPickMenu(id) | |
| 215 | + return PLUGIN_HANDLED | |
| 216 | + } | |
| 217 | + | |
| 218 | + if (g_iTurn == 1) | |
| 219 | + cs_set_user_team(pick, CS_TEAM_T) | |
| 220 | + else | |
| 221 | + cs_set_user_team(pick, CS_TEAM_CT) | |
| 222 | + | |
| 223 | + g_bAssigned[pick] = true | |
| 224 | + | |
| 225 | + client_print(0, print_chat, "^x04[CSB Draft]^x01 %n picked %n for %s.", id, pick, (g_iTurn == 1) ? "T" : "CT") | |
| 226 | + | |
| 227 | + /* alternate the turn */ | |
| 228 | + g_iTurn = (g_iTurn == 1) ? 2 : 1 | |
| 229 | + | |
| 230 | + if (remaining() > 0) | |
| 231 | + openPickMenu(currentPicker()) | |
| 232 | + else | |
| 233 | + finishDraft() | |
| 234 | + | |
| 235 | + return PLUGIN_HANDLED | |
| 236 | +} | |
| 237 | + | |
| 238 | +remaining() | |
| 239 | +{ | |
| 240 | + new players[32], num, left = 0 | |
| 241 | + get_players(players, num, "c") | |
| 242 | + | |
| 243 | + for (new i = 0; i < num; i++) | |
| 244 | + { | |
| 245 | + if (!g_bAssigned[players[i]]) | |
| 246 | + left++ | |
| 247 | + } | |
| 248 | + | |
| 249 | + return left | |
| 250 | +} | |
| 251 | + | |
| 252 | +finishDraft() | |
| 253 | +{ | |
| 254 | + g_bActive = false | |
| 255 | + client_print(0, print_chat, "^x04[CSB Draft]^x01 Teams are set. Good luck!") | |
| 256 | + server_cmd("sv_restart 1") | |
| 257 | +} | |
| 258 | + | |
| 259 | +public taskHud() | |
| 260 | +{ | |
| 261 | + if (!g_bActive) | |
| 262 | + return | |
| 263 | + | |
| 264 | + new cap = currentPicker() | |
| 265 | + | |
| 266 | + if (!is_user_connected(cap)) | |
| 267 | + return | |
| 268 | + | |
| 269 | + new capName[32] | |
| 270 | + get_user_name(cap, capName, charsmax(capName)) | |
| 271 | + | |
| 272 | + set_hudmessage(255, 180, 0, 0.02, 0.15, 0, 0.0, 1.1, 0.0, 0.0, -1) | |
| 273 | + ShowSyncHudMsg(0, g_iSync, "DRAFT^n%s to pick (%s)^n%d player(s) left", capName, (g_iTurn == 1) ? "T" : "CT", remaining()) | |
| 274 | +} |
csb.json
A
| @@ -0,0 +1,47 @@ | ||
| 1 | +{ | |
| 2 | + "name": "CSB Captains Pick", | |
| 3 | + "category": "match", | |
| 4 | + "tags": "captains, pick, teams", | |
| 5 | + "image": "", | |
| 6 | + "original_author": "", | |
| 7 | + "original_url": "", | |
| 8 | + "license": "GPL-3.0", | |
| 9 | + "title": "CSB Captains Pick", | |
| 10 | + "short_desc": "Captain draft: two captains pick players alternately from a menu into balanced teams, with a turn/roster HUD.", | |
| 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": "cstrike", | |
| 20 | + "install_notes": "1. Enable the cstrike module in addons/amxmodx/configs/modules.ini\n2. Put csb_captains_pick.amxx in addons/amxmodx/plugins/ and add it to plugins.ini\n3. Change map", | |
| 21 | + "known_conflicts": "Auto-balance and other team-management plugins will undo picks; disable them during a draft.", | |
| 22 | + "cvars": [ | |
| 23 | + { | |
| 24 | + "name": "csb_captains_enabled", | |
| 25 | + "default": "1", | |
| 26 | + "description": "Enable or disable the captain draft." | |
| 27 | + } | |
| 28 | + ], | |
| 29 | + "commands": [ | |
| 30 | + { | |
| 31 | + "name": "amx_captains", | |
| 32 | + "access": "h (ADMIN_MAP)", | |
| 33 | + "description": "Start a captain draft." | |
| 34 | + }, | |
| 35 | + { | |
| 36 | + "name": "amx_captains_stop", | |
| 37 | + "access": "h (ADMIN_MAP)", | |
| 38 | + "description": "Cancel the current draft." | |
| 39 | + }, | |
| 40 | + { | |
| 41 | + "name": "say /pick", | |
| 42 | + "access": "", | |
| 43 | + "description": "Open your pick menu when it is your turn (captains only)." | |
| 44 | + } | |
| 45 | + ], | |
| 46 | + "main": "addons/amxmodx/scripting/csb_captains_pick.sma" | |
| 47 | +} | |
| 0 | 48 |









