4

I am working on my Zombie map when I wanted to add a mechanic so that when you die you go into spectator and get to watch your team fight. I have most aspects of the mechanic working but I encountered a problem: I want to make it so when everyone is in spectator the map resets. I do this by adding three command blocks to the mechanic one to testfor @a[m=3] and the others just send them to the reset mechanic. I used this in a test world and for some reason it doesn't test for ALL players, just if there are anyone in spectator mode. Is there a way to test for everyone?

1
  • Yes, this is doable, but I don't have a working install of Minecraft right now, so I can't work the problem. The short answer, though, is that the scoreboard is your friend, along with testforblock in this case. Basically, you're going to use testforblock to see if a previous command block failed.
    – MBraedley
    May 22, 2016 at 1:04

1 Answer 1

2

You can test the existence of players not in spectator mode and invert the positive signal. In this case, you'd detect if the command block with /testfor had a SuccessCount value of 0, indicating that no players were found.

Repeating > Chain > Conditional Chain

  1. Basic command to look for players not in spectator mode.

    /testfor @a[m=!spectator]
    
  2. A /testforblock command that checks if the Repeating block was unsuccessful in finding any player not in spectator mode. Replace XYZ with the coordinates of the Repeating block.

    /testforblock X Y Z minecraft:repeating_command_block -1 {SuccessCount:0}
    
  3. Conditional. Command to run once there are no players not in spectator mode.

    /say There are no players not in spectator mode.
    
1
  • Thank you! I am still new to the new update so I never realized there were more than one command block. I understand your solution and it works perfectly. I can't wait to add it to the map.
    – diamondev
    May 22, 2016 at 2:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .