
   /* AMX Mod script.
   *
   * (c) Copyright 2003, Thraka (c)
   * This file is provided as is (no warranties).
   *
   * Neophytes DoD Server - 66.237.58.104:27015
   */
   #include <amxmod>
   #include <amxmisc>
   new logfilename[256]
   //
   ======================================================================
   ============================== //
   //
   ======================================================================
   ============================== //
   public switch_sides() {
      new maxplayers //= get_playersnum()
      new team1[10]
      new players[32]
      new cvar_team
      // Check for access
      //if (!cmd_access(id,level,cid,2))
      //return PLUGIN_HANDLED
      // Store limitteams cvar
      cvar_team = get_cvar_num("mp_limitteams")

      // Turn off limit teams
      set_cvar_num("mp_limitteams",0)

      // Let everyone know what is going on
      set_hudmessage(0,255,0,0.02,0.5,2, 0.1, 5.0, 0.02, 0.1, 1)
      show_hudmessage(0,"* ** Switching teams for new round")
      get_players(players, maxplayers,"","")
      // Loop through and change to opposite team
      for(new i = 1; i < 33; ++i){
         if ( is_user_connected(i) ){
         get_user_info(players[i],"team",team1,9)
            if(equal(team1,"axis")){
               client_cmd(players[i],"jointeam 1")   //Move Allies
            } else if(equal(team1, "allies")){
               client_cmd(players[i],"jointeam 2")   //Move Axis
            }
         }
      }
      // Restore limitteams cvar
      set_cvar_num("mp_limitteams",cvar_team)
      // Let everyone know what is going on
      set_hudmessage(0,255,0,0.02,0.5,2, 0.1, 5.0, 0.02, 0.1, 1)
      show_hudmessage(0,"* ** Switching teams for new round")
      return PLUGIN_HANDLED
   }
   //
   ======================================================================
   ============================== //
   //
   ======================================================================
   ============================== //
   public cmdChangeteam(id,level,cid){
      new arg[32]
      new admin[32]
      new admin_target[32]
      new msg[256]
      read_argv(1,arg,31)
      // Check for access
      if (!cmd_access(id,level,cid,2))
      return PLUGIN_HANDLED
      new player = cmd_target(id,arg,5)
      // Check target not admin
      if ( get_user_flags(player) & ADMIN_IMMUNITY )
      return PLUGIN_HANDLED
      //Get admin who called the commands, name (for logging)
      get_user_name(id,admin,31)
      get_user_name(id,admin_target,31)
      // Check to see if player was successful
      if (!player) return PLUGIN_HANDLED
      // Get the team he is on
      new team1[10]
           get_user_info(player,"team",team1,9)

      // Test his team
      if(equal(team1,"axis")){
         client_cmd(player,"jointeam 1")
      } else if(equal(team1, "allies")){
         client_cmd(player,"jointeam 2")
      }
      // Let him know what happened
      set_hudmessage(0,255,0,0.02,0.5,2, 0.1, 5.0, 0.02, 0.1, 1)
      format(msg,256,"** * Your team has been changed by the admin * **")
      show_hudmessage(player,msg)
      log_to_file(logfilename,"Changeteam:   %s   changed   %s   team  to
   %s",admin,admin_target,team1)
      // END
      return PLUGIN_HANDLED
   }
   //
   ======================================================================
   ============================== //
   //
   ======================================================================
   ============================== //
   public round_end(id){
      if (get_cvar_float("amx_autoswitchsides")) {
         switch_sides()
      }
   }
   //
   ======================================================================
   ============================== //
   //
   ======================================================================
   ============================== //
   public plugin_init() {
      register_event("RoundState","round_end","a","1=3","1=4")
         register_plugin("DoD Team Commands","0.9.4c","Thraka")
         register_cvar("amx_autoswitchsides","0")
      register_concmd("amx_changesides","switch_sides",ADMIN_KICK,"-
   Moves everyone to their opposite teams")
      register_concmd("amx_changeteam","cmdChangeteam",ADMIN_KICK,"-
   player name/id/wonid - Changes the player to the opposite team")
      get_time("addons/amx/logs/admin%m%d.log",logfilename,255)
         return PLUGIN_CONTINUE
   }
