Speed formules - 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: Speed formules (
/showthread.php?tid=296100)
Speed formules -
budelis - 09.11.2011
Hi. I want to talk about speed formules. I have some:
Код:
1.floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 180.3;
Код:
2.floatsqroot(floatpower(ST[0], 2) + floatpower(ST[1], 2) + floatpower(ST[2], 2)) * 200;
Which is better for use? Maybe you have someone new please post here.
Re: Speed formules -
Mauzen - 09.11.2011
floatabs is not needed, as squared numbers will always be positive. Also I do not recommend to use the floatpower function for this, as it is way slower than just doing: ST[0] * ST[0]
So my choice would be simply
floatsqroot(ST[0] * ST[0] + ST[1] * ST[1] + ST[2] * ST[2]) * FACTOR
Where FACTOR is 200 or 180 or whatever, im not sure what factor is correct for getting kmh/mph