Take the 2-minute tour ×
Arqade is a question and answer site for passionate videogamers on all platforms. It's 100% free, no registration required.

I'm trying to activate some command blocks only if there's more than one player online in my vanilla server. Is there a way to accomplish this with command blocks?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You probably want to use the testfor command with some type of selector.

The easiest thing to do would be to use the @a selector with a redstone comparator. The @a selector will return the count by means of the signal strength, which can be compared to a known strength. If you want to check for more than one (2 or more), then it's as simple as C=rr> where C is the command block, = is the comparator, r is redstone dust, and > is the repeater. (Thanks to @MBraedley for the suggestion)

You could also probably use the c selector here, for count, but I'm not 100% sure how that works in a conditional.

The name selector would also do it if you want to be sure there are other people around with names that are not yours, but that won't work if you need it to not trigger if only one non-you person is on the server.

share|improve this answer
1  
I don't think you need the count selector. testfor @a should be all that's needed. –  MBraedley Nov 25 '13 at 12:15
    
@MBraedley Won't that return true if there is only one player? The OP said "more than one". Actually, if there are no players the command block probably won't run because the chunk won't be loaded unless there's some mod involved... –  Yamikuronue Nov 25 '13 at 13:41
3  
It will return the count through a comparator by means of the signal strength. If you want to check for more than one (2 or more), then it's as simple as C=rr> where C is the command block, = is the comparator, r is redstone dust, and > is the repeater. –  MBraedley Nov 25 '13 at 13:57
    
I'll try these alternatives and give you a feedback asap. Thanks –  André Maldonado Nov 25 '13 at 16:41
    
It worked! Thank you all. –  André Maldonado Dec 3 '13 at 13:18

You can also use the c tag:

How it works: /testfor @a[c=!1]

Than he tests when there isn't own player online. He works than also as 0 players are online, but neveryone can see that. Only in the server data. You place a comparator next to the commandblock and then you can do what you want, but when you want a redstone line, you have to place a repeater.

Good luck.

Stef

Sorry for the spelling mistakes I'm Dutch.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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