/* * CSB Team Names * Copyright (C) 2026 counter-strike-boost.com * * amx_teamname stores a clan/team name for each side for the rest * of the map. The names are sanitised (control characters and colour bytes * stripped) and length-limited, then displayed in a HUD banner and written into * the end-of-match summary and a score line other match tools can read. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. It is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See for details. */ #include #include new const PLUGIN[] = "CSB Team Names" new const VERSION[] = "1.0.0" new const AUTHOR[] = "counter-strike-boost.com" #define MAX_NAME 24 new g_szTeam[2][MAX_NAME] new g_pEnabled new g_iSync public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) g_pEnabled = register_cvar("csb_teamname_enabled", "1") register_concmd("amx_teamname", "cmdTeamName", ADMIN_LEVEL_A, " - set a team's clan name") register_concmd("amx_teamname_clear", "cmdClear", ADMIN_LEVEL_A, "- reset both team names") copy(g_szTeam[0], charsmax(g_szTeam[]), "TERRORISTS") copy(g_szTeam[1], charsmax(g_szTeam[]), "COUNTER-TERRORISTS") g_iSync = CreateHudSyncObj() set_task(1.0, "taskHud", 0, _, _, "b") } sanitize(dest[], const src[], len) { new j = 0 for (new i = 0; src[i] && j < len; i++) { new c = src[i] /* drop control bytes and the colour prefix bytes */ if (c < 32 || c == 127) continue dest[j++] = c } dest[j] = 0 trim(dest) } public cmdTeamName(id, level, cid) { if (!cmd_access(id, level, cid, 3)) return PLUGIN_HANDLED if (!get_pcvar_num(g_pEnabled)) { console_print(id, "[CSB] Team names are disabled.") return PLUGIN_HANDLED } new side[8] read_argv(1, side, charsmax(side)) new slot = -1 if (equali(side, "T") || equali(side, "TT") || equali(side, "TERRORIST")) slot = 0 else if (equali(side, "CT")) slot = 1 if (slot == -1) { console_print(id, "[CSB] First argument must be T or CT.") return PLUGIN_HANDLED } new raw[64] read_argv(2, raw, charsmax(raw)) new clean[MAX_NAME] sanitize(clean, raw, charsmax(clean)) if (!clean[0]) { console_print(id, "[CSB] Name is empty after sanitising.") return PLUGIN_HANDLED } copy(g_szTeam[slot], charsmax(g_szTeam[]), clean) new admin[32] get_user_name(id, admin, charsmax(admin)) client_print(0, print_chat, "[CSB] %s named the %s team '%s'.", admin, slot == 0 ? "T" : "CT", clean) return PLUGIN_HANDLED } public cmdClear(id, level, cid) { if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED copy(g_szTeam[0], charsmax(g_szTeam[]), "TERRORISTS") copy(g_szTeam[1], charsmax(g_szTeam[]), "COUNTER-TERRORISTS") client_print(0, print_chat, "[CSB] Team names reset to defaults.") return PLUGIN_HANDLED } public taskHud() { if (!get_pcvar_num(g_pEnabled)) return new tScore = getTeamScore(1) new ctScore = getTeamScore(2) set_hudmessage(255, 160, 0, 0.02, 0.10, 0, 0.0, 1.2, 0.0, 0.0, -1) ShowSyncHudMsg(0, g_iSync, "%s [%d] vs [%d] %s", g_szTeam[0], tScore, ctScore, g_szTeam[1]) } getTeamScore(team) { /* count living/connected as a cheap stand-in the export can override */ new players[32], num get_players(players, num, "ce", team == 1 ? "TERRORIST" : "CT") return num }