
   #include <amxmod>
   new teamchange[33] = {0,...}
   public deathmsg_handle(){
      new victim = read_data(2)
      if(teamchange[victim]){
          if(teamchange[victim] == 1){
                 engclient_cmd(victim, "chooseteam")
                 engclient_cmd(victim, "menuselect", "1")
             }
             if(teamchange[victim] == 2){
                 engclient_cmd(victim, "chooseteam")
                 engclient_cmd(victim, "menuselect", "2")
             }
          if(teamchange[victim] == 3){
                 engclient_cmd(victim, "jointeam","2")
             }
             if(teamchange[victim] == 4){
                 engclient_cmd(victim, "jointeam","1")
             }
             if(teamchange[victim] == 5){
                 engclient_cmd(victim, "jointeam", "1")
       }
       if(teamchange[victim] == 6){
                 engclient_cmd(victim, "jointeam", "2")
             }
             if(teamchange[victim] == 7){
                 engclient_cmd(victim, "jointeam", "3")
       }
       if(teamchange[victim] == 8){
                 engclient_cmd(victim, "jointeam", "4")
             }
         teamchange[victim] = 0
      }
   }
   public teamchanger(id){
      if (!(get_user_flags(id)&ADMIN_SLAY)){
         client_print(id,print_console,"[AMX]  You have no access to that
   command")
         return PLUGIN_HANDLED
      }
      if(read_argc()<1){
         client_print(id,print_console,"[AMX] Usage: <playername/authid>:
   Will change player to team select next time he dies.")
         return PLUGIN_HANDLED
      }
      new player[33]
      read_argv(1,player,32)
      new target
      target = find_player("c",player)
      if (!target) target = find_player("bl",player)
      if(!target){
         client_print(id, print_console, "[AMX] Player not found")
         return PLUGIN_HANDLED
      }
      if(get_user_flags(target) & ADMIN_IMMUNITY){
         client_print(id,print_console, "[AMX] That player has immunity")
         return PLUGIN_HANDLED
      }
      new command[33]
      read_argv(0,command,32)
      //CS Support
      if(is_user_alive(target) && equal(command,"amx_t")){
         teamchange[target] = 1
      }
      if(!is_user_alive(target) && equal(command,"amx_t")){
         engclient_cmd(target, "chooseteam")
         engclient_cmd(target, "menuselect", "1")
      }
         read_argv(0,command,32)
         if(is_user_alive(target) && equal(command,"amx_ct")){
            teamchange[target] = 2
         }
         if(!is_user_alive(target) && equal(command,"amx_ct")){
            engclient_cmd(target, "chooseteam")
            engclient_cmd(target, "menuselect", "2")
      }
      //DoD Support
         read_argv(0,command,32)
         if(is_user_alive(target) && equal(command,"amx_allies")){
            teamchange[target] = 3
         }
         if(!is_user_alive(target) && equal(command,"amx_allies")){
            engclient_cmd(target, "jointeam","2")
      }
         read_argv(0,command,32)
         if(is_user_alive(target) && equal(command,"amx_axis")){
            teamchange[target] = 4
         }
         if(!is_user_alive(target) && equal(command,"amx_axis")){
            engclient_cmd(target, "jointeam","1")
      }
      //TFC Support
            read_argv(0,command,32)
            if(is_user_alive(target) && equal(command,"amx_blue")){
               teamchange[target] = 5
            }
            if(!is_user_alive(target) && equal(command,"amx_blue")){
               engclient_cmd(target, "jointeam","1")
         }
            read_argv(0,command,32)
            if(is_user_alive(target) && equal(command,"amx_red")){
               teamchange[target] = 6
            }
            if(!is_user_alive(target) && equal(command,"amx_red")){
               engclient_cmd(target, "jointeam","2")
      }
            read_argv(0,command,32)
            if(is_user_alive(target) && equal(command,"amx_yellow")){
               teamchange[target] = 7
            }
            if(!is_user_alive(target) && equal(command,"amx_yellow")){
               engclient_cmd(target, "jointeam","3")
         }
            read_argv(0,command,32)
            if(is_user_alive(target) && equal(command,"amx_green")){
               teamchange[target] = 8
            }
            if(!is_user_alive(target) && equal(command,"amx_green")){
               engclient_cmd(target, "jointeam","4")
      }
      return PLUGIN_HANDLED
   }
   public plugin_init(){
      register_plugin("Admin Advanced Teams","0.0","LGBR")
      new modname[33]
   register_event("DeathMsg","deathmsg_handle","a")
      get_modname(modname,32)
      if(equal(modname,"cstrike")){
          register_clcmd("amx_ct","teamchanger",ADMIN_SLAY,"amx_ct
   <target>: Changes a user to Counter-Terrorists next time he is dead")
          register_clcmd("amx_t","teamchanger",ADMIN_SLAY,"amx_t
   <target>: Changes a user to Terrorists next time he is dead")
      }
      if(equal(modname,"dod")){
           register_clcmd("amx_allies","teamchanger",ADMIN_SLAY,"amx_alli
   es <target>: Changes a user to Allies next time he is dead")
             register_clcmd("amx_axis","teamchanger",ADMIN_SLAY,"amx_axis
   <target>: Changes a user to Axis next time he is dead")
      }
      if(equal(modname,"tfc")){
           register_clcmd("amx_blue","teamchanger",ADMIN_SLAY,"amx_blue
   <target>: Changes a user to Blue next time he is dead")
             register_clcmd("amx_red","teamchanger",ADMIN_SLAY,"amx_red
   <target>: Changes a user to Red next time he is dead")
           register_clcmd("amx_yellow","teamchanger",ADMIN_SLAY,"amx_yell
   ow <target>: Changes a user to Yellow next time he is dead")
             register_clcmd("amx_green","teamchanger",ADMIN_SLAY,"amx_gre
   en <target>: Changes a user to Green next time he is dead")
      }
      return PLUGIN_CONTINUE
   }
