|
楼主 |
发表于 2008-11-2 10:57:25
|
显示全部楼层
来自 中国–广西–百色
回复: 蹲坑放风筝插件(自己修改)
一般来说,俺修改那些会群踢的插件是发原码的,因为那才觉得是贡献..
这是娱乐插件.本已满足放服务器的要求.但关系到CoVeTer战队的利益,本不想发原码的.
自己加入人颜色和用CoVerT战队的SPR牌效果更好.
#include <amxmodx>
#include <fun>
#define SND_STOP (1<<5)
#define TASK_CAMP 6666667
#define DETECT_RANGE 30.0 // 检测范围
#define ROW_NUM 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 bool:g_pl_lim[33] // 玩家蹲坑到100%的状态
new camper_sprite
new cvarflags[8] // 惩罚方式
new bool:isSlaped[33] // 正在被煽耳光
public plugin_init() {
register_plugin("AntiCamping","1.0","MM")
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","1") // 蹲坑检测 0=关闭, 1=开启
register_cvar("anticamping_camptime","30") // 允许蹲坑的时间上限
register_cvar("anticamping_punish_mode","a")
register_cvar("anticamping_meter","1") // 向客户端显示检测的信息, 0=关闭, 1=开启
register_cvar("anticamping_de_map_allow","1") //de_地图上是否允许防守方蹲坑
set_task(1.0,"checkcamping",1)
return PLUGIN_CONTINUE
}
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) {
if (get_cvar_num("anticamping_meter") != 0) {
new buffer[128],temp,pos
if ((get_user_team(id) == 1) && bombplanted && de_map && get_cvar_num("anticamping_de_map_allow"))
return PLUGIN_HANDLED
else if ((get_user_team(id) == 2) && (!bombplanted) && de_map && get_cvar_num("anticamping_de_map_allow"))
return PLUGIN_HANDLED
else {
temp = campmeter[id]/ROW_NUM
for (new x=0; x<temp; x++)
pos += format(buffer[pos],127-pos,"|")
for (new y=0; y<(100/ROW_NUM-temp); y++)
pos += format(buffer[pos],127-pos,"_")
pos += format(buffer[pos],127-pos,"^n蹲 坑 你 就 变 风 筝: %i%%",campmeter[id])
}
if (campmeter[id] > 99) {
set_hudmessage(255, 0, 0, -1.0, 0.85, 0, 1.0, 2.0, 0.1, 0.1, 4)
} else if (campmeter[id] > 50 ) {
set_hudmessage(255, 255, 0, -1.0, 0.85, 0, 1.0, 2.0, 0.1, 0.1, 4)
} else {
set_hudmessage(0, 255, 0, -1.0, 0.85, 0, 1.0, 2.0, 0.1, 0.1, 4)
}
show_hudmessage(id,buffer)
}
return PLUGIN_HANDLED
}
public checkcamping(){
if (!get_cvar_num("anticamping")){
set_task(1.0,"checkcamping",1)
return PLUGIN_CONTINUE
}
new players[32],variance[3],average[3]
new numberofplayers, variancetotal, standarddeviation, id, i, j, team
get_cvar_string("anticamping_punish_mode", cvarflags, 8)
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
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
if (get_cvar_num("anticamping_de_map_allow"))
campmeter[id] = 0
else
campmeter[id] += (camptolerancedefending - standarddeviation) / get_cvar_num("anticamping_camptime")
else
campmeter[id] += (camptoleranceattacking - standarddeviation) / get_cvar_num("anticamping_camptime")
}
else{
if (team == 2) // Team 1 = Terro, Team 2 = CT
if (get_cvar_num("anticamping_de_map_allow"))
campmeter[id] = 0
else
campmeter[id] += (camptolerancedefending - standarddeviation) / get_cvar_num("anticamping_camptime")
else
campmeter[id] += (camptoleranceattacking - standarddeviation) / get_cvar_num("anticamping_camptime")
}
if ((campmeter[id] < 80 ) && is_user_connected(id)) {
if (g_pl_lim[id] == true){
g_pl_lim[id] = false
}
}
if ((campmeter[id] < 0) && is_user_connected(id)){
campmeter[id] = 0
} else if ((campmeter[id]>100) && is_user_connected(id)) {
if ( contain(cvarflags,"a") != -1 ) {
new ids[2]
ids[0]=id
set_task(0.1, "slap_player", 0, ids, 1, "a", 100)
}
if (g_pl_lim[id] == false){
g_pl_lim[id] = true
}
campmeter[id]=100
}
if (is_user_connected(id) && get_cvar_num("anticamping"))
displaymeter(id)
}
set_task(1.5,"checkcamping",1)
return PLUGIN_CONTINUE
}
public slap_player(ids[]) {
new id = ids[0]
if (get_user_health(id) > 1){
user_slap(id,1)
message_begin(MSG_ALL,SVC_TEMPENTITY)
write_byte(124)
write_byte(id)
write_coord(65)
write_short(camper_sprite)
write_short(32767)
message_end()
}
else if (get_user_health(id) == 1){
user_slap(id,0)
message_begin(MSG_ALL,SVC_TEMPENTITY)
write_byte(125)
write_byte(id)
message_end()
}
else if( get_user_health(id) <= 0 ){
message_begin(MSG_ALL,SVC_TEMPENTITY)
write_byte(125)
write_byte(id)
message_end()
}
return PLUGIN_CONTINUE
}
public damage_event(id) {
if (get_cvar_num("anticamping")) {
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")) {
bombplanted=false
pausecounter[id]=true
campmeter[id]=0
new Float:freezetime = get_cvar_float("mp_freezetime") + 3.0
new parm[1]
parm[0]=id
set_task(freezetime,"unpausecounter",0,parm,1)
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public bartime_event(id) {
if (get_cvar_num("anticamping")) {
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")) {
bombplanted=true
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public got_bomb(id) {
if (get_cvar_num("anticamping")) {
de_map=true
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public round_end() {
if (get_cvar_num("anticamping")) {
new players[32]
new numberofplayers
new id
new i
get_players(players, numberofplayers, "a")
for (i = 0; i < numberofplayers; ++i) {
id=players
isSlaped[id] = false
campmeter[id]=0
if(isSlaped[id]){
user_slap(id,get_user_health(id));
message_begin(MSG_ALL,SVC_TEMPENTITY)
write_byte(125)
write_byte(id)
message_end()
}
}
}
return PLUGIN_CONTINUE
}
public plugin_precache() {
precache_sound("player/breathe2.wav")
camper_sprite = precache_model("sprites/camper100.spr")
return PLUGIN_CONTINUE
}
public client_connect(id) {
g_pl_lim[id] = false
campmeter[id] = 0
return PLUGIN_CONTINUE
}
public client_disconnect(id) {
g_pl_lim[id] = false
campmeter[id] = 0
if(isSlaped[id]){
message_begin(MSG_ALL,SVC_TEMPENTITY)
write_byte(125)
write_byte(id)
message_end()
isSlaped[id]=false
}
return PLUGIN_CONTINUE
}
|
|