|
楼主 |
发表于 2006-6-4 14:16:59
|
显示全部楼层
来自 中国–湖北–武汉
回复: 【发布】CZBot Control v1.0 - 自动添加/踢出/杀死 CZ机器人
[color="Magenta"]那个空间需要IE支持。下面贴出全部源码:
[PHP]
// Cvar : amx_addbots_to <NUMBER>; add bots when the number of players is less than NUMBER. not full!
// amx_killbots <1 or 0>; kill bots when all players has death
#include <amxmodx>
#define PLUGIN "CZBot Control"
#define VERSION "1.0"
#define AUTHOR "KinSprite"
#define KILL_BOTS_AFTER_SECONDS 6.0
#define KILL_BOTS_TASK_ID 5555
new g_addbots_to
new g_kill_bots
new bool:has_end_round
new bool:has_exist_task
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_addbots_to = register_cvar("amx_addbots_to","0")
g_kill_bots = 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_pcvar_num(g_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)
{
set_cvar_num("bot_quota", get_cvar_num("bot_quota") + 1)
}
else if (add_to_num < players_num)
{
set_cvar_num("bot_quota", get_cvar_num("bot_quota") - 1)
}
return PLUGIN_CONTINUE
}
//public client_death(killer, victim, wpnindex, hitplace, TK){
public client_death()
{
if (!get_pcvar_num(g_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("bot_kill")
}
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
}[/PHP] |
|