Cuberite Forum
GetSpeed() not working? - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: GetSpeed() not working? (/thread-3200.html)

Pages: 1 2


RE: GetSpeed() not working? - G3bE - 09-21-2018

No sorry, but it's basically just the speedCheck function above called in the movement hook


RE: GetSpeed() not working? - JARROD - 07-25-2019

Decent, need to accomplish something like this with mine.<p><br></p>


RE: GetSpeed() not working? - Krystilize - 03-07-2020

BTW, the way you are calculating speed is wrong, you have to use pythagoras to get the value instead of just x + z.
The function can be used like this:
Code:
function OnPlayerMove(aPlayer, OldPosition, NewPosition)
    Displacement = math.sqrt(((NewPosition.x-OldPosition.x)*(NewPosition.x-OldPosition.x))+((NewPosition.z-OldPosition.z)*(NewPosition.z-OldPosition.z)))
end
I am developing an anticheat that uses onplayermoving so i had to go through this process too.