Comparing Floats
#1

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
Reply
#2

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
Reply
#3

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

You used floatabs in the return of GetDistanceBetweenPlayers ?
Reply
#5

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)