|
发表于 2010-2-3 02:37:13
|
显示全部楼层
来自 中国–广西–钦州
代码如下: 希望各位喜欢
#include<amxmod>
#define WEP_B11 16
#define WEP_B12 17
#define WEP_B13 26
#define WEP_B14 1
#define WEP_B15 10
#define WEP_B16 11
#define WEP_B21 21
#define WEP_B22 5
#define WEP_B31 19
#define WEP_B32 23
#define WEP_B33 30
#define WEP_B34 7
#define WEP_B35 12
#define WEP_B41 28
#define WEP_B42 27
#define WEP_B43 22
#define WEP_B44 8
#define WEP_B45 3
#define WEP_B46 18
#define WEP_B47 24
#define WEP_B48 13
#define WEP_B51 20
#define WEP_3 29
#define WEP_O3 25
#define WEP_O4 4
#define WEP_O5 9
#define WEP_5 6
//以下为武器名称字符串
#define WEP_B11N "weapon_usp"
#define WEP_B12N "weapon_glock18"
#define WEP_B13N "weapon_deagle"
#define WEP_B14N "weapon_p228"
#define WEP_B15N "weapon_elite"
#define WEP_B16N "weapon_fiveseven"
#define WEP_B21N "weapon_m3"
#define WEP_B22N "weapon_xm1014"
#define WEP_B31N "weapon_mp5navy"
#define WEP_B32N "weapon_tmp"
#define WEP_B33N "weapon_p90"
#define WEP_B34N "weapon_mac10"
#define WEP_B35N "weapon_ump45"
#define WEP_B41N "weapon_ak47"
#define WEP_B42N "weapon_sg552"
#define WEP_B43N "weapon_m4a1"
#define WEP_B44N "weapon_aug"
#define WEP_B45N "weapon_scout"
#define WEP_B46N "weapon_awp"
#define WEP_B47N "weapon_g3sg1"
#define WEP_B48N "weapon_sg550"
#define WEP_B51N "weapon_m249"
#define WEP_3N "weapon_knife"
#define WEP_O3N "weapon_flashbang"
#define WEP_O4N "weapon_hegrenade"
#define WEP_O5N "weapon_smokegrenade"
#define WEP_5N "weapon_c4"
#define ITM_O2 "item_assaultsuit"
#define WARNCHANNEL 4
new weaponsw[32][2]//保存玩家的当前武器和上一武器(0当前,1上个)
new crashflag[32]//炸F第一步标记
public plugin_init(){
register_plugin("Anti Crash","1.5","Flea")
register_cvar("xqv_antidlf","0")
set_cvar_num("sv_allowdownload",0)
register_event("DeathMsg","domydeath","a")
set_task (4.0,"doremoveflag",82349,"",0,"ab")
}
public plugin_end(){ remove_task(82349);}
/////////////////////////反下载部分
//玩家连接时启用下载
public client_connect ( id ) { set_cvar_num("sv_allowdownload",get_cvar_num("xqv_antidlf"));}
//玩家已经就绪,如有其他玩家还在连接(下载)则仍旧开启,否则关闭
public client_putinserver ( id ) { checktoset();}
//玩家离开时检测下载的开关,置嫌疑和武器切换信息为0
public client_disconnect ( id ){ checktoset(); crashflag[id-1]=weaponsw[id-1][0] = weaponsw[id-1][1]=0;}
stock checktoset(){
if(!get_cvar_num("xqv_antidlf")){set_cvar_num("sv_allowdownload",0);return;}
new allow=0
for(new i=1;i<=32;++i)
if(is_user_connecting(i))
allow=1
set_cvar_num("sv_allowdownload",allow)
}
/////////////////////////反雷部分
//玩家死亡时清除对应信息
public domydeath(){ new i = read_data(2)-1; crashflag[i]=weaponsw[i][0]=weaponsw[i][1]=0;}
public doremoveflag(){//定时检测并移除玩家的嫌疑标志
new Players[32],playerCount,Hasgun
get_players(Players, playerCount)
for (new i=0; i<playerCount; ++i){
Hasgun = xqHas(Players[i],1) + xqHas(Players[i],2)
if(Hasgun) crashflag[i] = 0
}
}
stock carryonlyknife(id){//判断玩家是否持刀且只有刀,目前可假设为剩余1个武器
new wps[32],num
get_user_weapons(id,wps,num)
return num==1
}
stock docrasher(id){
new name[32]=""
get_user_name(id,name,31)
new outln[128]=""
format(outln,127,"--The player:%s(id=%d) is CRASHING? Check it out!",name,id)
xqSvPrint(outln,0.2,0.3,250,250,250)
}
public client_command(id){//捕捉选枪和切枪动作
if(!is_user_alive(id))return PLUGIN_CONTINUE
new cmdstr[32]=""
read_argv(0,cmdstr,31)
//处理客户端发送的选枪请求
if(containi(cmdstr,"weapon_")==0){
new wp = xqGetWeaponId(cmdstr)
if(!wp || xqGetUserWeapon(id) == wp)return PLUGIN_HANDLED//wp非法或者选的是当前枪则钩住
weaponsw[id-1][1] = xqGetUserWeapon(id)
weaponsw[id-1][0] = wp
return PLUGIN_CONTINUE
}
//丢枪时仅一种枪且有雷时列为嫌疑对象
else if(equali(cmdstr,"drop") && xqHas(id,1)+xqHas(id,2) == 1 && xqHas(id,4)+xqHas(id,5))
crashflag[id-1]=1
//客户端发送的切枪请求
else if(equali(cmdstr,"lastinv")){
if(carryonlyknife(id)&&crashflag[id-1]){ docrasher(id); return PLUGIN_HANDLED;}//可能炸服了
if( !xqUserHasWeapon(id,weaponsw[id-1][1]) ) return PLUGIN_HANDLED//没有则忽略
//一般情况:执行切换
weaponsw[id-1][0] = weaponsw[id-1][1]
weaponsw[id-1][1] = xqGetUserWeapon(id)//切换前保存旧的武器
new name[32]=""
get_weaponname(weaponsw[id-1][0],name,31)
engclient_cmd(id,name)
return PLUGIN_HANDLED
}
//合并欺骗攻击者部分
else if(equali(cmdstr,"uaredeath")){
new name[20]="",msgln[128]="",arg1[16]=""
get_user_name(id,name,19)
format(msgln,127,"--The player:%s(id=%d) is Cracking with uaredeath...!",name,id)
//把警告发向服务器
xqSvPrint(msgln,0.2,0.3,200,200,200)
//命令打对才让他高兴会
read_argv(1,arg1,15)
if(equali(arg1,"client_clcmd")) console_print(id,"cniusaudsaosdjw")//随便发个句子过去
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
/////////////////////////自定义库函数部分
//在主机控制台和屏幕打印信息(如果不是主机方式则只在服务器控制台显示),屏幕消息使用默认6秒的保存时间,通道为4
stock xqSvPrint(str[],Float:x,Float:y,r,g,b)
{
server_print(str)
if(xqIsLocal()){
set_hudmessage ( r, g, b, x, y, 0, 6.0, 6.0, 0.1, 0.2, 4)
show_hudmessage( 1,str)
}
}
stock xqHas(id,slot){//检测玩家是否有某个索引的枪,如1为主战枪,2为手枪
new Weapons[32],numWeapons
get_user_weapons(id, Weapons, numWeapons)
for (new i=0; i<numWeapons; ++i)
if(xqGetWeaponSlot(Weapons[i])==slot)
return 1
return 0
}
public xqGetWeaponSlot(id)
{//根据武器id返回是几号武器
if( id == WEP_B11 || id == WEP_B12 || id == WEP_B13 || id == WEP_B14 || id == WEP_B15 || id == WEP_B16)return 2
if( id == WEP_B21 || id == WEP_B22 || id == WEP_B31 || id == WEP_B32 || id == WEP_B33 || id == WEP_B34
|| id == WEP_B35 || id == WEP_B41 || id == WEP_B42 || id == WEP_B43 || id == WEP_B44 || id == WEP_B45
|| id == WEP_B46 || id == WEP_B47 || id == WEP_B48 || id == WEP_B51 )return 1
if( id == WEP_3 )return 3
if( id == WEP_O3 || id == WEP_O4 || id == WEP_O5 )return 4
if( id == WEP_5 )return 5
return 0
}
//根据武器名称获取武器id,主要用于比较,逆向则使用系统函数get_weaponname
stock xqGetWeaponId(name[])
{
if(equali(name,WEP_B11N)) return WEP_B11
if(equali(name,WEP_B12N)) return WEP_B12
if(equali(name,WEP_B13N)) return WEP_B13
if(equali(name,WEP_B14N)) return WEP_B14
if(equali(name,WEP_B15N)) return WEP_B15
if(equali(name,WEP_B16N)) return WEP_B16
if(equali(name,WEP_B21N)) return WEP_B21
if(equali(name,WEP_B22N)) return WEP_B21
if(equali(name,WEP_B31N)) return WEP_B31
if(equali(name,WEP_B32N)) return WEP_B32
if(equali(name,WEP_B33N)) return WEP_B33
if(equali(name,WEP_B34N)) return WEP_B34
if(equali(name,WEP_B35N)) return WEP_B35
if(equali(name,WEP_B41N)) return WEP_B41
if(equali(name,WEP_B42N)) return WEP_B42
if(equali(name,WEP_B43N)) return WEP_B43
if(equali(name,WEP_B44N)) return WEP_B44
if(equali(name,WEP_B45N)) return WEP_B45
if(equali(name,WEP_B46N)) return WEP_B46
if(equali(name,WEP_B47N)) return WEP_B47
if(equali(name,WEP_B48N)) return WEP_B48
if(equali(name,WEP_B51N)) return WEP_B51
if(equali(name,WEP_3N)) return WEP_3
if(equali(name,WEP_O3N)) return WEP_O3
if(equali(name,WEP_O4N)) return WEP_O4
if(equali(name,WEP_O5N)) return WEP_O5
if(equali(name,WEP_5N)) return WEP_5
return 0//错误
}
//获取武器时通常只要返回武器ID
stock xqGetUserWeapon(id){ new c,a; return get_user_weapon(id,c,a);}
stock xqUserHasWeapon(id,wpid)
{//判断玩家是否有某武器
new Weapons[32],numWeapons
get_user_weapons(id, Weapons, numWeapons)
for (new i=0; i<numWeapons; ++i)
if(wpid== Weapons[i])
return 1
return 0
}
//判断是否为主机方式
stock xqIsLocal()
{
if(!is_user_connected(1))return 0
new ip[16]=""
get_user_ip(1,ip,15,1)
return equali(ip,"loopback")
} |
|