Creating Teams

Discussion in 'Plugin Development' started by TheCraftGamer, Aug 10, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    TheCraftGamer

    Hey there,

    I want to create a new Minigame and herefore I need the Players to be split up into 4 different teams.
    I already tried different ways but it never worked.

    Any Ideas how I can randomly move the players into different teams?
    Kind Regards
     
  2. Offline

    typtFabian3355

    I have the same problem. I have this Idea but it doesn`t work.

    Code:
    List<String> players = new ArrayList<>();
            for (Player player : Bukkit.getOnlinePlayers()) {
                players.add(player.getName());
            }
     
            Collections.shuffle(players);
     
            int Teamgroesse = Bukkit.getOnlinePlayers().length / 4;
            int team = 1;
            int Spielerzahl = 1;
            while (team < 5) {
     
                for (int x = 1; x <= Teamgroesse; x++) {
     
                    Main.Team.put(players.get(x), team);
                    players.remove(x);
                    Spielerzahl++;
                    x--;
                }
     
                team++;
            }
    Can Someone help us?
     
  3. Offline

    TheBoy3

  4. Offline

    xXMaTTHDXx

    We'll when they join you could put them onto teams like this
    if(team1.length> team2.length){
    team2.put(p.getName()):

    Did this on my phone so it is not perfect but basically you check how many people are in team on when the player joins the server if team on is greater than team to you put them on team to, and you and do the same for the rest.
     
  5. Offline

    typtFabian3355

    The Teams should create when the game starts.
     
  6. Offline

    TheCraftGamer

    Yea same for me, when there are 8 Players a countdown will start and just before the countdown ends and the players get teleported the should be put in a team.
    Any ideas?

    xXMaTTHDXx TheBoy3
    Any Ideas?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  7. Offline

    xXMaTTHDXx

    We'll first I would loop through all the players on the server then divide the length in half and put half on red and half on blue.
     
Thread Status:
Not open for further replies.

Share This Page