#include <amxmodx>
#include <amxmisc>
#include <voiceutils>
#pragma semicolon 1
public plugin_init()
{
register_plugin("VoiceUtils: Mute", "1.0.0", "Nordic Warrior");
register_clcmd("say /mute", "cmdOpenMuteMenu", ADMIN_USER);
register_clcmd("say_team /mute", "cmdOpenMuteMenu", ADMIN_USER);
}
public cmdOpenMuteMenu(id)
{
static iPlayers[MAX_PLAYERS], iPlayersNum, iPlayer, szPlayer[3];
get_players_ex(iPlayers, iPlayersNum, GetPlayers_ExcludeBots | GetPlayers_ExcludeHLTV);
if(iPlayersNum == 1)
{
client_print_color(id, print_team_default, "^4[MUTE] ^1Вы ^1единственный ^1игрок на сервере.");
return PLUGIN_HANDLED;
}
new iMenu = menu_create("Кого заглушить?", "MuteMenu_handler");
new iMenuCallback = menu_makecallback("MuteMenu_callback");
for(new i; i < iPlayersNum; i++)
{
iPlayer = iPlayers[i];
if(iPlayer == id)
continue;
num_to_str(iPlayer, szPlayer, charsmax(szPlayer));
menu_additem(iMenu, fmt("%n", iPlayer), szPlayer, .callback = iMenuCallback);
}
menu_setprop(iMenu, MPROP_BACKNAME, "Назад");
menu_setprop(iMenu, MPROP_NEXTNAME, "Далее");
menu_setprop(iMenu, MPROP_EXITNAME, "Выход");
menu_display(id, iMenu);
return PLUGIN_HANDLED;
}
public MuteMenu_handler(id, iMenu, iItem)
{
if(iItem == MENU_EXIT)
{
menu_destroy(iMenu);
return;
}
static szPlayer[3];
menu_item_getinfo(iMenu, iItem, .info = szPlayer, .infolen = charsmax(szPlayer));
new iPlayer = str_to_num(szPlayer);
if(VU_IsClientMuted(iPlayer, id))
{
VU_UnmuteClient(iPlayer, id);
client_print_color(0, print_team_default, "^4[MUTE] ^1Игрок ^4%n ^3снова слышит ^4%n.", id, iPlayer);
}
else
{
VU_MuteClient(iPlayer, id);
client_print_color(0, print_team_default, "^4[MUTE] ^1Игрок ^4%n ^3больше не слышит ^4%n.", id, iPlayer);
}
menu_destroy(iMenu);
cmdOpenMuteMenu(id);
}
public MuteMenu_callback(id, iMenu, iItem)
{
static szPlayer[3];
menu_item_getinfo(iMenu, iItem, .info = szPlayer, .infolen = charsmax(szPlayer));
new iPlayer = str_to_num(szPlayer);
if(VU_IsClientMuted(iPlayer, id))
menu_item_setname(iMenu, iItem, fmt("\d%n \r[ + ]", iPlayer));
}