/* * CSB Admin Chat * Copyright (C) 2026 counter-strike-boost.com * * Prefixed admin chat channels: * @text -> private channel, only admins see it * @@text -> coloured server announcement to everyone * @@@text -> centred HUD message to everyone * * Inspired by "Admin Chat Colored" by AlexALX. This is an independent GPL * re-implementation written from scratch. * * 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 Admin Chat" new const VERSION[] = "1.0.0" new const AUTHOR[] = "counter-strike-boost.com" new g_pEnabled, g_pFlag, g_pPrefix, g_pHudRed, g_pHudGreen, g_pHudBlue, g_pHudHold new g_msgSayText public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) g_pEnabled = register_cvar("csb_achat_enabled", "1") g_pFlag = register_cvar("csb_achat_flag", "d") /* ADMIN_BAN by default */ g_pPrefix = register_cvar("csb_achat_prefix", "ADMIN") g_pHudRed = register_cvar("csb_achat_hud_r", "255") g_pHudGreen = register_cvar("csb_achat_hud_g", "160") g_pHudBlue = register_cvar("csb_achat_hud_b", "0") g_pHudHold = register_cvar("csb_achat_hud_hold", "6.0") register_clcmd("say", "cmdSay") register_clcmd("say_team", "cmdSay") g_msgSayText = get_user_msgid("SayText") } public cmdSay(id) { if (!get_pcvar_num(g_pEnabled)) return PLUGIN_CONTINUE new said[192] read_args(said, charsmax(said)) remove_quotes(said) trim(said) if (said[0] != '@') return PLUGIN_CONTINUE new flagStr[8] get_pcvar_string(g_pFlag, flagStr, charsmax(flagStr)) if (!(get_user_flags(id) & read_flags(flagStr))) return PLUGIN_CONTINUE new level = 0 while (level < 3 && said[level] == '@') level++ new text[192] copy(text, charsmax(text), said[level]) trim(text) if (!text[0]) { client_print(id, print_chat, "[CSB] Usage: @message (admins) / @@message (all) / @@@message (HUD)") return PLUGIN_HANDLED } new name[32], prefix[24] get_user_name(id, name, charsmax(name)) get_pcvar_string(g_pPrefix, prefix, charsmax(prefix)) switch (level) { case 1: sendAdminChat(id, name, prefix, text) case 2: sendPublicChat(id, name, prefix, text) case 3: sendHudMessage(id, name, prefix, text) } logIt(id, level, text) return PLUGIN_HANDLED } sendAdminChat(id, const name[], const prefix[], const text[]) { new buf[192], flagStr[8] get_pcvar_string(g_pFlag, flagStr, charsmax(flagStr)) new flags = read_flags(flagStr) new alive = is_user_alive(id) ? 0 : 1 formatex(buf, charsmax(buf), "^x04(%s)%s^x03 %s^x01 : %s", prefix, alive ? "(DEAD)" : "", name, text) new players[32], num, pid get_players(players, num, "ch") for (new i = 0; i < num; i++) { pid = players[i] if (!(get_user_flags(pid) & flags)) continue message_begin(MSG_ONE, g_msgSayText, _, pid) write_byte(id) write_string(buf) message_end() } } sendPublicChat(id, const name[], const prefix[], const text[]) { new buf[192] formatex(buf, charsmax(buf), "^x04[%s]^x03 %s^x01 : ^x04%s", prefix, name, text) new players[32], num get_players(players, num, "ch") for (new i = 0; i < num; i++) { message_begin(MSG_ONE, g_msgSayText, _, players[i]) write_byte(id) write_string(buf) message_end() } } sendHudMessage(id, const name[], const prefix[], const text[]) { new Float:hold = get_pcvar_float(g_pHudHold) if (hold < 1.0) hold = 1.0 set_hudmessage(get_pcvar_num(g_pHudRed), get_pcvar_num(g_pHudGreen), get_pcvar_num(g_pHudBlue), -1.0, 0.25, 0, 0.5, hold, 0.1, 0.2, 4) show_hudmessage(0, "[%s] %s:^n%s", prefix, name, text) /* a HUD message is easy to miss, so mirror it in chat as well */ new buf[192] formatex(buf, charsmax(buf), "^x04[%s]^x03 %s^x01 : ^x04%s", prefix, name, text) new players[32], num get_players(players, num, "ch") for (new i = 0; i < num; i++) { message_begin(MSG_ONE, g_msgSayText, _, players[i]) write_byte(id) write_string(buf) message_end() } } logIt(id, level, const text[]) { new name[32], authid[35] get_user_name(id, name, charsmax(name)) get_user_authid(id, authid, charsmax(authid)) new channel[16] switch (level) { case 1: copy(channel, charsmax(channel), "admins") case 2: copy(channel, charsmax(channel), "all") case 3: copy(channel, charsmax(channel), "hud") } log_amx("[CSB Admin Chat] %s <%s> (%s): %s", name, authid, channel, text) }