
   /* AMX Mod script.
   *
   * [SN*AFK] AFK Plugin for AMX 0.5 by sonic (sonic@codet.de)
   *
   * (c) Copyright 2002, sonic
   * This file is provided as is (no warranties).
   *
   */
   /* put in server.cfg:
   *
   *  enable / disable afk plugin  0=off 1=on (default 1)
   *  sn_afk_check  < value >
   *
   *  rounds before idler is kicked (default 2)
   *  sn_afk_rounds < value >
   *
   */
   #include <amxmod>
   new afk_pos[33][3]
   new afk_count[33]
   public client_putinserver(id){
       afk_pos[id][0] = 0
       afk_pos[id][1] = 0
       afk_pos[id][2] = 0
       afk_count[id] = 0
       return PLUGIN_CONTINUE
   }
   public client_disconnect(id){
       afk_pos[id][0] = 0
       afk_pos[id][1] = 0
       afk_pos[id][2] = 0
       afk_count[id] = 0
       return PLUGIN_CONTINUE
   }
   public sn_round_start() {
       new roundtime = floatround(get_cvar_float("mp_roundtime") * 60.0)
       if    (get_cvar_num("sn_afk_check")   ==   1   &&   roundtime   ==
   read_data(1)) {
           new players[32], inum
           get_players(players,inum,"a")
           new origin[3]
           for(new a = 0; a < inum; ++a) {
               get_user_origin(players[a],origin,0)
               afk_pos[players[a]][0] = origin[0]
               afk_pos[players[a]][1] = origin[1]
               afk_pos[players[a]][2] = origin[2]
           }
       }
       return PLUGIN_CONTINUE
   }
   public sn_icon_event(id) {
       afk_pos[id][0] = 0
       afk_pos[id][1] = 0
       afk_pos[id][2] = 0
       return PLUGIN_CONTINUE
   }
   public sn_round_end() {
       if (get_cvar_num("sn_afk_check") == 1) {
           new players[32], inum
           get_players(players,inum,"a")
           new afk_max = get_cvar_num("sn_afk_rounds")
           new origin[3]
           new authid[32]
           new name[32]
           for(new a = 0; a < inum; ++a) {
               get_user_origin(players[a],origin,0)
               if  (origin[0]  ==  afk_pos[players[a]][0] && origin[1] ==
   afk_pos[players[a]][1] && origin[2] != 0) {
                   afk_count[players[a]]++
                   if (afk_count[players[a]] >= afk_max) {
                       client_cmd(players[a],"echo [SN*AFK] Kicked due to
   idling.;disconnect")
                       get_user_authid(players[a],authid,32)
                       get_user_name(players[a],name,32)
                       log_message("[SN*AFK]   %s<%s>   kicked   due   to
   idling",name,authid)
                       client_print(0,print_chat,"[SN*AFK]  Kick  %s  for
   idling.",name)
                   } else {
                       get_user_name(players[a],name,32)
                       client_print(0,print_chat,"[SN*AFK]      %s     is
   AFK.",name)
                   }
               }
           }
       }
       return PLUGIN_CONTINUE
   }
   public sn_map_restart() {
       if (get_cvar_num("sn_afk_check") == 1) {
           new players[32], inum
           get_players(players,inum)
           for(new a = 0; a < inum; ++a) {
               afk_count[players[a]] = 0
           }
       }
       return PLUGIN_CONTINUE
   }
   public plugin_init() {
       register_plugin("SN*AFK","0.5","Sonic (sonic@codet.de)")
       register_cvar("sn_afk_check","1")
       register_cvar("sn_afk_rounds","2")
       register_event("RoundTime","sn_round_start", "bc")
       register_event("StatusIcon","sn_icon_event",      "be",     "1=0",
   "2=buyzone")
       register_event("SendAudio","sn_round_end","ac","2=%!MRAD_terwin","
   2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
       register_event("TextMsg","sn_map_restart","ac","2&#Game_C","2&#Gam
   e_w")
       return PLUGIN_CONTINUE
   }
