3

I've started making a puzzle parkour map, where if you get a question wrong, you die. I have the player go through a slime bounce contraption to land on a pressure plate. The pressure plate then activates a command block (kill @p) and kills the player. However, it is killing ALL entities on my map! This was very frustrating, and I had to do my map without entities after that. After that I was messing around with the /detect ... kill @p and that killed me and all entities as well! Does anyone knows what is going on, or if I have to change a gamerule or something?

Thanks.

  • 3
    Are you using any mods? – Skylinerw Dec 9 '15 at 7:23
  • Does /kill @a[type=Player,r=x] seem like a good workaround? Set x to the radius (how far the player has to be from the command block) – John Smith Dec 9 '15 at 11:55
  • 2
    @JohnSmith type doesn't do anything for @a and @p, because it only affects players anyway. @e[type=Player,c=1] should be equivalent to @p. – MrLemon Dec 9 '15 at 12:36
  • 1
    Could you paste here the exact command that is in the command block? Also ensure that there are no nearby command blocks being activated with different commands. – SirBenet Dec 9 '15 at 17:31
  • 4
    @SMILIECHICKEN The command you've provided is structurally correct and only kills players; it works fine. You likely have another command block killing non-player entities that's activating. – Skylinerw Dec 10 '15 at 5:44
8
/kill @e[type=Player]

Make sure to use square brackets!

  • @peter that would kill all players they were doing @p for the closest player. you would have to add a " c=1 " so it would kill the closest one instead. – Hraponssi Dec 21 '15 at 7:26
0

I would go even more safe way. If player gets wrong answer, then give him scoreboard point in predefind objective and then kill all things with point in that objective. That way you can be sure that nothing else will get killed.

Run this command once to setup the objective:

/scoreboard objectives add wrong dummy

Then I bet the player chooses the answer by pressing some button etc. Just connect one commandblock to it, that will do something like this (update coords and radius for your needs):

/scoreboard players set @p[r=5,c=1] wrong 1

Then when he falls to his fate on pressure plate, the last commandblock will need to have something like:

/kill @p[score_wrong=1]

Plus you need (optional) reset to score, so if he tries again, won't be killed automatically (this also can be at start of the map with some initial button) - be sure you cannot target dead player by @p, only @a works

/scoreboard players set @a[score_wrong=1] wrong 0

The addition to this is that after setting his score in wrong you can do anything else with the player, even persuade him that he was right and let him through....and then kill him just after that with some another trap. :) Or When he is right, just make him some bad times by throwing him into pit, too. But then not killing him, because his wrong score is 0, the kill commandblock won't affect him.

Btw. I would recommend you to use /tellraw with all those commands, so players have some output why and what was happening. Typically you can use the wrong scoreboard again and differ if he is right or wrong and send him apropriate message. For that, I recommend JSON generator at http://minecraftjson.com

PS: If you want to have more tests, just setup more scoreboards same way, then you can kill players just before end even though they managed through half of puzzle etc.

  • This seems like massive overkill to achieve what is effectively: "kill whoever steps on this". – DBS Mar 30 '16 at 14:21
  • Ya, but it can provide more complicated possibilities for adventure maps. Pity I found it here and not when the OP asked it, so he probably no longer needs that :/ – Antoine Hejlík Mar 30 '16 at 14:31
0

You could try kill @a[x=123,y=69,z=420,dx=0,dy=1,dz=0]

Replace x=123,y=69,z=420 with the xyz coordinates for the kill area. the dx,dy,dz are the distance in blocks from the x,y,z that will be included in the kill area. it's important to include these. Without them, it would assume infinity or the loaded area, whichever is smaller. I found out the hard way and had to replace all of the item frames in my world along with all of the animals i had in the farm and the villagers. oh so many villagers. (i used @e in my commandblocks because i wanted everything to be affected, including mobs and items dropped on plates)

If you don't feel like manually setting coordinates for each commandblock, you can just use kill @a[r=2] but you have to put the pressure plate directly on the commandblock. Use r=3 if you want to put the commandblock under another block. I don't recommend going any higher than 3 since it could affect players on the adjacent block. r is the radius. 0 will target nothing since a circle with a radius of zero is just a point. A radius of 1 is the size of a single block, 2 will include 1 block area on all sides, and so on

Advantage of using coordinates: You get to place the command block anywhere in the loaded area or spawn chunks and have it affect only the area you want to punish unlucky/unskilled players. Disadvantage: Having to manually set the coordinates for each kill area.

Advantage of using radius (r): a single command can be copy and pasted on all death traps. very convenient. Disadvantage: could potentially affect adjacent players who are not in the intended kill area but are very close to it. The commandblocks have to be very close to the kill area.

The @a will make sure that all that step on the kill block will die instead of just one if you went with @p. for example if 2 players simultaneously land on the kill block, @p will kill one that is closest while the other will survive. Unless it's a repeating command block which I try avoid using since those are notorious for lagging servers and causing log files to become very large if logAdminCommands is true (which it is by default). If you have to use a repeating command block, first see if you can get away with just using an impulse command block hooked up to a redstone clock set to 10 game ticks aka:5 redstone ticks aaka:2 impulses per second. You can make a redstone clock that cycles every 10 game ticks by placing a redstone repeater set to maximum delay facing a block that has a redstone torch on the side and using redstone dust, make a redstone line from the torch to the back of the repeater. this will cause the torch to blink 2 times per second. You can place a lever on the block with the torch if you want to toggle the clock on/off.

-3

Use /kill @p [c=1] instead of just your answer.

  • 1
    @p only targets a single player anyways. Adding a c argument does nothing – MrLemon Apr 15 '16 at 18:47
  • 1
    Welcome to the site, Alex. Please give the tour a read. This reads more like a comment than an answer; once you have more rep, you'll be able to comment on existing posts. That said, combined with @MrLemon's, this sounds like it doesn't materially add to an expert resolution to the original poster's issue. – T.J.L. Apr 15 '16 at 19:11
  • 1
    You've also separated the parameters from the selector with a space, causing the parameters to be ignored in the first place. – Skylinerw Apr 15 '16 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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