Floats help
#1

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.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)