|
蹲坑插件对所有的玩家均有效,保括管理员也不能免疫.请pop781帮我看看,如果让管理员免疫,即不被惩罚,特别是不被踢,该怎样修改代码?拜托pop781.
下面是源码
#include <amxmodx>
#include <fun>
#define SND_STOP (1<<5)
new playercoord0[33][3]
new playercoord1[33][3]
new playercoord2[33][3]
new playercoord3[33][3]
new playercoord4[33][3]
new campmeter[33]
new bool:pausecounter[33]
new bool:bombplanted
new bool:de_map
new camptolerancedefending = 180
new camptoleranceattacking = 200
new show_sprite
new bool:spriton[33] = false
new camptimecount[33] = 0
public showS(parm[])
{
new id = parm[0]
message_begin(MSG_ALL,SVC_TEMPENTITY)
write_byte(124)
write_byte(id)
write_coord(65)
write_short(show_sprite)
write_short(32767)
message_end()
//显示蹲坑人的情况
if ( !spriton[id] ){
new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
new wpnname[32], name[32]
get_user_name(id,name,31)
get_weaponname(wpnid,wpnname,31)
new health = get_user_health(id)
new armor = get_user_armor(id)
set_hudmessage(0, 255, 255, -1.0, 0.02, 0, 6.0, 7.0, 0.5, 0.15, 1)
show_hudmessage(0,"%s正在蹲坑^n这家伙手里拿着 %s (%d/%d).^n生命值:%d 护甲:%d",name,wpnname[7],clip,ammo,health,armor)
}
spriton[id] = true
}
public unshowS(parm[])
{
new id = parm[0]
message_begin(MSG_ALL,SVC_TEMPENTITY)
write_byte(125)
write_byte(id)
message_end()
}
public detectEnemy(param[]) {
new id = param[0]
if (!is_user_alive(id))
return PLUGIN_HANDLED
new myorigin[3]
get_user_origin(id, myorigin)
new bool:found = false
new plist[32], pnum
get_players(plist, pnum, "a")
//new name[32]
//get_user_name(id,name,31)
for(new i = 0; i < pnum; i++) {
new enemyorigin[3]
get_user_origin(plist, enemyorigin)
new distance = get_distance(enemyorigin, myorigin)
if ( float(distance) * 0.0254 < 30.0 ){
found = true
//client_print(id,print_chat,"",float(distance) * 0.0254)
}
new bool:isEnemy = (get_user_team(plist) != get_user_team(id))
if (isEnemy && float(distance) * 0.0254 < 30.0) {
set_hudmessage(255, 0, 0, -0.65, 0.8, 0, 1.0, 2.0, 0.1,0.1,119)
show_hudmessage(plist,"",float(distance)*0.0254)
//client_print(id,print_chat,"",float(distance) * 0.0254 ,plist)
}
}
return found
}
public sqrt(num) {
new div = num;
new result = 1;
while (div > result) { // end when div == result, or just below
div = (div + result) / 2 // take mean value as new divisor
result = num / div
}
return div;
}
public unpausecounter(parm[]) {
new id = parm[0]
pausecounter[id] = false
return PLUGIN_CONTINUE
}
public displaymeter(id) {
new camptimelimit = get_cvar_num("anticamping_camperkicktime")
if (get_cvar_num("anticamping_meter") != 0) {
if (campmeter[id] > 100) {
set_hudmessage(255, 0, 0, -1.0, 0.92, 0, 1.0, 2.0, 0.1, 0.1, 4)
show_hudmessage(id,"蹲坑指数:%i%||惩罚指数:%d/%d ",campmeter[id],camptimecount[id],camptimelimit)
} else if (campmeter[id] > 90) {
set_hudmessage(255, 0, 0, -1.0, 0.92, 0, 1.0, 2.0, 0.1, 0.1, 4)
show_hudmessage(id,"蹲坑指数:%i%||惩罚指数:%d/%d ",campmeter[id],camptimecount[id],camptimelimit)
} else if (campmeter[id] > 80){
set_hudmessage(255, 100, 0, -1.0, 0.92, 0, 1.0, 2.0, 0.1, 0.1, 4)
show_hudmessage(id,"蹲坑指数:%i%||惩罚指数:%d/%d ",campmeter[id],camptimecount[id],camptimelimit)
} else if (campmeter[id] > 50 ) {
set_hudmessage(255, 255, 0, -1.0, 0.92, 0, 1.0, 2.0, 0.1, 0.1, 4)
show_hudmessage(id,"蹲坑指数:%i%||惩罚指数:%d/%d ",campmeter[id],camptimecount[id],camptimelimit)
} else if (campmeter[id] > 20 ) {
set_hudmessage(0, 255, 0, -1.0, 0.92, 0, 1.0, 2.0, 0.1, 0.1, 4)
show_hudmessage(id,"蹲坑指数:%i%||惩罚指数:%d/%d ",campmeter[id],camptimecount[id],camptimelimit)
} else {
set_hudmessage(0, 0, 255, -1.0, 0.92, 0, 1.0, 2.0, 0.1, 0.1, 4)
show_hudmessage(id,"蹲坑指数:%i%||惩罚指数:%d/%d ",campmeter[id],camptimecount[id],camptimelimit)
}
}
return PLUGIN_HANDLED
}
public checkcamping(){
if (get_cvar_num("anticamping") == 0){
set_task(1.0,"checkcamping",1)
return PLUGIN_CONTINUE
}
new players[32]
new numberofplayers
new variance[3]
new average[3]
new variancetotal
new standarddeviation
new id
new team
new i
new j
new camptimelimit = get_cvar_num("anticamping_camperkicktime")
get_players(players, numberofplayers, "a")
for (i = 0; i < numberofplayers; ++i) {
while (i < numberofplayers && pausecounter[players]) {
++i
}
if (i >= numberofplayers){
set_task(1.0,"checkcamping",1)
return PLUGIN_CONTINUE
}
id = players
if (camptimecount[id] > camptimelimit) //判断玩家累计蹲坑时间是否超过上限
{
switch (get_cvar_num("anticamping_camperkick")) //根据 anticamping_camperkick ,决定如何惩罚蹲坑王
{
case 0: { //蹲坑时间超过上限 每一局都会一直减血直到死
//client_cmd(id,"echo ^"")
set_user_health(id, get_user_health(id) - get_cvar_num("anticamping_healthpunish") / 5)
//client_print(id,print_chat,"[严重警告]你累计蹲坑时间超过上限,你会得到惩罚.")
}
case 1: {
server_cmd("kick #%d ^"你因为累计蹲坑时间超过上限而被服务器踢出^"", get_user_userid(id) )
}
}
}
for (j = 0; j < 3; ++j) {
playercoord4[id][j] = playercoord3[id][j]
playercoord3[id][j] = playercoord2[id][j]
playercoord2[id][j] = playercoord1[id][j]
playercoord1[id][j] = playercoord0[id][j]
}
get_user_origin(id, playercoord0[id], 0)
for (j = 0; j < 3; ++j) {
average[j] = (playercoord0[id][j] +
playercoord1[id][j] +
playercoord2[id][j] +
playercoord3[id][j] +
playercoord4[id][j]) / 5
variance[j] = (((playercoord0[id][j] - average[j]) * (playercoord0[id][j] - average[j]) +
(playercoord1[id][j] - average[j]) * (playercoord1[id][j] - average[j]) +
(playercoord2[id][j] - average[j]) * (playercoord2[id][j] - average[j]) +
(playercoord3[id][j] - average[j]) * (playercoord3[id][j] - average[j]) +
(playercoord4[id][j] - average[j]) * (playercoord4[id][j] - average[j])) / 4)
}
variancetotal=variance[0]+variance[1]+variance[2]
standarddeviation=sqrt(variancetotal)
team = get_user_team(id)
if (!de_map){
if (team==2) // Team 1 = Terro, Team 2 = CT
campmeter[id] += (camptoleranceattacking - standarddeviation) / get_cvar_num("anticamping_camptime")
else
campmeter[id] += (camptoleranceattacking - standarddeviation) / get_cvar_num("anticamping_camptime")
}
else if (bombplanted){
if (team == 1) // Team 1 = Terro, Team 2 = CT
campmeter[id] = 0
else
campmeter[id] += (camptoleranceattacking-standarddeviation)/get_cvar_num("anticamping_camptime")
}
else{
if (team==2) // Team 1 = Terro, Team 2 = CT
campmeter[id] += (camptolerancedefending-standarddeviation)/get_cvar_num("anticamping_camptime")
else
campmeter[id] += (camptoleranceattacking-standarddeviation)/get_cvar_num("anticamping_camptime")
}
if (campmeter[id] < 80 ) {
emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav", 0.0, ATTN_NORM, SND_STOP, PITCH_NORM)
if (spriton[id]){
unshowS(players)
set_user_rendering(id,kRenderFxNone)
client_print(id,print_chat,"")
// client_print(0,print_chat,"[提示]if (spriton[id])去掉了%d 的 unshowS,spriton[id]= %d" ,id,spriton[id])
spriton[id] = false
//remove_task(2)
new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
new wpnname[32], name[32]
get_user_name(id,name,31)
get_weaponname(wpnid,wpnname,31)
new health = get_user_health(id)
new armor = get_user_armor(id)
set_hudmessage(200, 100, 0, 0.15, 0.05, 0, 6.0, 6.0, 0.1, 0.15, 7)
show_hudmessage(0,"",name,wpnname[7],clip,ammo,health,armor)
}
}
if (campmeter[id] < 0) {
campmeter[id] = 0
} else if (campmeter[id]>100) {
camptimecount[id] += 1
if (camptimecount[id] > camptimelimit) {
client_print(id,print_chat,"")
}
if( spriton[id] ){
if( detectEnemy(players) ){
//unshowS(players)
//client_print(id,print_chat,"")
new parm[1]
parm[0] = players
showS(parm[0])
}
}
if ( !spriton[id] ) {
// client_print(0,print_chat,"[提示]程序运行中!ON else if campmeter[%d] = %d" ,id,campmeter[id])
switch(get_cvar_num("anticamping_sign")) {
case 1: {
//举牌加亮人
client_print(id,print_chat,"",get_cvar_num("anticamping_camptime"),camptimecount[id],camptimelimit)
client_cmd(id,"spk barney/donthurtem")
set_user_rendering(id,kRenderFxGlowShell,255,100,100,kRenderNormal,16)
//unshowS(players)
new parm[1]
parm[0] = players
set_task(1.0,"showS",2, parm,1)
//spriton[id] = true
}
case 2: {
//只有举牌
client_print(id,print_chat,"",get_cvar_num("anticamping_camptime"),camptimecount[id],camptimelimit)
client_cmd(id,"spk barney/donthurtem")
//unshowS(players)
new parm[1]
parm[0] = players
set_task(1.0,"showS",2, parm,1)
//spriton[id] = true
}
case 3: {
//只有亮人
client_print(id,print_chat,"",get_cvar_num("anticamping_camptime"),camptimecount[id],camptimelimit)
client_cmd(id,"spk barney/donthurtem")
set_user_rendering(id,kRenderFxGlowShell,255,100,100,kRenderNormal,16)
spriton[id] = true
}
}
}
switch(get_cvar_num("anticamping")) {
case 1: {
user_slap(id,get_cvar_num("anticamping_healthpunish"))
}
case 2: {
set_user_health(id, get_user_health(id) - get_cvar_num("anticamping_healthpunish"))
}
case 3: {
emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
}
}
campmeter[id] = 100
} else if (campmeter[id] > 90) {
switch(get_cvar_num("anticamping")) {
case 1: {
user_slap(id,get_cvar_num("anticamping_healthpunish") / 5)
}
case 2: {
set_user_health(id, get_user_health(id) - get_cvar_num("anticamping_healthpunish") / 5)
}
case 3: {
emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav", 0.5, ATTN_NORM, 0, PITCH_NORM)
}
}
} else if (campmeter[id]>80){
switch(get_cvar_num("anticamping")) {
case 1: {
user_slap(id,get_cvar_num("anticamping_healthpunish") / 10)
}
case 2: {
set_user_health(id, get_user_health(id) - get_cvar_num("anticamping_healthpunish") / 10)
}
case 3: {
emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav", 0.1, ATTN_NORM, 0, PITCH_NORM)
}
}
}
displaymeter(id)
}
set_task(2.0,"checkcamping",1)
return PLUGIN_CONTINUE
}
public damage_event(id) {
if (get_cvar_num("anticamping") != 0) {
new enemy = get_user_attacker(id)
if (get_user_team(id)!=get_user_team(enemy)) {
campmeter[id]=0
campmeter[enemy]=0
}
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public new_round(id) {
if (get_cvar_num("anticamping") != 0) {
bombplanted=false
pausecounter[id]=true
campmeter[id]=0
new Float:freezetime = get_cvar_float("mp_freezetime")+1.0
new parm[1]
parm[0]=id
spriton[id] = false
unshowS(parm[0])
set_task(freezetime,"unpausecounter",0,parm,1)
set_user_rendering(id,kRenderFxNone)
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public bartime_event(id) {
if (get_cvar_num("anticamping") != 0) {
pausecounter[id]=true
campmeter[id]=0
new Float:bar_time=float(read_data(1)+1)
new parm[1]
parm[0]=id
set_task(bar_time,"unpausecounter",0,parm,1)
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public bomb_planted() {
if (get_cvar_num("anticamping") != 0) {
bombplanted=true
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public got_bomb(id) {
if (get_cvar_num("anticamping") != 0) {
de_map=true
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public round_end() {
if (get_cvar_num("anticamping") != 0) {
new players[32]
new numberofplayers
new id
new i
//remove_task(2)
get_players(players, numberofplayers,"a")
for (i = 0; i < numberofplayers; ++i) {
id=players
pausecounter[id]=true
unshowS(players)
set_user_rendering(id,kRenderFxNone)
spriton[id] = false
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}
public client_connect(id)
{
spriton[id] = false
camptimecount[id] = 0
}
public client_disconnect(id)
{
if(spriton[id])
{
message_begin(MSG_ALL,SVC_TEMPENTITY)
write_byte(125)
write_byte(id)
message_end()
}
}
public plugin_precache() {
show_sprite = precache_model("sprites/11.spr")
precache_sound("player/heartbeat1.wav")
precache_sound("barney/donthurtem.wav")
return PLUGIN_CONTINUE
}
public plugin_init() {
register_plugin("AntiCamping Advanced","1.2","多年菜鸟制作-原代码是SpaceDude编写的")
register_event("Damage", "damage_event", "b", "2!0")
register_event("BarTime","bartime_event","b")
register_event("ResetHUD", "new_round", "b")
register_event("SendAudio", "bomb_planted", "a", "2&%!MRAD_BOMBPL")
register_event("SendAudio", "round_end", "a", "2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
register_event("StatusIcon", "got_bomb", "be", "1=1", "1=2", "2=c4")
register_cvar("anticamping","3",0) //0=Disabled, 1=Slap, 2=Health Reduction, 3=Heartbeat
register_cvar("anticamping_camptime","60",0) //Amount of time allowed to camp
register_cvar("anticamping_healthpunish","5",0) //Amount of health taken due to punishment
register_cvar("anticamping_meter","1",0) //Display 'campmeter' to each cilent
register_cvar("anticamping_sign","1",0) //是否显示牌子和亮人 0-3
register_cvar("anticamping_camperkicktime","120",0) //累计蹲坑值上限
register_cvar("anticamping_camperkick","1",0) //累计蹲坑值达到上限的玩家,是否踢出
set_task(1.0,"checkcamping",1)
return PLUGIN_CONTINUE
} |
|