
   /* AMX Mod script.
   *
   * (c) 2003, Li0n
   * This file is provided as is (no warranties).
   *
   *
   *  This  plugin  check  for  AFKer  after  the  begining  of  a  round
   (configurable by afk_checkdelay)
   *  Then, the AFKer is killed or kicked if he is staying to respawn for
   n round  (configurable by afk_maxround)
   *
   * Cvars:
   * afk_admins_immune (0 or 1) - set immunity to admin
   * afk_check (0 or 1) - set AFK ON / OFF
   *  afk_checkdelay (default 20) - set time in second after a roundstart
   to check AFKers
   *  afk_maxround  (default 3) - set the number of rounds before kicking
   AFKer
   *
   *
   *  Plugin largely inspired from sefanja & -sonic-
   *  It's in fact a mixed of their
   */
   #include <amxmod>
   new spawn_origins[33][3]
   new afk_count[33]
   public event_roundtime(id){
      if    (floatround(get_cvar_float("mp_roundtime")    *    60.0)   ==
   read_data(1) && get_cvar_num("afk_check") == 1){
         get_user_origin(id,spawn_origins[id])
      }
   }
   public event_roundtime2(){
      if    (floatround(get_cvar_float("mp_roundtime")    *    60.0)   ==
   read_data(1) && get_cvar_num("afk_check") == 1){
         remove_task(0)
         set_task(get_cvar_float("afk_checkdelay"),"check_afk")
      }
   }
   public check_afk(){
      if (get_cvar_num("afk_check") == 0){
         return
      }
      new players[32], num
      new afk_max = get_cvar_num("afk_maxrounds")
      new origin[3]
      new name[32]
      get_players(players,num,"a")
      for (new i = 0; i < num; ++i) {
         get_user_origin(players[i],origin)
         if  (origin[0]  ==  spawn_origins[players[i]][0] && origin[1] ==
   spawn_origins[players[i]][1] && origin[2] ==
   spawn_origins[players[i]][2]) {
            if       ((get_user_flags(players[i])&ADMIN_IMMUNITY)      &&
   get_cvar_num("afk_admins_immune")) {
               continue
            } else {
               afk_count[players[i]]++
            }
            if (afk_count[players[i]] >= afk_max) {
               client_cmd(players[i],"echo   [AMX   AFK]  Kicked  due  to
   idling.;disconnect")
               get_user_name(players[i],name,31)
               client_print(0,print_chat,"[AMX    AFK]    Kick   %s   for
   idling.",name)
            } else {
               user_kill(players[i],0)
               get_user_name(players[i],name,31)
               client_print(0,print_chat,"[AMX AFK] %s is AFK.",name)
            }
         }
      }
   }
   public client_putinserver(id){
      if (get_cvar_num("afk_check") == 1) {
         afk_count[id] = 0
      }
      return PLUGIN_CONTINUE
   }
   public client_disconnect(id){
      if (get_cvar_num("afk_check") == 1) {
         afk_count[id] = 0
      }
      return PLUGIN_CONTINUE
   }
   public game_restart() {
      if (get_cvar_num("afk_check") == 1) {
         new players[32], num
         get_players(players,num)
         for(new i = 0; i < num; ++i) {
             afk_count[players[i]] = 0
         }
      }
      return PLUGIN_CONTINUE
   }
   public plugin_init(){
      register_plugin("AFK Killer/Kicker","0.9.4","Li0n")
      register_event("RoundTime","event_roundtime","b")
      register_event("RoundTime","event_roundtime2","bc")
      register_event("TextMsg","game_restart","a","1=4","2&#Game_C","2&#G
   ame_w")
      register_cvar("afk_check","1")
      register_cvar("afk_checkdelay","20")
      register_cvar("afk_maxrounds","3")
      register_cvar("afk_admins_immune","0")
      return PLUGIN_CONTINUE
   }
