
   /* AMX Mod script - dod_anti_afk
   *
   * This file is provided as is (no warranties).
   *
   * This is an anti-AFK plugin for DoD
   * (for those that don't know, AFK means "Away From Keyboard")
   * Based on the CS version written by Li0n
   *
   * Checks for AFK players periodically and kicks them if found
   *
   * Cvars:
   * afk_admin_immunity (0 or 1) - give immunity to admins
   * afk_checktime - how often (in seconds) to check for AFKers
   *                 (players that are AFK for this long will be kicked)
   */
   #include <amxmod>
   new player_origin[33][3]
   public round_start()
   {
       new players[32], num
       get_players(players,num)
       for (new i = 0; i < num; ++i)
           get_user_origin(players[i],player_origin[players[i]])
       set_task(get_cvar_float("afk_checktime"),"check_afk",1234,"",0,"b"
   )
       return PLUGIN_CONTINUE
   }
   public check_afk()
   {
       new players[32], num
       new curr_origin[3]
       new name[32]
       get_players(players,num)
       new immunity = get_cvar_num("afk_admin_immunity")
       for (new i = 0; i < num; ++i)
       {
           if ( immunity && (get_user_flags(players[i]) & ADMIN_IMMUNITY)
   )
               continue
           else
           {
               get_user_origin(players[i],curr_origin)
               if   (   curr_origin[0]==player_origin[players[i]][0]   &&
   curr_origin[1]==player_origin[players[i]][1]    &&  curr_origin[2]   <
   (player_origin[players[i]][2]     +     50)    &&  curr_origin[2]    >
   (player_origin[players[i]][2] - 50) )
               {
                   get_user_name(players[i],name,31)
                   client_cmd(players[i],"echo  [ADMIN]  Kicked for being
   AFK.;disconnect")
                   client_print(0,print_chat,"[ADMIN] %s kicked for being
   AFK",name)
                   log_message("[ADMIN] %s Kicked for being AFK", name)
               }
               else
                   player_origin[players[i]]=curr_origin
           }
       }
       return PLUGIN_CONTINUE
   }
   public respawn_msg(id)
   {
       player_origin[id][0] = 0
       return PLUGIN_CONTINUE
   }
   public weapon_fired(id)
   {
       player_origin[id][0] = 0
       return PLUGIN_CONTINUE
   }
   public HandleSay(id)
   {
       player_origin[id][0] = 0
       return PLUGIN_CONTINUE
   }
   public client_connect(id)
   {
       player_origin[id][0] = 0
       return PLUGIN_CONTINUE
   }
   public plugin_init()
   {
       register_plugin("DoD AFK Kicker","0.9.4","Fractal")
       register_event("RoundState", "round_start","a","1=1")
       register_event("ResetHUD", "respawn_msg","b")
       register_event("CurWeapon", "weapon_fired", "b","1=1")
       register_clcmd("say","HandleSay")
       register_clcmd("say_team","HandleSay")
       register_cvar("afk_checktime","240")
       register_cvar("afk_admin_immunity","1")
       return PLUGIN_CONTINUE
   }
