randomazing qustion

Discussion in 'Plugin Development' started by matanrak, Apr 15, 2014.

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

    matanrak

    i am working on a plugin and i wanted to ask if it is possible to check if any player online got a sertent score and if not to choose a random player.
    is it possible?
     
  2. It's pretty easy.

    You just loop through all online players and check their score. If you found someone, save this player.
    After you looped, check if the player is null. If so, do this:
    Code:java
    1.  
    2. Random rand = new Random()
    3. p = Bukkit.getOnlinePlayers().get(rand.nextInt(0,Bukkit.getOnlinePlayers().size() - 1));
    4.  
     
Thread Status:
Not open for further replies.

Share This Page