Have you tried the 'If this guy has the skull, set the score of [something] for him to 1' trick? Then command blocks that affects them would just be /[something] @a[score_name_min=1] or something like that?
– aytimothyNov 22 '14 at 7:08

@aytimothy no, but could you provide a more detailed example/explanation? im mostly new to advanced command block usage.
– ThedudxoNov 22 '14 at 7:53

Could you please do research into your question rather than asking us to do it for you. If you understand what I said: I'll clarify. But if you don't know how to "How do I make a counter?" - RESEARCH IT YOURSELF.
– aytimothyNov 23 '14 at 5:11

@aytimothy i have done research. your answer simply confused me, how was i to know to make a counter? the way you put it it looked like a single command. if you don't beleive i have done researh, i have made it work dynamicly (one button does all) up to 4 players. please don't auto assume and perhaps make your answers clearer, like you did in your edit. i have done research before asking this question, learning about /clear to test for an item. otherwise, my question would be more like "how to kill a player when they drop an item".
– ThedudxoNov 23 '14 at 5:36

3 Answers
3

Context:

In the Minecraft 14w08a, a snapshot between 1.8 and 1.7, you can now test for an item in a player's inventory by clearing 0 items of that type, as in the snapshot, it added the ability to specify the number of items to remove.

/clear [Player] [Item] [Data] [Count] [NBT Tags]

Except, it means that we have to identify the person and there is no way that you can capture the person in this. So, we need to give the player an identifier.

How do we do it?

This is a module. Repeat this contraption as many times as the number of players you want to track. So, 50 players means making this 50 times, but substituting the playerID for a different number, preferably plus one to the previous one.

Step 1: Create an identifier.
Using command blocks, you'll have to assign each player you want to test a value in a dummy score. Let's make a score calledplayerIDthat is a dummy value.

/scoreboard objectives add playerID dummy playerID

So, whenever you want to test for a player (if it's a PvP/command-block related map, all players have to be assigned a number when the connect/join the game; not spectating).

Step 1b.

Create a gate. All players have to go onto it when the game starts. When the first player steps on it, they are assigned a scoreboard value in the objective "playerID". This is what we'll be using to identify each player.

/scoreboard players set @p playerID 1

Now, the next player should either have to go onto another pressure plate, or you can make that same pressure plate give a different number (more complicated, not going to say how).Based on your comments, make a second gate for the second player and so on.

This gate should have /scoreboard players set @p playerID 2 and so on.

Step 2: Now, we'll have to a/testforfor each player.

Place a fast clock (at about 10Hz; turns on 10 times a second). You may go faster - But it will not work with repeaters/comparitors etc. That pulse goes into a command block with this command:

/clear @p[score_playerID=1,score_playerID_min=1] minecraft:Skull 0 0

This will clear the player with the playerID score of 1 zero Skulls.
If the player has a Skull in their inventory, it'll clear none of it and output 'true'.
If the player doesn't have a Skull in their inventory... (Although it's trying to clear no skulls, it checks if there are skulls. /clear commands output false if the item is not found, reguardless of how many needs to be removed.)

So, place a comparitor facing out of that /clear [blah blah blah] command block outputting to another command block. Now, let's put the "Oh, this guy fits this citeria."

If you want the score to automatically revert to 0 when the player loses the skull, just make a flip-flop gate (one that outputs to the left if the input is on, and to the right if the input is off etc.), with when the input is false, it outputs a signal to a command block that does:

Step 4: Doing something with them.
Now that you have an objective that gives a score of '1' to anyone with a skull in their inventory... Or '0' to those without one, you can just make a command block which does things to the players with the score of 1.

Create a command block that tests for this, on a 20Hz clock (refreshes 20 times a second, the fastest possible clock)... Or slower if you wish.

i'm having trouble with the following: /scoreboard players set @p playerID [1,2,3]. i have set it up so that each player must pass through an area (which activates this) before starting. the game gives me the error: '[1,2,3]' is not a valid number. it works with just the number 1, but then every player is going to get 1. i don't think i'm doing it right.
– ThedudxoNov 23 '14 at 4:30

@Thedudxo, you can't give players numbers with a single command. You'll need to make multiple gates, or a dynamic gate that gives each player a number, different to the other players. The square bracket simple means 'Replace this with any number between 1 and java's 32/64-bit value limit'.
– aytimothyNov 23 '14 at 5:01

Put a comparator to the command block with tp, where you attach a command block which places a command block with the next command set exactly where the previous command block was (with a repeater if necessary so you have enough delay for the new command block not to trigger immediately).

In the same way, you can replace the command of the second command block with one that makes it replace the first command with one giving the ID 3.

By chaining command blocks in this fashion (can be annoying depending on how many players you want to allow) you can have the command blocks update their commands with each ID.

In the end of the chain you make a command block that sets a command that sets a command that sets a command... and so on, that changes the first command into giving the player spectator mode.

And of course, you attach the tp command block to the ID setting command block and keep it unchanged all the time.

To illustrate what happens when this is running, I wrote the commands for a chain of three command blocks.

Assumptions (it should be clear what to change depending on the actual situation, if not could someone who gets it clarify in the comments, I'm too tired right now):

The TrackOutput parameter might need to be removed, as it's possibly 1.9-specific.

This chain is not tested, as I can't work on multiplayer.

What should happen:

The first player steps on the pressure plate.

The player gets the ID 1.

The player is teleported to the game spawn.

The command scoreboard players set @p playerID 2 is set for the first command block.

The command setblock 0 10 0 minecraft:command_block 0 replace {Command:scoreboard players set @p playerID 3,TrackOutput:0} is set for the second command block (or the third, if you count the tp command block).