List of players

Discussion in 'Plugin Development' started by Queepo, Feb 7, 2011.

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

    Queepo

    Hi,
    Having trouble with what should be a very simple task. I want to create a list containing all online players and be able to split them all into strings, thanks in advance for the help.

    Queepo
     
  2. Offline

    Crash

    Code:
    int playersOnline = server.getOnlinePlayers().length;
    String[] players = new String[playersOnline];
    for(int i = 0; i < playersOnline; i++){
    
        players[i] = server.getOnlinePlayers()[i].getName();
    
    }
     
  3. Offline

    Queepo

    thanks thats perfect
     
  4. Offline

    Liggliluff

    This is something I'll need, but instead of a list, I want to Check.
    Here is an example:
    Code:
    if (server.getOnlinePlayers()[i].getName() == "Liggliluff")
    I don't know why, but it doesn't recognize me, and when I turn it into a comment, the code inside runs so I'm sure there is a problem with the is-statement.
    Is there anyone who can help me?
     
  5. why add the players to an array when you can get the players from the getOnlinePlayers() list?
     
  6. Offline

    Plutonium239

    Use this instead:
    Code:
    if (server.getOnlinePlayers()[i].getName().equals("Liggliluff"))
     
Thread Status:
Not open for further replies.

Share This Page