#include <amxmodx>
#include <amxmisc>
new g_menuPosition[33]
new g_menuPlayers[33][32]
new g_menuPlayersNum[33]
new g_idPlayer[33]
public plugin_init()
{
register_plugin("Admin Player Name", "1.5", "Sutar")
register_clcmd("amx_namemenu", "cmdNameMenu")
register_clcmd("plname", "cmdNameChange")
register_menucmd(register_menuid("Player Name Menu"), 1023, "actionPlayerNameMenu")
}
public cmdNameMenu(id)
{
if(!(get_user_flags(id) & ADMIN_SLAY))
{
client_print(id, print_chat, "* Команда доступна только для Админов!")
return PLUGIN_HANDLED
}
displayNameMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
public displayNameMenu(id, pos)
{
if(pos < 0)
return PLUGIN_HANDLED
get_players(g_menuPlayers[id], g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 8
if(start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511, "\yМеню смены ника игрока\Rст. %d из %d\w^n^n", pos + 1, (g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0)))
new end = start + 8
new keys = MENU_KEY_0
if(end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for(new a = start; a < end; a++)
{
i = g_menuPlayers[id][a]
get_user_name(i, name, 31)
if(get_user_flags(i) & ADMIN_IMMUNITY)
len += format(menuBody[len], 511-len, "\d%d. %s *^n", ++b, name)
else
{
keys |= (1<<b)
if(is_user_admin(i))
len += format(menuBody[len], 511-len, "%d. %s *^n", ++b, name)
else
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
}
}
if(end != g_menuPlayersNum[id])
{
keys |= MENU_KEY_9
format(menuBody[len], 511-len, "^n9. Дальше...^n0. %s", pos ? "Назад" : "Выход")
}
else
format(menuBody[len], 511-len, "^n0. %s", pos ? "Назад" : "Выход")
show_menu(id, keys, menuBody, -1, "Player Name Menu")
}
public actionPlayerNameMenu(id, key)
{
switch(key)
{
case 8: displayNameMenu(id, ++g_menuPosition[id])
case 9: displayNameMenu(id, --g_menuPosition[id])
default:
{
g_idPlayer[id] = g_menuPlayers[id][g_menuPosition[id] * 8 + key]
client_cmd(id, "messagemode plname")
}
}
return PLUGIN_HANDLED
}
public cmdNameChange(id)
{
if(!(get_user_flags(id) & ADMIN_SLAY))
{
client_print(id, print_chat, "* Команда доступна только для Админов!")
return PLUGIN_HANDLED
}
if(!g_idPlayer[id])
{
client_print(id, print_chat, "* Функцию необходимы использовать через меню.")
return PLUGIN_HANDLED
}
new g_adminname[15], g_plname[32], g_plnewname[32]
get_user_name(id, g_adminname, 31)
get_user_name(g_idPlayer[id], g_plname, 31)
read_argv(1, g_plnewname, 31)
if(equal(g_plname, g_plnewname))
{
client_print(id, print_chat, "* Вам необходимо указать другой ник.")
client_cmd(id, "messagemode plname")
return PLUGIN_HANDLED
}
client_cmd(g_idPlayer[id], "name ^"%s^"", g_plnewname)
g_idPlayer[id] = 0
client_print(0, print_chat, "[Young] Администратор %s сменил ник игрока %s на %s", g_adminname, g_plname, g_plnewname)
return PLUGIN_HANDLED