Speeds and distances - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Speeds and distances (
/showthread.php?tid=283713)
Speeds and distances -
Srdjan - 16.09.2011
So lately I've been working a lot with distances, and speeds in SAMP, but I never manage to get the precise speed and distance travelled. I tried using GetTickCount () and few physics formulas for getting the speed and/or distance, but it never matches.
So what I want to ask is. How do I use the x, y and z velocity from GetVehicleVelocity? What's the formula to get "real life" speed, doesn't matter in which units.
Also, distance. Which units do I get that number in. Formula I (and everyone else) is:
Код:
distance = floatsqroot ((oldposX - newposX) * (oldposX - newposX) + (oldposY - newposY) * (oldposY - newposY) + (oldposZ - newposZ) * (oldposZ - newposZ)
Is it in yards, metres or something?
Thanks!
Re: Speeds and distances -
iggy1 - 16.09.2011
Its done in meters, i guess "GetPlayerVelocity" gives meters per second I'm not sure though.
Re: Speeds and distances -
Srdjan - 16.09.2011
GetPlayerVelocity returns x, y and z which need to be put in some formula to get the speed. I'm not sure if I'm using the right formula for that. Any suggestions?