2

I want to be able to detect if a certain word in chat is said like:

Console: Please say yes to be teleported or no to remain
Player1: yes
Player1 teleported to [insert random coordinates here]

Something that would monitor the chat for a certain word.

Thank You.

4

Unfortunately there is simply no way, currently, to test for what players say in chat.


There is however an alternative which is quite similar; using /tellraw along with the new (1.8 snapshots only so far) /trigger command. This would allow you to create a message in chat that looks something like this:

Would you like to be teleported? [Yes]

And would actually work when you clicked the [Yes] button.


First you'll need to create an objective (lets say, Objective1) with type "trigger". Then, you'll need to use /scoreboard players enable Player1 Objective1 to allow Player1 to use /trigger Objective1. You'll need to do this each time you ask the player if they want to teleport.

Then, to display the actual clickable message, run something like this in a command block:

/tellraw Player1 {"text":"Do you wish to be teleported? ","extra":[{"text":"[Yes]","clickEvent":{"action":"run_command","value":"/trigger Objective1 set 1"}}]}

This sets their Objective1 score to 1, and from there you can simply do something like /tp @a[score_Objective1_min=1] Coordinates.


Here's a site that's quite useful for generating tellraw commands; there is a lot you can do with them but the syntax can initially be very confusing: http://ezekielelin.com/minecraft/tellraw/

1

Even simpler than the above, again made with the very useful tool ezekielelin's tellraw generator If you put this into a command block all you need to do is change the [target player] and x, y, z and add/ remove the x and y rotation

tellraw @a {"text":"","extra":[{"text":"Do you want to be teleported?"},{"text":"[Yes]","clickEvent":{"action":"run_command","value":"/tp [target player] <x> <y> <z> [<y-rot> <x-rot>]"}}]}
  • I can't verify this right now, but I am 95% sure that this won't work without the player that clicks having access to /tp himself (i.e. op). This is the entire reason Trigger objectives and the /trigger command were implemented in the first place. – MrLemon Jul 30 '14 at 11:07
  • MrLemon is correct. This will only work for someone with operator permissions, which is why I used the longer trigger method in my answer. – SirBenet Aug 10 '14 at 19:57
-2

It is possible by using /tellraw command

Create tellraw commands here: http://minecraftjson.com/

  • 4
    How would this command be used to accomplish the goal? Just saying a command can do it, and sending a reader elsewhere isn't very useful. – Frank Jan 4 '15 at 0:30

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