0

With /scoreboard objectives add killCount playerKillCount Kills I can make a Kill Counter, but I want to convert the kill point in a in-game vanilla currency that I created with /scoreboard objectives add Money dummy Money. How can I add money just for the killer and not for every person online on the server? I'm using scoreboards for the first time and I'm a bit confused.. The scoreboard is player-related or keeps track of every player online in a unique scoreboard?

1

With Scoreboard operations you can set/change the value of one players scoreboard to another player's (May be the same) score in another objective (may be the same objective). The scoreboard is univeresal, in the scoreboard there are objectives, which are sub divisions of the scoreboard. In each objective each player can have a score, the score of the player exists only in that objective and MAY be different in other objectives.

The solution: Every tick add the player's kill count to his money and reset his kill count

Setup:

/scoreboard objectives add killCount playerKillCount
/scoreboard objectives add multiplier dummy
/scoreboard objectives add money dummy

Clock(20 tick):

/scoreboard players set @a multiplier <How Much money per kill>
/execute @a ~ ~ ~ scoreboard players operation @p[r=0] killCount *= @p multiplier      
/execute @a ~ ~ ~ scoreboard players operation @p[r=0] money += @p killCount
/scoreboard players set @a killCount = 0;
  1. Set their multiplier
  2. Multiply their killCount by the multiplier
  3. Add their killCount(Now in terms of money) to their money
  4. Reset their killCount
4
  • 1
    Small tip: you should not be mixing @a with a nested @p. The @a selector can target dead players while @p cannot, meaning that if the player happens to die, they will still be running the /scoreboard command while dead but will instead affect the scores of the nearest-living player to them. The fix is to use similar selectors, such as @a with @a[c=1] or @e[type=Player] with @p. The sender bias still applies, so it will work fine. Example: /execute @a ~ ~ ~ scoreboard players operation @a[c=1] killCount *= @a[c=1] multiplier
    – Skylinerw
    Nov 23 '15 at 6:50
  • Should I use some kind of comparator attached to the first CB?
    – hiru
    Nov 23 '15 at 15:28
  • No comparators are needed, the setup commands you just need to run once and the clock commands you run in order on a clock.
    – Moddl
    Nov 24 '15 at 1:28
  • @ModDL Concerning your edit: adding r=0 does not fix the issue with dead players. You should use @a[c=1], not @p[r=0]. It will not help in targeting the dead player (even less so due to the use of radius, which prohibits @a from targeting dead players, but won't matter since @p can't target dead players) and the targeting flaw still occurs if a living player is within the same block space of the dead executor. It's best to completely avoid flaws with the options that are available. Sender bias does apply with @a[c=1] and the dead player will always target themselves no matter what.
    – Skylinerw
    Nov 24 '15 at 3:26

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.