观众甲
|
分享:
▼
x0
|
[1.6][插件] 如何分辨 PODBOT跟ZBOT
如题 因为如果用RegisterHamFromEntity的话,在加上RegisterHam,就会有双重效果(玩家对podbot) 如果不用RegisterHamFromEntity的话,PODBOT跟Sypb那种能够正常运行 但是如果用RegisterHamFromEntity的话,PODBOT那类bot就会有双重效果 如果不用RegisterHamFromEntity的话,ZBOT就会无效 如果用RegisterHamFromEntity的话,ZBOT才会无效 所以如果我要同时支援两种bot,该怎写?
new Debug public client_putinserver(id) { if(Debug == 1)return new classname[32] pev(id,pev_classname,classname,31) if(!equal(classname,"player")) { Debug=1 set_task(1.0,"_Debug",id) } }
public _Debug(id) { RegisterHamFromEntity(Ham_TakeDamage,id,"fw_TakeDamage") RegisterHamFromEntity(Ham_Killed,id,"fw_PlayerKilled") }
这段是从插件中提取出来的支援ZBOT
[ 此文章被上帝的右手^^在2012-06-28 22:41重新编辑 ]
|
|
x2
[楼 主]
From:未知地址 | Posted:2012-06-28 22:03 |
|
|
HsK
CCN@HsK
级别: 版主
版区: CS插件区
x1701
x1108
|
分享:
▲
▼
刚刚看了看 podbot 和 sypb 的 Src.. 写出以下代码
stock is_bot_type (id) { if (!is_user_bot (id)) return 0; // not bot
new tracker[2], friends[2], ah[2]; get_user_info(id,"tracker",tracker,1); get_user_info(id,"friends",friends,1); get_user_info(id,"_ah",ah,1);
if (tracker[0] == '0' && friends[0] == '0' && ah[0] == '0') return 1; // PodBot / YaPB / SyPB
return 2; // Zbot }
那你应该懂了吧...
|
HsK-Dev Blog By CCN
|
x0
[4 楼]
From:未知地址 | Posted:2012-06-29 16:34 |
|
|
HsK
CCN@HsK
级别: 版主
版区: CS插件区
x1701
x1108
|
分享:
▲
以下为用法 复制程式
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN_NAME "Ham - Bot Get (ZBOT-PODBOT-SyPB)"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "HsK"
new bool:Ham_load = false, cvar_botquota;
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
RegisterHam(Ham_TakeDamage,"player","fw_TakeDamage");
cvar_botquota = get_cvar_pointer("bot_quota");
}
public client_putinserver(id)
set_task (1.0, "Ham_run", id);
public Ham_run (id)
{
server_print("Bot Type : %s", (is_bot_type (id) == 2 ? "Zbot" : (is_bot_type (id) == 1 ? "SyPB/YaPB/PodBot" : "This is not Bot")));
if (!is_user_connected(id) || !get_pcvar_num(cvar_botquota) || Ham_load)
return;
if (is_bot_type (id) != 2)
return;
Ham_load = true;
RegisterHamFromEntity(Ham_TakeDamage,id,"fw_TakeDamage");
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
if (victim == attacker || !attacker)
return;
client_print (attacker, print_chat, "** fw_TakeDamage **Damage! Bot id : %d", victim);
}
stock is_bot_type (id)
{
if (!is_user_bot (id))
return 0; // not bot
new tracker[2], friends[2], ah[2];
get_user_info(id,"tracker",tracker,1);
get_user_info(id,"friends",friends,1);
get_user_info(id,"_ah",ah,1);
if (tracker[0] == '0' && friends[0] == '0' && ah[0] == '0')
return 1; // PodBot / YaPB / SyPB
return 2; // Zbot
}
|
HsK-Dev Blog By CCN
|
x1
[5 楼]
From:未知地址 | Posted:2012-06-29 16:37 |
|
|
|