How do I test if all minecraft players on a server are in a radius?

How do I test if all minecraft players on a server are in a radius? - Student Cheating During an Exam

This has got me. I need a command that tells me if all players on a server are in a radius of a command block. If one of them isn't in the radius, the command will be false. Any ideas? Thanks!



Best Answer

Use a command block with the command /testfor @a[rm=RADIUS]. point a comparator from the command block into another block, and on that block, place a redstone torch. This tests if anyone is outside of the radius, and inverts the signal, providing the output you want.




Pictures about "How do I test if all minecraft players on a server are in a radius?"

How do I test if all minecraft players on a server are in a radius? - Student Getting A+ Mark in Her Exam
How do I test if all minecraft players on a server are in a radius? - Student Cheating During an Exam
How do I test if all minecraft players on a server are in a radius? - Student Cheating During an Exam



How do you test a player for a radius in Minecraft?

2. Type the Command
  • Test if Players are within 10 blocks. In this example, we will test to see if there are any players within a 10 block radius with the following command: /testfor @a[r=10] ...
  • Test if Mooshrooms are within 50 blocks. ...
  • Test if Nearest Player is at Level 20 experience.




  • Minecraft Tutorial | HOW TO USE RADIUS! (Test if a player is nearby)




    More answers regarding how do I test if all minecraft players on a server are in a radius?

    Answer 2

    A block-updateless method would be to use 1.9's new command blocks with the "conditional" setting, as well as using /testforblock to check the success of a command.

    Image example:

    Repeating > chain > conditional chain

    1. Look for players outside the area. This has been reduced to 1 player, as otherwise the command is processed equal to the number of players outside the area. All we need to know is if there's at least 1.

      /testfor @a[rm=10,c=1]
      
    2. Check the SuccessCount value of the Repeating command block. Replace the XYZ values with that of the Repeating command block. If the value was 0, that means no players were found.

      /testforblock X Y Z minecraft:repeating_command_block -1 {SuccessCount:0}
      
    3. Conditional. Command to run based on there being no players outside the area.

      /say No players outside the area.
      

    To further reduce server strain, you can disable output tracking on the command blocks. Do so by clicking the "O" button in the interface so that it turns into an "X":

    Command block interface

    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: RODNAE Productions, RODNAE Productions, RODNAE Productions, RODNAE Productions