请教pop781
蹲坑插件对所有的玩家均有效,保括管理员也不能免疫.请pop781帮我看看,如果让管理员免疫,即不被惩罚,特别是不被踢,该怎样修改代码?拜托pop781.下面是源码
#include <amxmodx>
#include <fun>
#define SND_STOP (1<<5)
new playercoord0
new playercoord1
new playercoord2
new playercoord3
new playercoord4
new campmeter
new bool:pausecounter
new bool:bombplanted
new bool:de_map
new camptolerancedefending = 180
new camptoleranceattacking = 200
new show_sprite
new bool:spriton = false
new camptimecount = 0
public showS(parm[])
{
new id = parm
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 ){
new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
new wpnname, name
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,clip,ammo,health,armor)
}
spriton = true
}
public unshowS(parm[])
{
new id = parm
message_begin(MSG_ALL,SVC_TEMPENTITY)
write_byte(125)
write_byte(id)
message_end()
}
public detectEnemy(param[]) {
new id = param
if (!is_user_alive(id))
return PLUGIN_HANDLED
new myorigin
get_user_origin(id, myorigin)
new bool:found = false
new plist, pnum
get_players(plist, pnum, "a")
//new name
//get_user_name(id,name,31)
for(new i = 0; i < pnum; i++) {
new enemyorigin
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
pausecounter = false
return PLUGIN_CONTINUE
}
public displaymeter(id) {
new camptimelimit =get_cvar_num("anticamping_camperkicktime")
if (get_cvar_num("anticamping_meter") != 0) {
if (campmeter > 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,camptimecount,camptimelimit)
} else if (campmeter > 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,camptimecount,camptimelimit)
} else if (campmeter > 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,camptimecount,camptimelimit)
} else if (campmeter > 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,camptimecount,camptimelimit)
} else if (campmeter > 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,camptimecount,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,camptimecount,camptimelimit)
}
}
return PLUGIN_HANDLED
}
public checkcamping(){
if (get_cvar_num("anticamping") == 0){
set_task(1.0,"checkcamping",1)
return PLUGIN_CONTINUE
}
new players
new numberofplayers
new variance
new average
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]) {
++i
}
if (i >= numberofplayers){
set_task(1.0,"checkcamping",1)
return PLUGIN_CONTINUE
}
id = players
if (camptimecount > 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 = playercoord3
playercoord3 = playercoord2
playercoord2 = playercoord1
playercoord1 = playercoord0
}
get_user_origin(id, playercoord0, 0)
for (j = 0; j < 3; ++j) {
average = (playercoord0 +
playercoord1 +
playercoord2 +
playercoord3 +
playercoord4) / 5
variance = (((playercoord0 - average) * (playercoord0 - average) +
(playercoord1 - average) * (playercoord1 - average) +
(playercoord2 - average) * (playercoord2 - average) +
(playercoord3 - average) * (playercoord3 - average) +
(playercoord4 - average) * (playercoord4 - average)) / 4)
}
variancetotal=variance+variance+variance
standarddeviation=sqrt(variancetotal)
team = get_user_team(id)
if (!de_map){
if (team==2) // Team 1 = Terro, Team 2 = CT
campmeter += (camptoleranceattacking - standarddeviation) / get_cvar_num("anticamping_camptime")
else
campmeter += (camptoleranceattacking - standarddeviation) / get_cvar_num("anticamping_camptime")
}
else if (bombplanted){
if (team == 1) // Team 1 = Terro, Team 2 = CT
campmeter = 0
else
campmeter += (camptoleranceattacking-standarddeviation)/get_cvar_num("anticamping_camptime")
}
else{
if (team==2) // Team 1 = Terro, Team 2 = CT
campmeter += (camptolerancedefending-standarddeviation)/get_cvar_num("anticamping_camptime")
else
campmeter += (camptoleranceattacking-standarddeviation)/get_cvar_num("anticamping_camptime")
}
if (campmeter < 80 ) {
emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav", 0.0, ATTN_NORM, SND_STOP, PITCH_NORM)
if (spriton){
unshowS(players)
set_user_rendering(id,kRenderFxNone)
client_print(id,print_chat,"")
// client_print(0,print_chat,"[提示]if (spriton)去掉了%d 的 unshowS,spriton= %d" ,id,spriton)
spriton = false
//remove_task(2)
new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
new wpnname, name
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,clip,ammo,health,armor)
}
}
if (campmeter < 0) {
campmeter = 0
} else if (campmeter>100) {
camptimecount += 1
if (camptimecount > camptimelimit) {
client_print(id,print_chat,"")
}
if( spriton ){
if( detectEnemy(players) ){
//unshowS(players)
//client_print(id,print_chat,"")
new parm
parm = players
showS(parm)
}
}
if ( !spriton ) {
// client_print(0,print_chat,"[提示]程序运行中!ON else if campmeter[%d] = %d" ,id,campmeter)
switch(get_cvar_num("anticamping_sign")) {
case 1: {
//举牌加亮人
client_print(id,print_chat,"",get_cvar_num("anticamping_camptime"),camptimecount,camptimelimit)
client_cmd(id,"spk barney/donthurtem")
set_user_rendering(id,kRenderFxGlowShell,255,100,100,kRenderNormal,16)
//unshowS(players)
new parm
parm = players
set_task(1.0,"showS",2, parm,1)
//spriton = true
}
case 2: {
//只有举牌
client_print(id,print_chat,"",get_cvar_num("anticamping_camptime"),camptimecount,camptimelimit)
client_cmd(id,"spk barney/donthurtem")
//unshowS(players)
new parm
parm = players
set_task(1.0,"showS",2, parm,1)
//spriton = true
}
case 3: {
//只有亮人
client_print(id,print_chat,"",get_cvar_num("anticamping_camptime"),camptimecount,camptimelimit)
client_cmd(id,"spk barney/donthurtem")
set_user_rendering(id,kRenderFxGlowShell,255,100,100,kRenderNormal,16)
spriton = 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 = 100
} else if (campmeter > 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>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=0
campmeter=0
}
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public new_round(id) {
if (get_cvar_num("anticamping") != 0) {
bombplanted=false
pausecounter=true
campmeter=0
new Float:freezetime = get_cvar_float("mp_freezetime")+1.0
new parm
parm=id
spriton = false
unshowS(parm)
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=true
campmeter=0
new Float:bar_time=float(read_data(1)+1)
new parm
parm=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
new numberofplayers
new id
new i
//remove_task(2)
get_players(players, numberofplayers,"a")
for (i = 0; i < numberofplayers; ++i) {
id=players
pausecounter=true
unshowS(players)
set_user_rendering(id,kRenderFxNone)
spriton = false
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}
public client_connect(id)
{
spriton = false
camptimecount = 0
}
public client_disconnect(id)
{
if(spriton)
{
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
}
回复: 请教pop781
for (i = 0; i < numberofplayers; ++i) {
// 这里。。加入跳过带免疫权的玩家
if ( get_user_flags(players)&ADMIN_IMMUNITY != 0) continue
while (i < numberofplayers && pausecounter]) {
我没有时间测试,如果有问题可以跟贴求助
注意,下次发帖求助,请不要制定某人,这里高手很多,我的能力有限。。
回复: 请教pop781
Post by pop781我没有时间测试,如果有问题可以跟贴求助
注意,下次发帖求助,请不要制定某人,这里高手很多,我的能力有限。。
多谢pop781.
这里高手是多,但象你这样热心的高手却并不多
回复: 请教pop781
测游完毕,加入if ( get_user_flags(i)&ADMIN_IMMUNITY != 0) continue后,正常编译,但进入游戏后,所有玩家均没有惩罚,连在中间显示的蹲坑进度条也没有了,请再检查一下
回复: 请教pop781
哦刚才写错了// 这里。。加入跳过带免疫权的玩家
if ( get_user_flags(players )&ADMIN_IMMUNITY != 0) continue
如果还不行
去掉上面的更改,改这里看看
id = players
// 这里。。加入跳过带免疫权的玩家
if ( get_user_flags(id)&ADMIN_IMMUNITY != 0) continue
if (camptimecount > camptimelimit) //判断玩家累计蹲坑时间是否超过上限
回复: 请教pop781
刚测试完以上两种情况均可以达到目的,但具有ADMIN_IMMUNITY 的管理员所有惩罚均不起作用了,中间显示的蹲坑进度条也没有了.其实只需判断管理员达到蹲坑上限不被KICK就行.
按道理讲,
id = players
// 这里。。加入跳过带免疫权的玩家
if ( get_user_flags(id)&ADMIN_IMMUNITY != 0) continue
if (camptimecount > camptimelimit) //判断玩家累计蹲坑时间是否超过上限
这里加了判断后,对于具有ADMIN_IMMUNITY 的管理员,其它惩罚功能应该继续有效啊,为什么不行呢?
回复: 请教pop781
Post by et007刚测试完
这里加了判断后,对于具有ADMIN_IMMUNITY 的管理员,其它惩罚功能应该继续有效啊,为什么不行呢?...
你不是要 ADMIN_IMMUNITY 的管理员达到免予吗?
如果你只要不被kick,改这里
case 1: {
// 这里。。kick 没有带免疫权的玩家
if ( get_user_flags(players)&ADMIN_IMMUNITY == 0)
server_cmd("kick #%d ^"你因为累计蹲坑时间超过上限而被服务器踢出^"", get_user_userid(id) )
}
回复: 请教pop781
可以了多谢你热心的pop781:sweet_kis能加你QQ么?
页:
[1]