1

How can I count the number of players on a team in 1.13?

Duel Studios's Avatar Duel Studios7/19/18 7:42 pm
1 emeralds 8.5k 3
7/23/2018 2:26 pm
garlicbreathinator's Avatar garlicbreathinator
I'm trying to make a deathmatch mode in minecraft but what I can't figure out is how to actually find out who the last one standing is. Originally I used the "successcount" value but now that that doesn't work I've been trying to figure out how to use the execute subcommands. If someone could help me out on how I can set up a "detection" system of sorts that would be greatly appreciated. Thanks
Posted by Duel Studios's Avatar
Duel Studios
Level 39 : Artisan Fox
37

Create an account or sign in to comment.

3

2
07/22/2018 7:32 pm
Level 31 : Artisan Engineer
garlicbreathinator
garlicbreathinator's Avatar
You can now use "/execute store" to store the success count of a command (or the output/result, in commands like /scoreboard players get) to an NBT tag or a scoreboard score.

Syntax for the whole command
The syntax is:
/execute store (result|success) <target (where the data's stored)> run <chained command>
result- the result of the chained command (ex. /scoreboard players get)
success- the success count (like from /stats) of the chained command

These are the 3 possible targets:
score <name> <objective> - Stores as <name>'s score in <objective>
entity <selector> <path to NBT tag> <data type> <scale> - Stores as <data type> in the selected NBT tag in <selector>'s data, multiplies it by <scale> first
block <coordinates> <path> <data type> <scale> - Same thing, only stored in the NBT of the block at <coordinates>, assuming it can store NBT

The command you want is probably something like
/execute store score Red playercount run team list Red (playercount is an objective, Red is a dummy)
If that doesn't work, this will
/execute store score Red playercount as @a[team=Red] at @s run tp @s ~ ~ ~ (test how many red players can teleport to the exact location they are in)

Good luck,
Garlicbreathinator
1
07/23/2018 2:16 pm
Level 39 : Artisan Fox
Duel Studios
Duel Studios's Avatar
So how would I run it to say run a command when there is only one player left on a team as that would be when the game ends. I have it set to give you a score when you are dead I just need help setting up it detecting for only 1 player. Thanks for replying btw.
2
07/23/2018 2:26 pm
Level 31 : Artisan Engineer
garlicbreathinator
garlicbreathinator's Avatar
To check when a team has only one player on it that is alive, use commands like this:
/scoreboard players set RedTeam playercount 0
/execute as @a[team=Red,scores={dead=0}] run scoreboard players add RedTeam playercount 1
/execute if score RedTeam playercount matches 0 run <chained command>

The chained command you want is probably one of these
-setting a redstone block somewhere to trigger a line of command blocks (to announce the winner, etc)
-running a function to do the same thing
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome