Sorting Players

Discussion in 'Plugin Development' started by nxtguy, May 8, 2013.

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

    nxtguy

    Hello,

    How would I go about sorting all the players on a server in to two uneven groups/teams.

    For example, there are 10 people on the server. I want 40% to be on red and 60% to be on blue.

    What would be the best way to do this? "Best" being least lag, and fastest. Also including code examples would be great.

    Thanks!
     
  2. Offline

    Suraski

    First get your percentages for both, 40% red lets say...

    Loop through the players in the game, and the first 4 of the 10 and add them to the players in the red group?
    For the 60% just loop through and add the other 6 to it?
     
  3. Offline

    nxtguy

    But is this really random? Wouldn't it just depend on when the players entered the server?
     
  4. Offline

    skipperguy12

    nxtguy
    So get the player randomly using Java's Random class, put them into an array, and then loop through that array?
     
  5. Offline

    nxtguy

    Awesome, thanks!

    skipperguy12 Would you also happen to know how to set the server motd?

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

    ZeusAllMighty11

    ServerListPingEvent

    setMessage(String msg);
     
  7. Offline

    nxtguy

    :D Thanks!
     
Thread Status:
Not open for further replies.

Share This Page