
   /* AMXMOD script.
   * (c) Copyright 2003, Vapok
   * This file is provided as is (no warranties).
   *
   * AMX Admin Kick Ban Plugin
   *
   * Bans players after being amx_kickstoban number of time.
   *
   * Allows Server Admins to have the ability to enforce rules
   * without needing the ADMIN_BAN flag.
   *
   *
   * Note:
   * Must place this plugin BEFORE admincmd.amx in the plugins.ini file
   * Also..  You MUST have admincmd.amx listed in your plugins.ini file
   *
   */
   #include <amxmod>
   new vaultfile[64]
   in_vault(var[]) {
      new i = 1
      new line[64 + 1]
      new lineLen
      new Cvar[32]
      new Cval[32]
      if(!(file_exists(vaultfile)))
         return -1
      while( read_file(vaultfile,i,line,64,lineLen) ) {
         parse(line,Cvar,32,Cval,32)
         if(equal(Cvar,var))
            return i
         i++
         if(equal(Cvar,"//",2))
            continue
      }
      return -1
   }
   set_vaultdata(var[],val[]) {
      new linenum = in_vault(var)
      new line[64]
      format(line,64,"%s %s",var,val)
      write_file(vaultfile,line,linenum)
      return 1
   }
   get_vaultdata(var[],val[],len) {
      new linenum = in_vault(var)
      if (linenum == -1)
         return 0
      new line[64]
      new lineLen
      new FCvar[32]
      new Fval[32]
      read_file(vaultfile, linenum, line, 64, lineLen)
      parse(line,FCvar,32,Fval,32)
      copy(val,len,Fval)
      return 1
   }
   public admin_kick_player(id)
   {
      if (get_cvar_num("amx_kick_ban") == 1)
      {
         new arg[32]
         read_argv(1,arg,32)
         new player = find_player("b",arg)
         if(!player)
             player = find_player("c",arg)

         if (player)
         {
             if (read_argc() < 3)
             {
                 client_print(id,print_chat,"Kick  doesn't  count against
   player.  No Reason Entered.")
                 return PLUGIN_CONTINUE
             }

             if (get_user_flags(player)&ADMIN_IMMUNITY)
             {
                   client_print(id,print_chat,"Player has Immunity.")

             } else {

                 //Get WonID from Player
                 new kicked_numS[13], wonidS[33], wonid
                 wonid = get_user_wonid(player)
                 numtostr(wonid, wonidS, 32)

                 //Get Kicks From File
                 get_vaultdata(wonidS, kicked_numS, 12)
                 new cur_kicks = strtonum(kicked_numS)

                 //Get All Player Information
                 new authid[16],name[32],hostname[64]
                 get_user_authid(player,authid,16)
                 get_user_name(player,name,32)
                 get_cvar_string("hostname",hostname,63)

                 //Increment Kicks by One
                 cur_kicks++

                 new cur_kicksS[31]
                 numtostr(cur_kicks, cur_kicksS, 30)


                 if ( cur_kicks == (get_cvar_num("amx_kickstoban")))
                 {
                    new bnTime
                    bnTime = get_cvar_num("amx_bantime")
                    set_hudmessage(255,255,255,0.01,0.15,0, 6.0,6.0, 1.0,
   1.0, 3)
                    show_hudmessage(0,"%s   has  been  banned  from  this
   server...",name)
                    server_cmd("banid %d %s Kicked",bnTime,authid)
                    server_cmd("writeid")

                    //Reset Player Kicks
                    set_vaultdata(wonidS, "0")
                 } else {
                    new  kicks_left  =  get_cvar_num("amx_kickstoban")  -
   cur_kicks
                    client_print(id,print_chat,"%s   has  %d  kicks  left
   before being banned.",name,kicks_left)
                    //Write To File
                    set_vaultdata(wonidS, cur_kicksS)
                 }
              }
         }
      }

      return PLUGIN_CONTINUE
   }
   public plugin_init()
   {
      register_plugin("Admin Kick Ban","0.9.3.1","Vapok")
      register_cvar("amx_kick_ban","1")
      register_cvar("amx_kickstoban","5")
      register_cvar("amx_bantime","60")
      register_cvar("amx_kick_ban_file","addons/amx/kicks.ini")
      register_clcmd("amx_kick","admin_kick_player",ADMIN_KICK)

      get_cvar_string("amx_kick_ban_file",vaultfile,63)
      return PLUGIN_CONTINUE
   }
