Русское сообщество по скриптингу

Edit camp meter

Scripting help for english speaking users. While not very active, you still have a chance to get help here.
Правила форума
We cannot maintain english version version of our forum rules, but shortly (it's simple) - Don't be a dick. If you really want to know our rules you should check appropriate thread.

Edit camp meter

Сообщение VenomIvanof » 29 авг 2016, 21:49

How can i make this plugin only for awp?
I want when someone buy awp to turn on the camp meter.

Код: Выделить всё
#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



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) {
        if (
campmeter[id] > 100) {
            
set_hudmessage(random(255), random(255), random(255), -1.00.320.11.50.020.02, -2)
            
show_hudmessage(id,"Go away !!!^nYour CAMPMETER is %i%",campmeter[id])
        } else if (
campmeter[id] > 90) {
            
set_hudmessage(random(255), random(255), random(255), -1.00.320.11.50.020.02, -2)
            
show_hudmessage(id,"Go away !!!^nYour CAMPMETER is %i%",campmeter[id])
        } else if (
campmeter[id] > 80){
            
set_hudmessage(random(255), random(255), random(255), -1.00.320.12.10.020.02, -2)
            
show_hudmessage(id,"CAMPmeter: %i%",campmeter[id])
        } else if (
campmeter[id] > 50 ) {
            
set_hudmessage(random(255), random(255), random(255), -0.90.320.12.10.020.02, -2)
            
show_hudmessage(id,"CampMeter: %i%",campmeter[id])
        } else if (
campmeter[id] > 20 ) {
            
set_hudmessage(random(255), random(255), random(255), -0.90.320.12.10.020.02, -2)
            
show_hudmessage(id,"Campmeter: %i%",campmeter[id])
            
        }
    }
    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
    get_players
(playersnumberofplayers"a")
    for (
0numberofplayers; ++i) {
        while (
numberofplayers && pausecounter[players[i]]) {
            ++
i
        
}
        if (
>= numberofplayers){
            
set_task(1.0,"checkcamping",1)
            return 
PLUGIN_CONTINUE
        
}
        
id players[i]
        for (
03; ++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(idplayercoord0[id], 0)
        for (
03; ++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.0ATTN_NORMSND_STOPPITCH_NORM)
        }
        if (
campmeter[id] < 0) {
            
campmeter[id] = 0
        
} else if (campmeter[id]>100) {
            switch(
get_cvar_num("anticamping")) {
                case 
1: {
                    
user_slap(id,get_cvar_num("anticamping_healthpunish"))
                }
                case 
2: {
                    
set_user_health(idget_user_health(id) - get_cvar_num("anticamping_healthpunish"))
                }
                case 
3: {
                    
emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav"1.0ATTN_NORM0PITCH_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(idget_user_health(id) - get_cvar_num("anticamping_healthpunish") / 5)
                }
                case 
3: {
                    
emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav"0.5ATTN_NORM0PITCH_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(idget_user_health(id) - get_cvar_num("anticamping_healthpunish") / 10)
                }
                case 
3: {
                    
emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav"0.1ATTN_NORM0PITCH_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 (
is_user_connected(enemy) && 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
        set_task
(freezetime,"unpausecounter",0,parm,1)
        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
        get_players
(playersnumberofplayers"a")
        for (
0numberofplayers; ++i) {
            
id=players[i]
            
pausecounter[id]=true
            
return PLUGIN_CONTINUE
        
}
    }
    return 
PLUGIN_CONTINUE
}

public 
plugin_precache() {
    
precache_sound("player/heartbeat1.wav")
    return 
PLUGIN_CONTINUE
}
public 
plugin_init() {
    
register_plugin("AntiCamping Advanced","1.01","SpaceDude - ADVanced edit...")
    
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)  //0=Disabled, 1=Slap, 2=Health Reduction, 3=Heartbeat
    
register_cvar("anticamping_camptime","20",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
    
set_task(1.0,"checkcamping",1)
    return 
PLUGIN_CONTINUE
Аватара пользователя
VenomIvanof
 
Сообщения: 62
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6

Re: Edit camp meter

Сообщение VenomIvanof » 30 авг 2016, 17:33

1st try now work with bool any ideas?

Код: Выделить всё
#include <amxmodx>
#include <fun>

#define SND_STOP (1<<5)
#define AFK_WEAPON CSW_AWP

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 g_iWeapon[33]

public 
OnWeaponChange(id)
    
g_iWeapon = (get_user_weapon(id) == AFK_WEAPON) ? true false
    
bool
:is_wpn(id)
    return (
g_iWeapon[id] == CSW_AWP) ? true false

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) {
      if (
campmeter[id] > 100) {
         
set_hudmessage(random(255), random(255), random(255), -1.00.320.11.50.020.02, -2)
         
show_hudmessage(id,"Go away !!!^nYour CAMPMETER is %i%",campmeter[id])
      } else if (
campmeter[id] > 90) {
         
set_hudmessage(random(255), random(255), random(255), -1.00.320.11.50.020.02, -2)
         
show_hudmessage(id,"Go away !!!^nYour CAMPMETER is %i%",campmeter[id])
      } else if (
campmeter[id] > 80){
         
set_hudmessage(random(255), random(255), random(255), -1.00.320.12.10.020.02, -2)
         
show_hudmessage(id,"CAMPmeter: %i%",campmeter[id])
      } else if (
campmeter[id] > 50 ) {
         
set_hudmessage(random(255), random(255), random(255), -0.90.320.12.10.020.02, -2)
         
show_hudmessage(id,"CampMeter: %i%",campmeter[id])
      } else if (
campmeter[id] > 20 ) {
         
set_hudmessage(random(255), random(255), random(255), -0.90.320.12.10.020.02, -2)
         
show_hudmessage(id,"Campmeter: %i%",campmeter[id])
         
      }
   }
   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
   get_players
(playersnumberofplayers"a")
   for (
0numberofplayers; ++i) {
      while (
numberofplayers && pausecounter[players[i]]) {
         ++
i
      
}
      if (
>= numberofplayers){
         
set_task(1.0,"checkcamping",1)
         return 
PLUGIN_CONTINUE
      
}
      
id players[i]
      for (
03; ++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(idplayercoord0[id], 0)
      for (
03; ++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==&& is_wpn(id))   // 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 == && is_wpn(id))   // Team 1 = Terro, Team 2 = CT
            
campmeter[id] = 0
         
else
            
campmeter[id] += (camptoleranceattacking-standarddeviation)/get_cvar_num("anticamping_camptime")
      }
      else{
         if (
team==&& is_wpn(id))   // 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.0ATTN_NORMSND_STOPPITCH_NORM)
      }
      if (
campmeter[id] < 0) {
         
campmeter[id] = 0
      
} else if (campmeter[id]>100 && is_wpn(id)) {
         switch(
get_cvar_num("anticamping")) {
            case 
1: {
               
user_slap(id,get_cvar_num("anticamping_healthpunish"))
            }
            case 
2: {
               
set_user_health(idget_user_health(id) - get_cvar_num("anticamping_healthpunish"))
            }
            case 
3: {
               
emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav"1.0ATTN_NORM0PITCH_NORM)
            }
         }
         
campmeter[id] = 100
      
} else if (campmeter[id] > 90 && is_wpn(id)) {
         switch(
get_cvar_num("anticamping")) {
            case 
1: {
               
user_slap(id,get_cvar_num("anticamping_healthpunish") / 5)
            }
            case 
2: {
               
set_user_health(idget_user_health(id) - get_cvar_num("anticamping_healthpunish") / 5)
            }
            case 
3: {
               
emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav"0.5ATTN_NORM0PITCH_NORM)
            }
         }
      } else if (
campmeter[id]>80 && is_wpn(id)){
         switch(
get_cvar_num("anticamping")) {
            case 
1: {
               
user_slap(id,get_cvar_num("anticamping_healthpunish") / 10)
            }
            case 
2: {
               
set_user_health(idget_user_health(id) - get_cvar_num("anticamping_healthpunish") / 10)
            }
            case 
3: {
               
emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav"0.1ATTN_NORM0PITCH_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 (
is_user_connected(enemy) && 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
      set_task
(freezetime,"unpausecounter",0,parm,1)
      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
      get_players
(playersnumberofplayers"a")
      for (
0numberofplayers; ++i) {
         
id=players[i]
         
pausecounter[id]=true
         
return PLUGIN_CONTINUE
      
}
   }
   return 
PLUGIN_CONTINUE
}

public 
plugin_precache() {
   
precache_sound("player/heartbeat1.wav")
   return 
PLUGIN_CONTINUE
}
public 
plugin_init() {
   
register_plugin("AntiCamping Advanced","1.01 [Edit by iPlay]","SpaceDude - ADVanced edit...")
   
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_event("CurWeapon""OnWeaponChange""be""1=1")
   
register_cvar("anticamping","1",0)  //0=Disabled, 1=Slap, 2=Health Reduction, 3=Heartbeat
   
register_cvar("anticamping_camptime","20",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
   
set_task(1.0,"checkcamping",1)
   return 
PLUGIN_CONTINUE
}  


this is the code with bool
Аватара пользователя
VenomIvanof
 
Сообщения: 62
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6

Re: Edit camp meter

Сообщение Pafos » 30 авг 2016, 18:31

Код: Выделить всё
get_user_weapon // return the last used weapon 

Код: Выделить всё
user_has_weapon // checks for weapons at the player 
Аватара пользователя
Pafos
 
Сообщения: 533
Зарегистрирован: 07 апр 2014, 18:03
Откуда: pfnClientConnect
Благодарил (а): 126 раз.
Поблагодарили: 92 раз.
Опыт программирования: Больше трех лет
Языки программирования: Pawn

Re: Edit camp meter

Сообщение VenomIvanof » 30 авг 2016, 18:45

Pafos писал(а):
Код: Выделить всё
get_user_weapon // return the last used weapon  

Код: Выделить всё
user_has_weapon // checks for weapons at the player  


fixed but still cant work on AWP
Аватара пользователя
VenomIvanof
 
Сообщения: 62
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6


Вернуться в Scripting

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1