|
今天算是见识了 ,快速真实的玩家 也被 拒之门外 ,看到帖子说是这些 代码 有用 ,感兴趣的朋友来 测试 啊
[mw_shl_code=pawn,true]#include <amxmodx>
#define TASK_SEC 4343
new bool:in_menu[33], cvar_jointeam, cvar_onlyadminspec, g_team[33], cvar_maxsecnochoose, g_maxplayers, g_msgid[33], g_alreadychange[33];
new cvar_limitteams, cvar_autoteambalance;
public plugin_init()
{
register_plugin("Anti Fake Bots", "4.0", "cyby");
register_message(get_user_msgid("ShowMenu"), "message_show_menu");
register_clcmd("say", "hook_say");
register_clcmd("say_team", "hook_say");
register_clcmd("jointeam", "cmd_team");
register_clcmd("joinclass", "cmd_class");
register_clcmd("chooseteam", "cmd_choose");
cvar_jointeam = register_cvar("afb_teamjoin", "0");
cvar_onlyadminspec = register_cvar("afb_onlyadminspec", "0");
cvar_maxsecnochoose = register_cvar("afb_secsnochoose", "20");
cvar_limitteams = get_cvar_pointer("mp_limitteams");
cvar_autoteambalance = get_cvar_pointer("mp_autoteambalance");
set_cvar_float("allow_spectators", 1.0);
g_maxplayers = get_maxplayers();
}
public message_show_menu(msgid, dest, id)
{
static szTeamSelect[] = "#Team_Select";
static szMenuTextCode[32];
get_msg_arg_string(4, szMenuTextCode, charsmax(szMenuTextCode));
if(contain(szMenuTextCode, szTeamSelect) > -1)
{
cmd_choose(id);
return PLUGIN_HANDLED;
}
g_msgid[id] = msgid;
return PLUGIN_CONTINUE;
}
public client_putinserver(id)
{
in_menu[id] = false;
g_team[id] = 0;
set_user_info(id, "_vgui_menus", "0");
g_alreadychange[id] = false;
if(get_pcvar_float(cvar_maxsecnochoose) > 0)
set_task(get_pcvar_float(cvar_maxsecnochoose), "kickplayer", id+TASK_SEC);
}
public kickplayer(id)
{
id -= TASK_SEC;
server_cmd("kick #%d ^"Ai fost dat afara ca a durat prea mult pana sa-ti alegi echipa!^"", get_user_userid(id));
}
public client_disconnect(id)
{
in_menu[id] = false;
g_team[id] = 0;
remove_task(id+TASK_SEC);
}
public hook_say(id)
{
if(!is_user_connected(id) || in_menu[id] || g_team[id] == 0)
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public cmd_team(id)
{
if(in_menu[id])
return PLUGIN_CONTINUE;
return PLUGIN_HANDLED;
}
public cmd_class(id)
{
if(in_menu[id])
return PLUGIN_CONTINUE;
return PLUGIN_HANDLED;
}
fnOpenMenu(id)
{
if(!is_user_connected(id))
return -1;
if(g_team[id] == 0 || g_team[id] == 6)
return bool:true;
return bool:false;
}
public cmd_choose(id)
{
if(!fnOpenMenu(id))
return PLUGIN_HANDLED;
static menu, menu_item[128], name[32];
get_user_name(id, name, charsmax(name));
formatex(menu_item, charsmax(menu_item), "\yDoresti sa intrii pe server: \r%s ?^n", name);
menu = menu_create(menu_item, "choose_handler");
formatex(menu_item, charsmax(menu_item), "\wDa");
menu_additem(menu, menu_item);
if(get_pcvar_num(cvar_onlyadminspec))
{
if(get_user_flags(id) & ADMIN_SLAY)
formatex(menu_item, charsmax(menu_item), "\wSpectator\y (%d)", fnGetPL(6));
else
formatex(menu_item, charsmax(menu_item), "\dSpectator\y (%d)", fnGetPL(6));
}
else
formatex(menu_item, charsmax(menu_item), "\wSpectator\y (%d)", fnGetPL(6));
menu_additem(menu, menu_item);
menu_display(id, menu, 0);
return PLUGIN_HANDLED;
}
public choose_handler(id, menu, item)
{
if(!is_user_connected(id))
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
if(!fnOpenMenu(id))
{
client_print(id, print_center, "Nu poti accesa meniul!");
menu_destroy(menu);
return PLUGIN_HANDLED;
}
switch(item)
{
case 0:
{
if(!get_pcvar_num(cvar_jointeam))
{
static echipa;
echipa = random_num(1, 2);
if(join_allow(id) != echipa && join_allow(id) != 3)
join_team(id, echipa, true);
else
{
menu_destroy(menu);
cmd_choose(id);
return PLUGIN_HANDLED;
}
}
else if(get_pcvar_num(cvar_jointeam) > 0 && get_pcvar_num(cvar_jointeam) < 3)
join_team(id, get_pcvar_num(cvar_jointeam), true);
menu_destroy(menu);
return PLUGIN_HANDLED;
}
case 1:
{
if(get_pcvar_num(cvar_onlyadminspec))
{
if(!(get_user_flags(id) & ADMIN_SLAY))
{
client_print(id, print_center, "Doar adminii au acces sa se puna spec!");
menu_destroy(menu);
cmd_choose(id);
return PLUGIN_HANDLED;
}
}
if(is_user_alive(id))
user_silentkill(id);
join_team(id, 6, false);
menu_destroy(menu);
return PLUGIN_HANDLED;
}
case MENU_EXIT:
{
if(!get_pcvar_num(cvar_jointeam))
join_team(id, random_num(1, 2), true);
else if(get_pcvar_num(cvar_jointeam) > 0 && get_pcvar_num(cvar_jointeam) < 3)
join_team(id, get_pcvar_num(cvar_jointeam), true);
menu_destroy(menu);
return PLUGIN_HANDLED;
}
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
fnGetPL(team)
{
static players;
players = 0;
for(new i = 1; i <= g_maxplayers; i++)
{
if(!is_user_connected(i) || g_team != team)
continue;
players++;
}
return players;
}
stock join_team(id, team, bool:class)
{
static szTeam[2];
new iMenuMsgid = g_msgid[id];
new iMsgBlock = get_msg_block(iMenuMsgid);
g_team[id] = team;
in_menu[id] = true;
num_to_str(team, szTeam, 1);
set_msg_block(iMenuMsgid, BLOCK_SET);
engclient_cmd(id, "jointeam", szTeam);
if(class)
{
static szClass[2];
formatex(szClass, charsmax(szClass), "5");
engclient_cmd(id, "joinclass", szClass);
}
set_msg_block(iMenuMsgid, iMsgBlock);
in_menu[id] = false;
remove_task(id+TASK_SEC);
g_alreadychange[id] = true;
}
stock join_allow(id)
{
static tplayers, ctplayers;
tplayers = fnGetPL(1), ctplayers = fnGetPL(2);
switch(get_user_team(id))
{
case 1: tplayers--;
case 2: ctplayers--;
}
static teamlimit;
teamlimit = get_pcvar_num(cvar_limitteams);
if(get_pcvar_num(cvar_autoteambalance) && teamlimit != 0)
{
if(tplayers - ctplayers >= teamlimit && ctplayers - tplayers >= teamlimit)
return 3;
else if(tplayers - ctplayers >= teamlimit)
return 1;
else if (ctplayers - tplayers >= teamlimit)
return 2;
}
return 0;
}[/mw_shl_code]
这个问题很要命
|
|