#include <amxmodx>
#include <fakemeta>
const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
new StrN[3]=0,g_menu[33]=0,bool:ChooseTeam_Used[33], bool:DetectVIPMap[33];
public plugin_init()
{
register_plugin("Players Count in Team Menu [Optimal]" , "3.0.5" , "kramesa+Seroff" );
register_message(get_user_msgid("ShowMenu"), "MenuTeam");
register_message(get_user_msgid("VGUIMenu"), "VGUITeam");
register_clcmd("chooseteam", "OpenMenu");
register_clcmd("jointeam", "j_OpenMenu");
register_menu("chooseteam", KEYSMENU, "chooseteam_menu");
register_menu("jointeam", KEYSMENU, "jointeam_menu");
register_event("HLTV", "Event_HLTV_New_Round", "a", "1=0", "2=0");
new entity = -1;
if((engfunc(EngFunc_FindEntityByString, entity, "classname", "info_vip_start")) > 0)
{
DetectVIPMap[0] = true;
}
else
{
DetectVIPMap[0] = false;
}
}
public j_OpenMenu(id)
{
if(ChooseTeam_Used[id] == true)
{
menu_cancel(id);
client_print_center(id, "Только один раз можно сменить команду за раунд!");
return PLUGIN_HANDLED;
}
if(DetectVIPMap[0] == false)
{
menu_cancel(id);
join_OpenMenu(id);
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public join_OpenMenu(id){
new Arg[3],NumArg;
read_argv(1,Arg,charsmax(Arg));
if(!equal(Arg,"")){
NumArg=str_to_num(Arg);
switch(NumArg){
case 1,2:jointeam_m(id, NumArg);
case 5:jointeam_m(id, random_num(1,2));
case 6:engclient_cmd(id,"jointeam", "6");
}
}else{
TeamMenu(id);
}
return PLUGIN_CONTINUE;
}
public Event_HLTV_New_Round(id)
{
arrayset(ChooseTeam_Used, false, sizeof(ChooseTeam_Used));
}
public client_authorized(id)
{
ChooseTeam_Used[id] = false;
g_menu[id]=0;
}
public OpenMenu(id)
{
if(ChooseTeam_Used[id] == true)
{
menu_cancel(id);
client_print_center(id, "Только один раз можно сменить команду за раунд!");
return PLUGIN_HANDLED;
}
if(DetectVIPMap[0] == false)
{
menu_cancel(id);
TeamMenu(id);
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public MenuTeam(msg, des, rec)
{
if(DetectVIPMap[0] == false)
{
static const TeamSelect[] = "#Team_Select";
static sz_Menu[sizeof(TeamSelect)];
get_msg_arg_string(4, sz_Menu, charsmax(sz_Menu));
if(!equal( sz_Menu, TeamSelect))
{
return PLUGIN_CONTINUE;
}
set_pdata_int(rec, 205, 0);
if(ChooseTeam_Used[rec]==false){
TeamMenu(rec);
}
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public VGUITeam(msg, des, rec)
{
if(get_msg_arg_int(1) != 2)
{
return PLUGIN_CONTINUE;
}
TeamMenu(rec);
return PLUGIN_HANDLED;
}
get_users(Team[]){
static iPlayers[32],iNum=0
get_players(iPlayers, iNum, "hce",Team);
return iNum
}
public TeamMenu(id)
{
if(ChooseTeam_Used[id] == true)
{
menu_cancel(id);
client_print_center(id, "Только один раз можно сменить команду за раунд!");
return PLUGIN_HANDLED;
}
new Users[124];
formatex(Users,charsmax(Users),"\r1. \wТеррористы \y[\r%d\y]^n\r2. \wКонтр-Террористы \y[\r%d\y]^n^n",get_users("TERRORIST"), get_users("CT"));
static menu[512], len;
len = 0;
len += formatex(menu[len], charsmax(menu) - len, "\yВыбор команды^n^n");
len += formatex(menu[len], charsmax(menu) - len, Users);
len += formatex(menu[len], charsmax(menu) - len, "\r5. \wСлучайная команда^n");
len += formatex(menu[len], charsmax(menu) - len, "\r6. \wСпектаторы^n^n");
new Keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_5|MENU_KEY_6
if(g_menu[id]!=0){
len += formatex(menu[len], charsmax(menu) - len, "\r0. \wВыход^n^n");
Keys |= MENU_KEY_0
}
show_menu(id, Keys, menu, -1, "chooseteam");
g_menu[id]++;
return PLUGIN_CONTINUE;
}
public chooseteam_menu(id, key)
{
switch(key)
{
case 0:
{
jointeam_m(id,1);
}
case 1:
{
jointeam_m(id,2);
}
case 4:
{
jointeam_m(id, random_num(1,2));
}
case 5:
{
engclient_cmd(id, "jointeam","6");
}
case 9:
{
menu_cancel(id);
}
}
return PLUGIN_HANDLED
}
public jointeam_m(id, team)
{
static menu[512], len;
len = 0;
len += formatex(menu[len], charsmax(menu) - len, "\yВыберите ваш внешний вид^n^n");
switch(team){
case 1:{
len += formatex(menu[len], charsmax(menu) - len, "\r1. \wPhoenix Connexion^n");
len += formatex(menu[len], charsmax(menu) - len, "\r2. \wElite Crew^n");
len += formatex(menu[len], charsmax(menu) - len, "\r3. \wArctic Avengers^n");
len += formatex(menu[len], charsmax(menu) - len, "\r4. \wGuerilla Warface^n");
}
case 2:{
len += formatex(menu[len], charsmax(menu) - len, "\r1. \wSeal Team 6^n");
len += formatex(menu[len], charsmax(menu) - len, "\r2. \wGSG-9^n");
len += formatex(menu[len], charsmax(menu) - len, "\r3. \wSAS^n");
len += formatex(menu[len], charsmax(menu) - len, "\r4. \wGIGN^n");
}
}
len += formatex(menu[len], charsmax(menu) - len, "^n\r5. \wСлучайный выбор^n");
num_to_str(team,StrN,2);
new Keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5
show_menu(id, Keys, menu, -1, "jointeam");
set_msg_block(114, BLOCK_ONCE);
return PLUGIN_CONTINUE;
}
public jointeam_menu(id, key)
{
engclient_cmd(id, "jointeam",StrN);
switch(key)
{
case 0:
{
engclient_cmd(id, "joinclass","1");
}
case 1:
{
engclient_cmd(id, "joinclass","2");
}
case 2:
{
engclient_cmd(id, "joinclass","3");
}
case 3:
{
engclient_cmd(id, "joinclass","4");
}
case 4:
{
engclient_cmd(id, "joinclass","5");
}
}
show_menu(id, 0, "^n^n^n^n^n^n^n^n^n", 1, "jointeam");
ChooseTeam_Used[id] = true;
return 1;
}
stock register_menu(const title[],keys,const function[],outside=0)
{
register_menucmd(register_menuid(title,outside),keys,function);
}
client_print_center(id,Message[]=""){
message_begin(MSG_ONE, get_user_msgid("TextMsg"), .player=id)
write_byte(print_center);
write_string(Message);
message_end();
}