Have you tried adding a scoreboard to detect whether he has the flag? Look at how to get and store player name? This time, attempt to /clear the flag.
– aytimothy
I've answered a question looking to identify a player, and perform something at their death.
Long story short, follow the instructions to make the gate and to identify the players, but replace the /clear
command in the second step with:
/clear @p[score_playerID=1,score_playerID_min=1] minecraft:Wool 14 0
and the identifier with something else like... Say:
/scoreboard objectives create hasWool dummy hasWool
/scoreboard players set @p[score_playerID=1,score_playerID_min=1] hasWool 1
/scoreboard players set @p[score_playerID=1,score_playerID_min=1] hasWool 0
in order to identify whether someone has the flag or not. (This only works with /gamerule keepinventory true
.)
Next, when the player dies, simply do your command, since you know that they're dead, and they have the wool.
Update:
These commands all work, but the problem is: if the player is dead, they can't execute commands. You can't /execute as a player if the player is dead.
– xornob
Let's say we'll use a Creeper to be the placeholder for the /execute
command.
Run the conditional flip-flop gates (outlined in that first answer), testing for /testfor @a[score_h=0,hasWool_min=1]
(looks for a player who's dead and had the wool.
When a player is dead and has the wool (condition sets to true), run /tp @e[type=Creeper] @p[score_h=0,hasWool_min=1]
, make that creeper place the block /execute @e[type=Creeper] ~ ~ ~ setblock ~ ~1 ~ wool 14
and teleport away /tp @e[type=Creeper] 0 0 0
.
The false condition is up to you; you can either make it teleport the creeper back (since it's already done when the true condition runs anyway)
Just make sure that command is executed before they are respawn (or gets teleported to the respawn point)
Note: You can't directly @a
as when you use /clear @a minecraft:Wool 14 0
, it'll output true to everyone, even if only one person has it, while @p
just gets messy. (You're detecting the closest player)
The problem is that you can't target someone without a score using a score selector. So the solution, not surprisingly, is to give everyone a score. You don't have to change anyone's score value either; instead, just "increment" everyone's score by 0, in your case, with the following command:
/scoreboard players add @a hasJoined 0
Better yet, throw that command in a command block that is triggered off a 20Hz clock, and you're guaranteed that everyone always has a score.
The way this works is that everyone that already has a score in the hasJoined
objective won't have their score changed, but everyone else will have their hasJoined
score set to 0.
Best Answer
Assuming your Bukkit plugins don't interfere with vanilla commands (and if one does, go and hit the plugin dev with oak wood planks), your problem is most likely a misunderstanding of the target selector arguments.
There are two target selector arguments for every scoreboard objective:
score_NAME=X
andscore_NAME_min=X
, whereNAME
is the name of the objective, andX
is an integer number. The first one checks for the maximum, the second for the minimum score needed to be a valid target. To target someone with anOBJ1
of at exactly 4, you have to use both.This can be expanded almost infinitely with more objectives, for example
would target any player with an
OBJ1
score of 4,OBJ2
score of 2, andOBJ3
score between 66 and 99 (inclusive).In your teleport example, you'd use