jlbsky
|
分享:
▼
x0
|
[1.6][插件] BOT判斷的問題
各位大神,下面是BOT的代碼,這個代碼是進一個玩家詞服器自動踢一個BOT,但是這個是用的pbot,請問怎麽改成用sypb的,求大神解釋
/* 机器人 "PodBot Controle"
Edited:ig amx_addbots_to "6" // 最少保持人数 amx_removebots_num "10" // 但多余多少人在线时,剔除bot amx_killbots "1" // 当剩余玩家都是bot时,是否杀死bot,加快游戏节奏 */
#include <amxmodx> #include <fakemeta>
#define PLUGIN "cn.PodBot Controle" #define VERSION "1.2.16" #define AUTHOR "ig"
new bool:g_Bot[33]
new g_maxbots new g_addbots_to new g_removebots_when new g_kill_bots new bool:bCanStart new g_iMaxplayers
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR)
g_iMaxplayers = get_maxplayers() g_maxbots = register_cvar("amx_maxbots","6") // 机器人最大数目 g_addbots_to = register_cvar("amx_addbots_to","8") // 最少保持人数 g_removebots_when = register_cvar("amx_removebots_num","10") // 但多余多少人在线时,剔除bot g_kill_bots = register_cvar("amx_killbots","1") // 当剩余玩家都是bot时,是否杀死bot,加快游戏节奏 bCanStart = false }
public plugin_cfg() { set_task(5.0,"bot_reset")
if (server_bot_record()<1) { set_task(50.0,"delay_set") } else { set_task(6.0,"delay_set") } }
public bot_reset() { // 判断是那种bot类型 if (!cvar_exists("pb_minbots")){ pause("ad") // 其他情况,停止插件运作 }
// 先清除所有bot,及设置 //server_cmd("pb removebots") server_cmd("pb_mapstartbotdelay 0") server_cmd("pb_minbots 0") server_cmd("pb_maxbots 0") server_cmd("pb_bot_quota_match 0") server_cmd("pb_autokill 0") server_cmd("pb_autokill %d", get_pcvar_num(g_kill_bots)) }
public delay_set() { bCanStart = true check_bots() }
server_bot_record() { new sNum[32] get_localinfo("bot_num", sNum, 31) return str_to_num(sNum) }
server_bot_record_set(num) { new sNum[32] formatex(sNum, 31, "%d", num) set_localinfo("bot_num", sNum) }
public client_connect(id) { g_Bot[id] = false
if(bCanStart){ remove_task(333) set_task(1.0, "check_bots", 333) } }
public client_disconnect(id) { g_Bot[id] = false
if(bCanStart){ remove_task(333) set_task(5.0, "check_bots", 333) } }
public check_bots() { new add_to_num = get_pcvar_num(g_addbots_to)
if(add_to_num==0) return PLUGIN_CONTINUE
add_to_num = (add_to_num>g_iMaxplayers) ? g_iMaxplayers:add_to_num
if(add_to_num==g_iMaxplayers) add_to_num--
new botnum,lastbot count_bot(botnum,lastbot) new playersum = get_playersnum(1)
if (add_to_num>playersum && botnum<get_pcvar_num(g_maxbots)) { server_cmd("pb add") server_bot_record_set(botnum+1) } else if (add_to_num<playersum) { if (botnum>0 && playersum>get_pcvar_num(g_removebots_when)) { server_cmd("pb remove #%d",lastbot) server_bot_record_set(botnum-1) } } return PLUGIN_CONTINUE }
count_bot(&botnum,&lastbot) { for(new i=1; i<=g_iMaxplayers; i++) { if (is_user_connected(i) && is_user_bot(i)){ botnum++ lastbot = (get_user_userid(i)) } } }
|