Floats help - 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: Floats help (
/showthread.php?tid=495685)
[SLOVED] Floats help -
Mike.FTW - 18.02.2014
Hi, I'm trying to make a anti-chat that detects no-recoil with the new OnPlayerWeaponShot from 0.3z.
How it will work? It will get the procent from last shot and actual one.
And if is bigger than 95%(or any value i will chose) that player will be suspected of no-recoil.
I tryed like this in script, but i get every time 99% or 0%.
((fX = actual shot on X axe from OnPlayerWeaponShot and LastShotX is obivous))
Код:
if(fX < LastShotX[playerid])
{
DividedX = floatdiv(fX, LastShotX[playerid]);
ProcentX = DividedX * 100;
}
I maked some calculs and you get the correct procent only if you divide floats after the dot(.), else it will be 99% or 0% every time and i dont know how to do that.
For example: 1985.46 and 1985.99 if you calculate after the dot it will be 46 / 99 = 0.46 * 100 it will be = 46%, that beeing the right value i want to get.
The question is: How to divide the floats just after the dot? Or is any way to get the same/better restult in a different way?
EDIT: I found how to do it. floatfract makes the float 0.?? and the calcul works.