
   /* AMX Mod script.
   *
   * (c) Copyright 2002, OLO
   * This file is provided as is (no warranties).
   *
   */
   #include <amxmod>
   /* cvar: amx_mirrordmg < flags >
   *  to disable mirror damage set amx_mirrordmg to ""
   *  "a" - take health from attacked
   *  "b" - give lost health and armor to the victim
   *  "c" - make attacker glowing
   *  "d" - kick players attacking teammates at roundstart
   */
   new damage_mode
   new takehealth[33]
   new takearmor[33]
   new ihealth[33]
   new iarmor[33]
   new iglow[33]
   new Float:roundtime[33]
   public respawn_msg(id){
       ihealth[id] = get_user_health(id)
       iarmor[id] = get_user_armor(id)
       roundtime[id] = get_gametime() + get_cvar_float("mp_freezetime") +
   10.0
   }
   public damage_cvar(){
       new flags[8]
       get_cvar_string("amx_mirrordmg",flags,8)
       damage_mode = read_flags(flags)
   }
   public health_msg(id){
       new chealth = read_data(1)
       takehealth[id] = ihealth[id] - chealth
       ihealth[id] = chealth
   }
   public battery_msg(id){
       new carmor = read_data(1)
       takearmor[id] = iarmor[id] - carmor
       iarmor[id] = carmor
   }
   public damage_msg(id){
       new weapon, enemy = get_user_attacker(id,weapon)
       if   (   enemy   &&   (enemy   !=  id)  &&  (get_user_team(id)  ==
   get_user_team(enemy)) ){
           if ( damage_mode & 1 ){
               set_user_health(enemy,       get_user_health(enemy)      -
   takehealth[id] )
               new tarmor = get_user_armor(enemy) - takearmor[id]
               if (tarmor < 0) tarmor = 0
               set_user_armor(enemy, tarmor )
           }
           if ( damage_mode & 2 ){
               set_user_health(id, get_user_health(id) + takehealth[id] )
               new tarmor = get_user_armor(id)
               if (tarmor > 0)
                   tarmor += takearmor[id]
               set_user_armor(id, tarmor )
           }
           if ( damage_mode & 4 ){
               if (iglow[enemy] < 1){
                   new parm[2]
                   parm[0] = enemy
                   set_task(0.2,"glow_change",0,parm,2)
               }
               iglow[enemy] += 40
               set_user_rendering(enemy,kRenderFxGlowShell,iglow[enemy],0
   ,0,kRenderNormal, 16)
           }
           if ( (damage_mode & 8) && (roundtime[enemy] > get_gametime()))
               client_cmd(enemy,"echo  [AMX]  Sorry but there is no place
   for such ppl as you;disconnect")
       }
   }
   public glow_change(parm[]){
       new enemy = parm[0]
       iglow[enemy] -= 5
       if (iglow[enemy] > 0){
           set_user_rendering(enemy,kRenderFxGlowShell,iglow[enemy],0,0,
   kRenderNormal, 16)
           set_task(0.2,"glow_change",0,parm,2)
       }
       else{
           iglow[enemy] = 0
           set_user_rendering(enemy)
       }
   }
   public plugin_init(){
       register_plugin("Mirror Damage","0.6","default")
           register_event("ResetHUD", "respawn_msg","b")
           register_event("Health", "health_msg","b")
           register_event("Battery", "battery_msg","b")
           register_event("Damage",   "damage_msg",  "b",  "2!0",  "3=0",
   "4!0")
       register_cvar("amx_mirrordmg","ac",0)
       set_task(10.0,"damage_cvar",0,"",0,"b")  /*  update  cvar  setting
   every 10.0 seconds */
       return PLUGIN_CONTINUE
   }
