-2

This question already has an answer here:

I have used an online /tellraw editor to create a /tellraw command which uses clickable events to run /scoreboard commands (adds @p to a team), so I can use it on my Realms server.

The problem was, when non-operator players (they don't have cheats enabled) clicked the text, they didn't have the permission to use the command that would run when clicked. I have tried /execute to fix it, but then i realized that /execute is also a "cheat".

How can I fix this without having to give someone the ability to "cheat"?

marked as duplicate by Virusbomb, Timmy Jim, Schism, dly, Gigazelle Aug 19 '18 at 6:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

The use of scoreboard triggers is a solution to allow non OP players to trigger the execution of op level commands. Current Minecraft Java Edition is 1.12.2

Setup

Create a trigger objective one time manually:

/scoreboard objectives add cmdTrigger trigger

Create a command block that is RepeatUnconditionalAlways Active with command:

scoreboard players enable @a cmdTrigger


Setup Commands

Now create a chain of two command blocks. The first command block contains the OP command that you want non OP players to access. This chain will need to be repeated for each command.

First command block is RepeatUnconditionalAlways Active with example tp command:

scoreboard teams join Red @a[score_cmdTrigger_min=1,score_cmdTrigger=1]

Second command block is ChainConditionalAlways Active with command:

scoreboard players set @a[score_cmdTrigger_min=1,score_cmdTrigger=1] cmdTrigger 0

For a second command, repeat the two command blocks but use another cmdTrigger score:

scoreboard teams join Blue @a[score_cmdTrigger_min=2,score_cmdTrigger=2]
scoreboard players set @a[score_cmdTrigger_min=2,score_cmdTrigger=2] cmdTrigger 0

Continue with as many chains as you want commands.


Player Run Commands

To use the first OP command the player would have to use command:

/trigger cmdTrigger set 1

To use the second OP command the player would have to use command:

/trigger cmdTrigger set 2

Continued for as many commands as you have set up. These can be manually typed into chat by the players but they would have to know what each score does. This is what will be run with your tellraw clickEvent.

Here is an example:

/tellraw @a [{"text":"To join the red team: "},{"text":"[Click Here]\n","color":"red","clickEvent":{"action":"run_command","value":"/trigger cmdTrigger set 1"}},{"text":"To join the blue team: ","color":"none"},{"text":"[Click Here]","color":"blue","clickEvent":{"action":"run_command","value":"/trigger cmdTrigger set 2"}}]
  • Can I somehow hide the Trigger cmdTrigger changed with set 1 message that shows up every time I run the /trigger cmdTrigger set 1 command? – Quijibo Mar 22 '18 at 20:40
  • You can use /gamerule sendCommandFeedback false, but then other commands run by OP's will not have feedback unless there is an error. That message should not display for the non OP players who will be running that command. – IronAnvil Mar 23 '18 at 3:17
0

That's what the /trigger command is for. https://minecraft.gamepedia.com/Commands/trigger

It allows non-OP players to set/add to their score on a scoreboard objective with the type "trigger", but only if they've been enabled to do so:

/scoreboard players enable <entity> <trigger>

This works nicely with tellraw, just set the clickEvent to run the trigger command and detect the score (remember to re-enable, enabling is only for a one time use).

0

the answer is to set up a trigger command instead.

You basically set up a scoreboard objective with the type trigger and enable it for your players when they get the tellraw. Then you make them execute the trigger command (e.g. trigger set triggerObjective 1) via the clickEvent and detect their score (@a[score_triggerObjective_min=1,score_triggerObjective=1]) and do with them whatever you want.
Don't forget to reset the triggerObjective afterwards.

Helpful resources:
https://minecraft.gamepedia.com/Commands/trigger
https://minecraft.gamepedia.com/Scoreboard#Criteria

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