SA-MP Forums Archive
Comparing Floats - 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: Comparing Floats (/showthread.php?tid=334670)



Comparing Floats - ScottCFR - 15.04.2012

I wrote a small function to calculate the distance between two players. That works fine, it returns what I'd like it to. I'm trying to compare the returned value, with the number 5.

Код:
if(GetDistanceBetweenPlayers(i, TargetPlayer) > 5.0)
For some reason, this will only work if the arrow is facing right. When the arrow is facing right, the code works from any distance.



- Scott


Re: Comparing Floats - ReneG - 15.04.2012

I have no idea about the rest of the code, but > means greater than and < is less than so just use your common sense I guess


Re: Comparing Floats - ScottCFR - 15.04.2012

Yes, I know that. However, no matter what the number '5' is changed to, the left arrow doesn't work. But, the right arrow will work at any distance.


Re: Comparing Floats - ViniBorn - 15.04.2012

You used floatabs in the return of GetDistanceBetweenPlayers ?


Re: Comparing Floats - ScottCFR - 15.04.2012

Here's the function:

Код:
stock GetDistanceBetweenPlayers(player1, player2)
{
	new Float:x, Float:y, Float:z;
	GetPlayerPos(player2, x, y, z);
	new Float:dist = GetPlayerDistanceFromPoint(player1, x, y, z);
	return dist;
}