Two players at once?

Discussion in 'Plugin Development' started by ChrisStarr32, Apr 28, 2014.

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

    ChrisStarr32

    Is it possible to have two players in one variable?
    Maybe like
    Code:java
    1. Player p = killer && killed;
    2. //:)


    Im sorry for my noobish if this is not possible.. Just curious! :)
     
  2. Offline

    rfsantos1996

    Nope, but if you want something more easier than writing lines and lines of "Player " you can do:
    Code:java
    1. Player p = killer, p1 = killed, p3 = e.getPlayer();
    2.  
    3. // I belive this will work either
    4.  
    5. Player[] players = {killer, killed, e.getPlayer()};
    6.  
    7. // Arrays (this Object[] thing) have a fixed size, 0 -> max size and will thrown an exception if tried to get a non-existent thing
    8. // Then, remember to check its length before using:
    9. if(players.length > 3) { // or >= 4, because arrays will be players[0] ... players[3] (0-3 = 4 objects)
    10. players[3].doStuff();
    11. }

    I know I made something very basic, but I don't know how much Java do you know, so...
     
    ChrisStarr32 likes this.
  3. Offline

    ChrisStarr32

Thread Status:
Not open for further replies.

Share This Page