|
发表于 2006-6-18 20:46:23
|
显示全部楼层
来自 中国–江苏–南京
回复: 【发布】PODBot Control v1.0 - 自动添加/踢出/杀死 POD机器人
#include <amxmodx>
#define PLUGIN "PODBot Control"
#define VERSION "1.0"
#define AUTHOR "KinSprite"
#define ADD_ONE_BOT "yapb add"
#define KILL_ALL_BOTS "yapb killbots"
#define KILL_BOTS_AFTER_SECONDS 6.0
#define KILL_BOTS_TASK_ID 5555
new bool:has_end_round
new bool:has_exist_task
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("amx_addbots_to","0")
register_cvar("amx_killbots","1")
register_logevent("StartNewRound",2,"0=World triggered","1=Round_Start")
register_logevent("EndRound",2,"0=World triggered","1=Round_End")
}
public client_connect(id)
{
//if(!is_user_bot(id))
set_task(1.0, "check_bots")
return PLUGIN_CONTINUE
}
public client_disconnect(id)
{
//if(!is_user_bot(id))
set_task(1.0, "check_bots")
return PLUGIN_CONTINUE
}
public check_bots()
{
new add_to_num = get_cvar_num("amx_addbots_to")
if (add_to_num==0 || add_to_num==1)
return PLUGIN_CONTINUE
new max_players = get_maxplayers()
if (max_players <= add_to_num)
add_to_num = max_players - 1
new players_num = get_playersnum(1)
if (add_to_num > players_num)
{
server_cmd(ADD_ONE_BOT)
}
else if (add_to_num < players_num)
{
new ct_count, t_count, players[32], players_b[32]
get_players(players, ct_count, "de","CT")
get_players(players_b, t_count, "de","TERRORIST")
if (t_count > ct_count)
{
new userid = get_user_userid(players_b[t_count-1])
server_cmd("kick #%d",userid)
}
else if (ct_count != 0)
{
new userid = get_user_userid(players[ct_count-1])
server_cmd("kick #%d",userid)
}
}
return PLUGIN_CONTINUE
}
//public client_death(killer, victim, wpnindex, hitplace, TK){
public client_death()
{
if (!get_cvar_num("amx_kill_bots") || has_end_round || has_exist_task)
return PLUGIN_CONTINUE
new players[32],num
get_players(players,num,"ac")
if (num==0)
{
set_task(KILL_BOTS_AFTER_SECONDS,"kill_bots",KILL_BOTS_TASK_ID)
has_exist_task = true
}
return PLUGIN_CONTINUE
}
public kill_bots()
{
if (!has_end_round)
server_cmd(KILL_ALL_BOTS)
}
public StartNewRound()
{
if (task_exists(KILL_BOTS_TASK_ID))
remove_task(KILL_BOTS_TASK_ID)
has_exist_task = false
has_end_round = false
}
public EndRound()
{
has_exist_task = true
has_end_round = true
}
我改了一下你的源程序,在1.6下编译通过,可在F上试的时候没作用,想请教一下我改的对不对,F用的是yapb的bot,对应的增加bot命令是yapb add,杀死所有bot的命令是yapb killbots |
|