Choose a random player online

Discussion in 'Plugin Development' started by zapamundi, May 8, 2014.

Thread Status:
Not open for further replies.
  1. Hi i want to make a method that make that:
    Choose 1 player of online players
    then pick that player and join in the red team
    and the rest of the players join in the blue team
     
  2. Offline

    GeorgeeeHD

    Code:java
    1. Random random = new Random();
    2. Player randomPlayer = Bukkit.getOnlinePlayers[random.nextInt(Bukkit.getOnlinePlayers.length())];
    3. //Code to put this player on red team
    4. for(Player all : Bukkit.getOnlinePlayers()) {
    5.  
    6. if(all != randomPlayer) {
    7. //Code to add to blue team
    8. }
    9.  
    10. }
     
  3. Thanks for it. Another question : wher i put these code??? in onEnable... OnCommand or wher?

    Bump!

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

    RainoBoy97

  5. Offline

    HungerCraftNL

    If you're doing the 'team joining' in a command you need to use this in the command, if you want the joining with signs you've to use it there.
     
  6. Offline

    GeorgeeeHD

    Have you actually coded anything yet? By the sounds of things, you don't really know what your doing, seeing as you don't know where to put the code you asked how to write :confused:
     
    ZodiacTheories likes this.
Thread Status:
Not open for further replies.

Share This Page