
   #include <amxmod>
   new automapname[16] = "de_dust2"
   /* balance numbers */
   new autoteamnum = 5
   /* addbot switch for ensuring add a bot one time */
   new ctswitch = 0
   new tswitch = 1
   public real_start() {
       server_print("The   server   will   restart   now   with   %s...",
   automapname)
       server_cmd("changelevel %s", automapname)
   }
   public scheduled_start(shrs, smins) {
       new ctime[64]
       get_time("%H:%M:%S",ctime,63)
       server_print("Current time is %s", ctime)
       server_print("Scheduled restart time is %d:%d", shrs, smins)
       new mhours[6], mmins[6]
       get_time("%H",mhours,5)
       get_time("%M",mmins,5)
       new mins = strtonum(mmins)
       new hrs = strtonum(mhours)

       /* be careful here, calc the time */
       new stime = (shrs - hrs) * 60 + smins - mins
       if (stime <= 0) stime += 1440

       /* to seconds */
       stime *= 60
       server_print("The server will restart in %d seconds", stime)

       new Float:fstime = float(stime)
       set_task(fstime,"real_start")
   }
   /* set the auto restart map for playing a match */
   public admin_automap() {
       if (read_argc() < 2) {
           server_print("Current automapname is %s", automapname)
       }
       else {
           read_argv(1, automapname, 15)
           server_print("automapname changed to %s", automapname)
       }
   }
   /* balance adjust */
   public balance_adjust() {
       new ctplayers[32], tplayers[32]
       new ctnum, tnum, dnum
       get_players(ctplayers,ctnum,"e","CT")
       get_players(tplayers,tnum,"e","TERRORIST")

       /* kicking bot... */
       if (ctnum > autoteamnum) {
           dnum = ctnum - autoteamnum
           for(new a = 0; a < ctnum; a++) {
               if (is_user_bot(ctplayers[a])) {
                   new id = get_user_userid(ctplayers[a])
                   server_print("kick a CT bot user %d to balance", id)
                   server_cmd("kick #%d", id)
                   dnum--
               }

               if (dnum == 0) break
           }
       }

       if (tnum > autoteamnum) {
           dnum = tnum - autoteamnum
           for(new a = 0; a < tnum; a++) {
               if (is_user_bot(tplayers[a])) {
                   new id = get_user_userid(tplayers[a])
                   server_print("kick a T bot user %d to balance", id)
                   server_cmd("kick #%d", id)
                   dnum--
               }

               if (dnum == 0) break
           }
       }

       /* adding bot... */
       /* Why I do so much, cause every time system allows me to only add
   one bot */
       if (ctswitch) {
           if (ctnum < autoteamnum) {
               server_print("add a CT bot to balance")
               server_cmd("pb ^"addbot 90 2 5 CT^"")
           }

           ctswitch = 0
           tswitch = 1
           return 0
       }

       if (tswitch) {
           if (tnum < autoteamnum) {
               server_print("add a T bot to balance")
               server_cmd("pb ^"addbot 90 1 5 T^"")
           }

           ctswitch = 1
           tswitch = 0
           return 0
       }

       return 0
   }
   public plugin_init() {
       register_plugin("AutoStart","0.0.1","default")
       register_concmd("amx_automap","admin_automap")

       new param[2]
       param[0] = 12
       param[1] = 15
       scheduled_start(param[0], param[1])
       set_task(15.0, "balance_adjust", 0, "", 0, "b")

       return PLUGIN_CONTINUE
   }
