/*
* CSB Connect Announce
* Copyright (C) 2026 counter-strike-boost.com
*
* Announces players joining and leaving in coloured chat, together with the
* country resolved from their IP through the geoip module (geoip_country /
* geoip_code2). Admins and VIPs get a marker in front of their name so regulars
* can see who just arrived. All text is plain (no external images), so it works
* on every client including non-Steam.
*
* Inspired by the many "Connect Announce" plugins for AMX Mod X. This is an
* independent GPL re-implementation; no original code is reused.
*
* 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 Connect Announce"
new const VERSION[] = "1.0.0"
new const AUTHOR[] = "counter-strike-boost.com"
new g_pConnect, g_pDisconnect, g_pAdminFlag, g_pVipFlag
new g_szName[33][32]
new g_szCountry[33][46]
new g_szCode[33][3]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_pConnect = register_cvar("csb_ca_connect", "1")
g_pDisconnect = register_cvar("csb_ca_disconnect", "1")
g_pAdminFlag = register_cvar("csb_ca_adminflag", "d") /* ADMIN_KICK */
g_pVipFlag = register_cvar("csb_ca_vipflag", "t") /* ADMIN_LEVEL_G / custom VIP */
}
public client_putinserver(id)
{
if (is_user_bot(id) || is_user_hltv(id))
return
get_user_name(id, g_szName[id], charsmax(g_szName[]))
new ip[32]
get_user_ip(id, ip, charsmax(ip), 1) /* 1 = strip the port */
if (!geoip_country(ip, g_szCountry[id], charsmax(g_szCountry[])))
copy(g_szCountry[id], charsmax(g_szCountry[]), "Unknown")
if (!geoip_code2(ip, g_szCode[id]))
copy(g_szCode[id], charsmax(g_szCode[]), "??")
if (!get_pcvar_num(g_pConnect))
return
new marker[16]
getMarker(id, marker, charsmax(marker))
client_print_color(0, print_team_default,
"^x04[CSB]^x03 %s%s^x01 connected from^x04 %s^x01 (%s)",
marker, g_szName[id], g_szCountry[id], g_szCode[id])
}
public client_disconnected(id)
{
if (!get_pcvar_num(g_pDisconnect))
return
if (!g_szName[id][0])
return
client_print_color(0, print_team_default,
"^x04[CSB]^x03 %s^x01 (%s) left the server.",
g_szName[id], g_szCode[id][0] ? g_szCode[id] : "??")
g_szName[id][0] = 0
g_szCountry[id][0] = 0
g_szCode[id][0] = 0
}
getMarker(id, out[], len)
{
new flags = get_user_flags(id)
new adminFlag[4], vipFlag[4]
get_pcvar_string(g_pAdminFlag, adminFlag, charsmax(adminFlag))
get_pcvar_string(g_pVipFlag, vipFlag, charsmax(vipFlag))
new aBit = adminFlag[0] ? read_flags(adminFlag) : 0
new vBit = vipFlag[0] ? read_flags(vipFlag) : 0
if (aBit && (flags & aBit))
copy(out, len, "ADMIN ")
else if (vBit && (flags & vBit))
copy(out, len, "VIP ")
else
out[0] = 0
}