How to award player on every kill in Minecraft using command blocks?
I want to award the players in my game with 2 cooked porkchops every time they kill another player.
What I have tried so far, is setup one command block which gives every player with the killsloot scoreboard objective 2 porkschops, and setup another one which removes one from the killsloot scoreboard objective for all players for whom the objective is higher than one. The killsloot objective tracks kills.
The command blocks have the following commands, from left to right:
/give @a[score_killsloot_min=1] minecraft:cooked_porkchop 2
/scoreboard players remove @a[score_killsloot_min=1] killsloot 1
This does not seem to work however. Minecraft seems to remove the kills from the objective before it gives the item, and as a result, I receive no items. I can confirm this by, when I give myself a killsloot count of two, it runs the give command once, and when I give myself a killsloot count of three, it runs the give command twice.
I have tried swithing the command blocks in position, but that did not seem to change the order the command are run in.
How do I give a player two porkchop for every kill they get? I am on Minecraft version 1.8.
I would like to point out this question is not a duplicate of gaming.stackexchange.com/questions/194564/…, as it does not ask for a progressive award system, and the difference in how its achieved is quite significant.
Solution 1:
The activation order does matter and is what's causing the problem. However, activation order via redstone dust does not follow a pattern nor is the order it activates guaranteed to be constant. You would be better off adding delay between the two commands or using a more reliable activation method such as a /fill
clock.
Image example of activation order from a /fill
clock:
Source & tutorial
In 1.9, you can simply use chained command blocks to directly specify the order commands are activated, so as to not rely on unreliable and directional methods.