#How do I detect player movement that is only done by the player?

1 messages · Page 1 of 1 (latest)

cursive flame
#

I'm making an AFK plugin, and I'm using the PlayerMoveEvent to detect movement.
The issue is if the player moves by things like - water moving them or another player hits them I don't want that to count as them moving.
Is there a way I can do that?

toxic ice
#

A good way to combat simple AFK machines is to compare the player's pitch and yaw.

(Basically the things that let you look up, down, left and right.)

Compare their values every so often and if they haven't changed in while, you could mark the player as AFK.

cursive flame
#

Ah, shouldn't I worry about the player starting to move without moving their head though?

toxic ice
#

This isn't a perfect method as players could still use hacked clients with mods such as Derp that would randomize where they look.

#

But, it's a good solution for most players.

toxic ice
#

What kind of situations are you thinking of that would need the player to move first?

cursive flame
#

You mean before they move their head?

toxic ice
#

Yes

cursive flame
#

Oh I'm just thinking a player might start moving using the wasd and not the mouse

#

And it would be weird if they will still count as being afk

toxic ice
#

I mean, players can run around without moving their mouse, but it limits their movement significantly.
It's pretty common for AFK players to not touch their mouse, but be able to be pushed by other players. That action of moving them triggers most AFK systems to mark them as no longer AFK. If you instead just compare their pitch and yaw values instead of an actual location, you can get a better measurement of whether or not they are AFK.

#

This also allows you to teleport players to a location and still have them be AFK. (So long as they keep the direction they are looking at.)

cursive flame
#

Ah I see, then it is possible for them to move without moving their mouse but it's just not that likely

#

So I better use this method other than just checking their location

toxic ice
#

Yes. You could try and combine both methods, but this method is one of the simple but effective ones.