-1

I'm trying to make a minigame I already mentioned in other questions of mine. I think I got all the commands except one. I need a command block to return true when there is only one player left and that'll end the game.

I haven't tried anything yet because I have no idea how to do this. I have also tried researching this but I never get any info. Also, I'm on 1.7.10.

Is this possible in 1.7.10 and if so, how do I do it?

4
  • 1
    Just as a tip, this question might be better if you included your other questions that you mentioned in your first sentence :)
    – aman207
    Commented Mar 11, 2016 at 19:18
  • i'm new to arqade. how do i add links to my questions?
    – gamer103
    Commented Mar 11, 2016 at 19:49
  • Here this might help.
    – aman207
    Commented Mar 12, 2016 at 0:33
  • If someone finds this question and wants an answer for modern versions, go here: gaming.stackexchange.com/q/365931/171580 Commented Apr 20, 2020 at 4:26

2 Answers 2

0

Try giving all player an objective with the command scoring system, when someone loses give them a point and make a clock running with a command to detect if any players has 1 point on the objective, if they do you can teleport them away or kill them.

Then have a clock running to the side checking in a certain radius if there is one player with the score of 0, when all players have 1 point and are taken away there will that one player left the score of 0 and you can make him win with teleporting him the winner room or ssimply say in the chat, "you are the winner!"

You can probably find all the commands you need for this on the YouTuber channel of "Dragnoz". He does a lot of this kind of stuff.

1
  • i have thought of doing this but i am stuck on the part where it tells if there is one person left with a score of zero. also i have checked dragonz channel and nothing obvious that would help me came up. could you direct me to a certain vid?
    – gamer103
    Commented Mar 12, 2016 at 2:08
0

You can't test if there is only one player left, but instead you can test if there aren't more players left in an area, use this command:

/testfor @a[c=2,x=X,y=Y,z=Z,r=R]

Unfolded:

 /testfor       | testfor
      @a[]      | players
        c=2     | which are one of the 2 closest players
 x=X,y=Y,z=Z    | at the coordinates X, Y, Z
          r=R   | or R blocks away from them

That means you should replace X, Y, Z with the approximate center coordinates of your minigame area, and R with half the minigame area length.

Now you should stick a comparator out of the command block, and invert it's output, so if the command returns false (eg. that there are less then 2 players in the specified area), your output is true.

2
  • 1.13 syntax: /execute if entity @a[x=X,y=Y,z=Z,distance=..R,limit=2]
    – pppery
    Commented Jul 14, 2019 at 14:34
  • This does not work and has never worked, neither in 1.7, nor in 1.13 or between. You ask the game "are there players matching these conditions?" and then needlessly limit the selection to 2. It matches one as well. Commented Apr 5, 2020 at 2:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.