Testing what a player says

Testing what a player says - Man in Blue Jersey Shirt and Shorts Playing Soccer

I would like to make a minecraft map where command blocks say would you like to go to lava parkour? Then if you say yes it will tp you if you so no nothing happens. I was thinking it's probably a /testfor @p/say"yes" or something I'm in the latest snapshot it is probably no something possible but I would like to try



Best Answer

Building on DatEpicCoderGuyWhoPrograms' Answer (and stealing his json for tellraw), you can use trigger to circumvent needing OP permissions to teleport on click. They have to be enabled for a player (done via commandblock), who can then use the /trigger command to modify his score once, then the trigger is disabled again.

Tutorial

Set up a trigger objective (once) using

/scoreboard objective add <name> trigger

Use two command blocks with

/scoreboard players enable <player> <name>
/tellraw @a {"text":"","extra":[{"text":"Would you like to teleport?","clickEvent":{"action":"run_command","value":"/trigger <name> set 1"},"hoverEvent":{"action":"show_text","value":"Teleport?"}}]}

The teleport itself is done via a command-block hooked to a clock, using

/tp @a[score_<name>_min=1] <x> <y> <z>

Replace all values in <> with the appropriate values.




Pictures about "Testing what a player says"

Testing what a player says - Man in White T-shirt Playing Basketball
Testing what a player says - Free stock photo of adult, black, black white
Testing what a player says - Free stock photo of adult, black, black white





Testing how good WOMEN'S Footballers ACTUALLY Are




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Thirdman, PNW Production, Tima Miroshnichenko, Tima Miroshnichenko