Is there a way I can change someone's score if an execute command block is successful WITHOUT using comparators? I wanna give an alert to anyone if a zombie is nearby in my map so I put /execute @a ~ ~ ~ testfor @e[type=Zombie] and want to give anyone that got successful results for that testfor a score of 1 so I can do additional things.
We set up the objectives and set the default value of ZombieNear to 0, so it won't be null. ZombierNear will represent if anyone got a successful result when testing for zombies nearby. WhichPlayer will be used to differentiate between players and makes it multiplayer compatible (don't worry too much about it). Then, we run the following commands here in order (order matters here):
/scoreboard players set @r WhichPlayer 1
/stats entity @p[score_WhichPlayer_min=1] set SuccessCount @p ZombieNear
/execute @p[score_ZombieNear_min=1] ~ ~ ~ /say Zombies are near! (optional)
/scoreboard players set @a[score_WhichPlayer_min=1] WhichPlayer 0
Make sure that you have those commands in the correct order -- you can put this on a super fast clock to detect it real-time. Basically, the first command just picks a random player. Then, the /stats command will set a trigger for the next command to store its own success count to ZombieNear. What this means is when the third command /execute-/testfor... if it succesfully executes /testfor, then it will store a SuccessCount of how many zombies it finds. The 4th command is just an example of the additional things you can do -- just make sure to have the target selector arguments [score_ZombieNear_min=1]. The 5th command resets which player is picked. If you run these command blocks on a fast clock, it will loop through everyone.
If you want to Skype me to help, get extra help, or just want to be friends, feel free : CreativiTimothy (I often find myself trying to look for friends that enjoy Minecraft, mainly because my friends in real life don't play Minecraft, so I appreciate all friends, whether redstoner, builder, survival-er, or PvPer)
Is there a way I can change someone's score if an execute command block is successful WITHOUT using comparators? I wanna give an alert to anyone if a zombie is nearby in my map so I put /execute @a ~ ~ ~ testfor @e[type=Zombie] and want to give anyone that got successful results for that testfor a score of 1 so I can do additional things.
Yes, there is a way. It uses CommandStats and the /stats command to store the success count of the /execute-/testfor command block.
First we create the objectives. We run these commands:
We set up the objectives and set the default value of ZombieNear to 0, so it won't be null. ZombierNear will represent if anyone got a successful result when testing for zombies nearby. WhichPlayer will be used to differentiate between players and makes it multiplayer compatible (don't worry too much about it). Then, we run the following commands here in order (order matters here):
Make sure that you have those commands in the correct order -- you can put this on a super fast clock to detect it real-time. Basically, the first command just picks a random player. Then, the /stats command will set a trigger for the next command to store its own success count to ZombieNear. What this means is when the third command /execute-/testfor... if it succesfully executes /testfor, then it will store a SuccessCount of how many zombies it finds. The 4th command is just an example of the additional things you can do -- just make sure to have the target selector arguments [score_ZombieNear_min=1]. The 5th command resets which player is picked. If you run these command blocks on a fast clock, it will loop through everyone.
I hope this helped! If it was too confusing, I suggest you read some tutorials on /stats and CommandStats, but if you do exactly what I mentioned above, it should work. I went around and messed with it on a world, so I will include a world download here: http://www.mediafire.com/download/xmnxr6oq5qsq8t3/xBloodstonemc_DoIfExecuteSuccess.zip
If you want to Skype me to help, get extra help, or just want to be friends, feel free : CreativiTimothy (I often find myself trying to look for friends that enjoy Minecraft, mainly because my friends in real life don't play Minecraft, so I appreciate all friends, whether redstoner, builder, survival-er, or PvPer)
Youtube (Redstone and Command Block inventions, concepts, and maps): https://www.youtube.com/channel/UCI0Glg0fEIeq_KgIQKFGN1g
I may have not understood well, but these commands should work too, and that's easier than CommandStats :
First create the objective with /scoreboard objectives add ZombieNear dummy
Run these commands on a clock :
/scoreboard players set @a ZombieNear 0
/execute @e[type=Zombie] ~ ~ ~ scoreboard players set @a[r=#] ZombieNear 1
You can now select the players with a zombie in a # radius with @a[score_ZombieNear_min=1]
There is a much more easy way to do this: /execute @a ~ ~ ~ /execute @e[type=Zombie,r=10] ~ ~ ~ /scoreboard...
No need for the double execute. Paulo28's method is the best for this situation.