2

Im using command block on a multiplayer map I am creating. Is there any data value that goes up/down when a player looks in the direction of another player? If not, are you able to count how many players that are on a specific team in a set radius and then say that number through /tellraw?

1

Yes! There is!

If you're looking to teleport somebody, you can determine the direction that they're looking at with this syntax of the /tp command.

/tp @p [x] [y] [z] [x-look] [y-look]

If you're looking to select somebody looking in a certain direction, you can use the rx, rxm, ry and rym selector arguments.
For each selector, a float is required as the value to look for. The ry and rx arguments look for a player with a rotation lower than the given value, while the rxm and rym arguments look for a player with a rotation greater than the given value.

  • The rx and rxm arguments test for the player's horizontal rotation.
    -90.0 being that he/she is looking straight down and 90.0 for straight up.
  • The ry amd rym arguments test for the player's vertical rotation; whether they are looking North, South, East or West.
    This system branches from the South direction (0d) and moves into negative/positive; East (-90d)/West (90d) and North (180d/-180d).
    It also allows for in-betweens of multiples of 90 degrees, allowing freedom in testing for certain rotations, for example: 45d is South West.

For example, if I would like to test for a player that is looking North West, and straight ahead (at ground level), I would test for a rx and rxm of 0 (directly ahead) and a ry and rym of somewhere between North (180d) and West (90d); 135 degrees.

 /testfor @a[rx=0,rxm=0,ry=135,rym=135] ...

Just note, that this command tests for exact rotation, which can be really hard to reach. It'd be better to give leeway either side, for example: 5 degrees.

 /testfor @a[rx=5,rxm=-5,ry=140,rym=130] ...

If not, are you able to count how many players that are on a specific team in a set radius and then say that number through /tellraw?

This is also achievable. This time, add the team selector to your command, and to count, get each player to /execute @a[...] ~ ~ ~ scoreboard players add dummy count 1, assuming that you have a dummy player to take the count, have the score set to 0 and your counting scoreboard is count.

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.