Kill all Players?

Discussion in 'Archived: Plugin Requests' started by pat231, May 10, 2012.

  1. Offline

    pat231

    Hello,

    Can someone help me? I am trying to write a small plugin for my server that kills all players at once with the command kall. I am still very new to java and doing all this. I have made a heal all function, I just need help with the kill all.

    Thank You so much in advance.
     
  2. Offline

    zathrus

    Code:
    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
        p.setHealth(0);
    }
     
  3. Offline

    pat231

    Thanks. I actually figured it out about 5 minutes before you posted. Thanks anyways.

    Do you think you could help me with something else? I am trying to get both of the commands to work together but I am having no suck luck:

    Code:
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
        if(cmd.getName().equalsIgnoreCase("healall")){
          for (Player p : Bukkit.getServer().getOnlinePlayers()) {
              p.setHealth(p.getMaxHealth());
          }
          for (Player p : Bukkit.getServer().getOnlinePlayers()) {
              p.setFoodLevel(20);
          }
          return true;
        }
        return false;
        }
    }
    How would I add the kill all command with the command /kall?

    Thanks in advance if you can help or not. Sorry for all the questions, I am trying to learn as best I can.
     
  4. Offline

    zathrus

  5. Offline

    pat231

  6. Offline

    KaiBB

    Also, this goes in Plugin Development, not Plugin Requests. Just a tip to help stay popular with the general public ^.^
     
    zathrus likes this.
  7. Offline

    Orcem12

    @pat231
    Code:
          for (Player p : Bukkit.getServer().getOnlinePlayers()) {
              p.setHealth(p.getMaxHealth());
          }
    to:
    Code:
          for (Player p : Bukkit.getServer().getOnlinePlayers()) {
              p.setHealth(20);
          }
     
    zathrus likes this.
  8. Offline

    sverre26

    Why do you want to kill all players?
     
  9. Offline

    pat231

    sverre26 Several reasons, we have a small Hunger Games instance. Some times I need to kill all the players, it is just a handy function I think.
     
  10. Offline

    ArcheCane

    He doesn't like them.
     

Share This Page