0

I am working on my map and I really want to know WHY the SuccessCount tag doesn't work anymore in 1.11? I got at this conclusion when I tried to test if there are 2 players in a certain area. I read all the commands again in again, place and replaced back the command blocks (the command blocks can bug sometimes) and even brought a second account in that area to be sure.

enter image description here

1 - execute @e[type=armor_stand,name=lobby] ~ ~ ~ testfor @a[r=10,c=2]

2 - /testforblock ~1 ~ ~ minecraft:repeating_command_block -1 {SuccessCount:2}

3 - say test

Can someone help me with this? I tried so many solutions, but it kinda gets tidious to do anymore. I would like an explanation or maybe other solution.

2 Answers 2

1

It is working correctly; you are receiving the success count from the /execute command, not the /testfor command. If there is only 1 armor stand running the /testfor command, then the success count is going to be 1 if that /testfor command succeeds (causing /execute to succeed the 1 time).

You will need to rely on other methods to track total, such as removing /execute and using hard-coded coordinates:

/testfor @a[x=10,y=64,z=10,r=10,c=2]

Or scores to track the number of players (and detect that score instead of the SuccessCount value):

/scoreboard players set #NearLobby OBJ 0
/execute @e[type=armor_stand,name=lobby] ~ ~ ~ /execute @a[r=10,c=2] ~ ~ ~ /scoreboard players add #NearLobby OBJ 1
/scoreboard players test #NearLobby OBJ 2 *
1
  • Thank you! I know this solution is a little pain for my future commands, but it's worth it
    – iDoomfull
    Commented Oct 30, 2016 at 15:47
1

/testfor's SuccessCount is how many entities are found, however /execute's SuccessCount is how many times the contained command is successfully run.

As your command block contains /execute, the SuccessCount is tracking how many times the contained command (/testfor) is being successfully run. As /testfor is only being run once (I assume there's only one "lobby" stand), it can only ever succeed once.


As a simple workaround without having to go into stats or scoreboards, you could reverse the first command:

execute @a ~ ~ ~ testfor @e[type=armor_stand,name=lobby,r=10]

This means that the /testfor command will run multiple times and succeed once for every player near the stand.

Though note that this would no longer be capped at 2.


Alternatively, you can use command stats:

/stats entity @e[type=armor_stand,name=lobby] set SuccessCount @e[type=armor_stand,name=lobby,c=1] PlayersFound

Beforehand, you'll need to add a PlayersFound dummy objective, and also initiate the lobby armor stand's score to something (e.g: /scoreboard players set @e[type=armor_stand,name=lobby] PlayersFound 0) before stats will work.

Then, after running the first command, you can check if the armor stand found at least 2 players with @e[type=armor_stand,name=lobby,score_PlayersFound_min=2].

With this, you're checking the result of the /testfor command that the armor stand is running, rather than the /execute command that the command block is running.

1
  • Your solution is good, but Skylinerw's one is briefly explained :)
    – iDoomfull
    Commented Oct 30, 2016 at 15:48

You must log in to answer this question.

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