
   /* AMX Mod script.
   *
   * Leech by Bolchevique (with code from PsychoGuard)
   * This file is provided as is (no warranties).
   *
   * Heal a player with leech_ratio*dommage when attaking an ennemy
   * with a limit of leech_max_hp (default 150 hp). Default ratio : 20%
   *
   */
   #include <amxmod>
   public damage_event() {
      new dmg = read_data(2);
      new victim = read_data(0);
      new weapon;
      new Float:ratio, leech_max_hp;
      new attacker = get_user_attacker(victim, weapon);
      ratio = get_cvar_float("leech_ratio");
      if (ratio != 0.0){
         leech_max_hp = get_cvar_num("leech_max_hp");
         if    (attacker    !=   victim   &&   get_user_team(victim)   !=
   get_user_team(attacker)){
            new hp = get_user_health(attacker) + floatround(dmg*ratio);
            if (hp >= leech_max_hp)
            set_user_health(attacker,leech_max_hp);
            else
            set_user_health(attacker,hp);
         }
      }
      return PLUGIN_CONTINUE;
   }
   public plugin_init() {
      register_plugin("Leech", "0.61", "Bolchevique");
      register_event("Damage", "damage_event", "b", "2!0");
      register_cvar("leech_ratio", "0.2");
      register_cvar("leech_max_hp", "150");
      return PLUGIN_CONTINUE;
   }
