/*
* CSB Welcome MOTD
* Copyright (C) 2026 counter-strike-boost.com
*
* Shows a welcome MOTD (a local HTML file or a URL) once per player per map,
* after a short delay, plus a personalised coloured chat greeting that includes
* the player's name, score and country (resolved with GeoIP). A cvar makes the
* MOTD show only the first time a SteamID is ever seen, tracked with an nVault
* flag so it survives map changes and restarts.
*
* 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
#include
new const PLUGIN[] = "CSB Welcome MOTD"
new const VERSION[] = "1.0.0"
new const AUTHOR[] = "counter-strike-boost.com"
new g_pEnabled, g_pDelay, g_pFirstOnly, g_pUrl, g_pFile
new g_iVault
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_pEnabled = register_cvar("csb_welcome_enabled", "1")
g_pDelay = register_cvar("csb_welcome_delay", "4.0")
g_pFirstOnly = register_cvar("csb_welcome_firstonly", "0")
g_pUrl = register_cvar("csb_welcome_url", "")
g_pFile = register_cvar("csb_welcome_file", "welcome.txt")
g_iVault = nvault_open("csb_welcome")
}
public plugin_end()
{
if (g_iVault > 0)
nvault_close(g_iVault)
}
public client_putinserver(id)
{
if (!get_pcvar_num(g_pEnabled) || is_user_bot(id))
return
set_task(get_pcvar_float(g_pDelay), "taskWelcome", id)
}
bool:isFirstTime(id)
{
new authid[35]
get_user_authid(id, authid, charsmax(authid))
if (!authid[0])
return true
new key[48]
formatex(key, charsmax(key), "seen_%s", authid)
new seen = nvault_get(g_iVault, key)
if (seen > 0)
return false
nvault_set(g_iVault, key, "1")
return true
}
public taskWelcome(id)
{
if (!is_user_connected(id))
return
new bool:first = isFirstTime(id)
/* MOTD: everyone, or only first-timers depending on the cvar */
if (!get_pcvar_num(g_pFirstOnly) || first)
{
new url[128]
get_pcvar_string(g_pUrl, url, charsmax(url))
if (url[0])
{
show_motd(id, url)
}
else
{
new file[64]
get_pcvar_string(g_pFile, file, charsmax(file))
show_motd(id, file, "Welcome")
}
}
/* personalised coloured chat greeting */
new name[32]
get_user_name(id, name, charsmax(name))
new ip[24], country[46]
get_user_ip(id, ip, charsmax(ip), 1)
if (!geoip_country(ip, country, charsmax(country)) || !country[0])
copy(country, charsmax(country), "somewhere")
new score = get_user_frags(id)
if (first)
client_print(id, print_chat, "^x04[CSB]^x01 Welcome, ^x03%s^x01 from ^x04%s^x01! Enjoy your stay.", name, country)
else
client_print(id, print_chat, "^x04[CSB]^x01 Welcome back, ^x03%s^x01 from ^x04%s^x01. Score: %d.", name, country, score)
}