5

I'm developing a multiplayer minigame, but haven't been able to get any of my friends to help me on testing yet. I need to set EVERY players internalCash score to their cash score, but cannot use /execute, since it needs to run for non-op players.

It would be INCREDIBLY elegant if I could simply use

/scoreboard players operation @a internalCash = @a cash

but it doesn't seem to work properly with @e, which scares me. Could someone please tell me if I need to develop a clever workaround for this, or if this will do.

edit Oops! Kinda need the "players operation " part. :P

4
  • Hmmmmm... I seem to recall there being a way to do this, but /scoreboard @a objective = @a objective2 isn't it. I'll look into this.
    – Unionhawk
    Commented Dec 16, 2015 at 7:04
  • @Unionhawk its the players operation under scoreboard
    – Moddl
    Commented Dec 16, 2015 at 7:05
  • @ModDL Yeah, /scoreboard players operation @a targetObjective = @a sourceObjective, I think, but I'm not confident enough/haven't tested the operation of this enough to post such things as an answer right now. If you want to. go for it
    – Unionhawk
    Commented Dec 16, 2015 at 7:08
  • Same here, haven't tested this out. Never had to use operation before.
    – Moddl
    Commented Dec 16, 2015 at 7:09

1 Answer 1

4

/execute does not require the targets to be OP'd and is very necessary to use in order to do what you're trying to do. /scoreboard operations requires one of the two selectors to resolve to a single target, so you cannot use @a with @a.

Using /execute:

/execute @a ~ ~ ~ scoreboard players operation @a[c=1] internalCash = @a[c=1] cash
5
  • It doesn't? Hmm. I thought I had trouble with that before. What you suggest is what i originally had (except the @a[c=1] were @p selectors instead). So I DON'T have to go through and redo EVERYTHING. Thank goodness. Also, thanks for the help! :) New here, so my upvote doesn't count for your answer score :( Commented Dec 16, 2015 at 7:51
  • @sharpturn From the wiki: "executes the specified command as if executed by the specified target(s) with operator-level permission". Using @a[c=1] is preferred if /execute's target is also @a, because it is the only selector capable of targeting dead players. If you used @p instead of @a[c=1], dead players will still run the /scoreboard command but will instead target the next-nearest living player, which changes the wrong target's scores. You could also use @e[type=Player] instead of @a for /execute and use @p for /scoreboard.
    – Skylinerw
    Commented Dec 16, 2015 at 7:55
  • 1
    You might be confusing execute with JSON-based commands in books, signs and tellraw, which do run with the user's permission level (hence /trigger exists).
    – MrLemon
    Commented Dec 16, 2015 at 8:39
  • Thanks for all the help! I was probably just confusing /tellraw clickEvents with /execute commands. I only recently got back into commands in minecraft, so still very slightly rusty. Still capable of making shelves in one command block, though! Proud of that one. Commented Dec 16, 2015 at 9:00
  • 1
    @MrLemon Just a tiny correction: signs, unlike /tellraw or books, actually behave like /execute in that the clicker is given elevated permission to run the command. Oddly though, the coordinate origin of execution is the sign's coordinates, but the player is still the designated executor as sender bias applies to them.
    – Skylinerw
    Commented Dec 16, 2015 at 9:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .