The Meaning of Life, the Universe, and Everything.
Join Date:
3/1/2015
Posts:
46
Minecraft:
TheMathGeek_314
Member Details
is there a way i could specify if a specific player died? I'm making a game where everyone is trying to kill one specific player, and that player is holding the tnt. When that player (and only that player) dies, give tnt to the nearest living player. If anyone else dies, nothing special happens. Can I do this somehow?
When a player holding tnt dies, I want to give the nearest player tnt. Basically I want to run the following command when Player1 dies:
/execute <Player1.corpse> ~ ~ ~ give @p tnt
Is there a way to do this or to work around it?
What do you mean by the "nearest player"? Do you mean the player that had died, or the closest living player to that dead player?
In either case, you will use the "deathCount" objective-type to track when the player dies. Only the @a selector can target dead players.
On a clock, which would cause a dead player to give the nearest-living player to them (since @p cannot target dead players) TNT:
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
is there a way i could specify if a specific player died? I'm making a game where everyone is trying to kill one specific player, and that player is holding the tnt. When that player (and only that player) dies, give tnt to the nearest living player. If anyone else dies, nothing special happens. Can I do this somehow?
You could try teleporting an invisible armorstand to each player and when someone dies the command stop working and then make a execute command.
/execute @e[type=ArmorStand,name=???] ~ ~ ~ /give @p tnt 1 0
but if I teleport an armor stand to EACH player, then the 'execute @e[...]' would run for every player, not just the one nearest to the dead player
Sorry if I'm not clear enough I am on mobile but something that you can do is before all of the commands that Skylinerw told you do this:
-Add an objective called Holding which is a dummy objective
-As the first command block in the machine order put: /scoreboard players set @a Holding 1 {SelectedItem:{id:"minecraft: tnt"}}
-Then in Skylinerw's command add this to the selector to select a dead player holding the tnt "score_Holding_min=1,score_Holding=1"
Link Removed
Thanks, this really helped for a PvP map I am working on.