How to target to all players

Discussion in 'Plugin Development' started by RoopeFI, Aug 14, 2012.

Thread Status:
Not open for further replies.
  1. Hey!

    I was wondering how I can target command to all players online on the server.
    Example: I want to set everyone whos online to fire, so hows that possible?
     
  2. Offline

    Timr

    Code:
    for(Player p : Bukkit.getOnlinePlayers()) {
        p.setFireTicks(6000); //Set them on fire for 6 seconds           
    }
    This will iterate through all the players and set them all on fire.
     
  3. Offline

    tr4st

  4. Offline

    Icyene

    I'm pretty sure that method expects TICKS, not MILLISECONDS: there are 20 ticks in a second, to 120 in 6 seconds, not 6K. Correct my if I'm wrong, however.
     
  5. Offline

    Timr

    Ah, you're correct. You'll have to excuse me, it was 5 in the morning. For 6 seconds you would want to do p.setFireTicks(120);
     
  6. Offline

    Icyene

    Doing some early morning coding, I see (or late, VERY late night :p)
     
  7. Offline

    devilquak

    Is there a way to do this but exclude the player who sent the command?
     
  8. Offline

    zack6849

    check if all of the players in the loop are the sender, if not set them on fire
     
  9. Offline

    MnMaxon

    Code:
    for(Player p : Bukkit.getOnlinePlayers()) {
    if(p != sender){
        p.setFireTicks(6000); //Set them on fire for 6 seconds       
    }
    }
    I think
     
  10. Offline

    zack6849

    Code:
                for(Player p : Bukkit.getOnlinePlayers()) {
                    if(!p.getDisplayName().equalsIgnoreCase(sender.getName())){
                        p.setFireTicks(100); 
                    }   
                }
                    return true;
            }
     
  11. Offline

    Kodfod

    Earth Times:
    Second = 20
    Minute = 1200
    Hour = 72000
    Day = 1728000
    Week = 12096000
    Fortnight (Two Weeks) = 24192000
    Month = 48384000
    Quarter (3 Months) = 145152000
    Year = 2515968000
    Olympiad (4 years) = 10063872000
    Decade (10 Years) = 25159680000
    Indiction (15 Years) = 37739790000
    Generation (25 years) = 62899200000
    jubilee (Biblical) (50 years)= 125798400000
    Century (100 Years) = 251596800000
    Millennium (1000 Years) = 2515968000000
    exasecond (32 billion Years) = 90574848000000000000

    Just saying ==P
     
  12. Offline

    devilquak

    You forgot yottaseconds, 32 quadrillion years, which is 2.2 million times longer than the age of the universe.
     
  13. Thanks! Got it working with this!
     
  14. Offline

    Icyene

    Note its 120 ticks instead of 6000 for 6 seconds :p
     
  15. yeah i know, thanks :p
     
Thread Status:
Not open for further replies.

Share This Page