/*
* CSB Nickname Manager
* Copyright (C) 2026 counter-strike-boost.com
*
* amx_rename forces a client's name and locks it for a configurable period so
* the player cannot change it back. A reserved-name list (admin, owner,
* console, ...) is enforced continuously: anyone using one is auto-renamed to a
* generated name. Name changes are applied and enforced through the info-key
* buffer via fakemeta.
*
* 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 Nickname Manager"
new const VERSION[] = "1.0.0"
new const AUTHOR[] = "counter-strike-boost.com"
new g_pEnabled, g_pLockTime
new Float:g_fLockUntil[33]
new g_szForced[33][32]
new bool:g_bLocked[33]
new const g_szReserved[][] =
{
"admin",
"owner",
"console",
"server",
"root"
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_pEnabled = register_cvar("csb_nick_enabled", "1")
g_pLockTime = register_cvar("csb_nick_locktime", "60")
register_concmd("amx_rename", "cmdRename", ADMIN_SLAY, " - force a player's name")
set_task(2.0, "taskEnforce", 0, _, _, "b")
}
public client_disconnected(id)
{
g_fLockUntil[id] = 0.0
g_bLocked[id] = false
g_szForced[id][0] = 0
}
setUserName(id, const newName[])
{
new buffer = engfunc(EngFunc_GetInfoKeyBuffer, id)
engfunc(EngFunc_SetClientKeyValue, id, buffer, "name", newName)
}
public taskEnforce()
{
if (!get_pcvar_num(g_pEnabled))
return
new players[32], num, pid
get_players(players, num)
new Float:now = get_gametime()
for (new i = 0; i < num; i++)
{
pid = players[i]
if (is_user_bot(pid) || is_user_hltv(pid))
continue
if (g_bLocked[pid] && now > g_fLockUntil[pid])
g_bLocked[pid] = false
new name[32]
get_user_name(pid, name, charsmax(name))
/* enforce an active rename lock */
if (g_bLocked[pid])
{
if (!equal(name, g_szForced[pid]))
{
setUserName(pid, g_szForced[pid])
client_print(pid, print_chat, "[CSB] Your name is locked to '%s' by an admin.", g_szForced[pid])
}
continue
}
/* reserved-name protection */
new low[32]
copy(low, charsmax(low), name)
strtolower(low)
for (new r = 0; r < sizeof g_szReserved; r++)
{
if (equal(low, g_szReserved[r]))
{
new gen[32]
formatex(gen, charsmax(gen), "Player_%d", get_user_userid(pid))
setUserName(pid, gen)
client_print(pid, print_chat, "[CSB] The name '%s' is reserved. You were renamed.", name)
break
}
}
}
}
public cmdRename(id, level, cid)
{
if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED
new arg[32]
read_argv(1, arg, charsmax(arg))
new target = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY)
if (!target)
return PLUGIN_HANDLED
new newName[32]
read_argv(2, newName, charsmax(newName))
trim(newName)
if (!newName[0])
{
client_print(id, print_chat, "[CSB] Usage: amx_rename ")
return PLUGIN_HANDLED
}
new oldName[32]
get_user_name(target, oldName, charsmax(oldName))
copy(g_szForced[target], charsmax(g_szForced[]), newName)
setUserName(target, newName)
new lockSecs = get_pcvar_num(g_pLockTime)
if (lockSecs > 0)
{
g_bLocked[target] = true
g_fLockUntil[target] = get_gametime() + float(lockSecs)
}
new aname[32]
if (id)
get_user_name(id, aname, charsmax(aname))
else
copy(aname, charsmax(aname), "CONSOLE")
client_print(0, print_chat, "[CSB] %s renamed %s to %s.", aname, oldName, newName)
log_amx("[CSB Nick] %s renamed %s to %s", aname, oldName, newName)
return PLUGIN_HANDLED
}