26.09.2010, 18:24
(
Последний раз редактировалось Rzzr; 26.09.2010 в 20:13.
)
IsApproximately
Very simple though very useful piece of code.
I've made this a long time ago, and I have used it quite a lot.
You can use it to check if number 1 is approximately the same as number 2, instead of checking if it is number 2.
So instead of if(1 == 5) (which checks if 1 is 5,)
you now use if(IsApproximately(1, 5, 6)). Now you check if 1 is approximately the same as 5, with a possible difference of 6.
You can use it (for example) to see if someone's Angle is approximately the same as someone else's angle, if someone's money is approximately the same as someone else's and so on.
pawn Код:
stock IsApproximately(Float:number1, Float:number2, Float:difference)
{
if(number2 <= number1+difference && number2 >= number1-difference) return true;
else return false;
}
I've made this a long time ago, and I have used it quite a lot.
You can use it to check if number 1 is approximately the same as number 2, instead of checking if it is number 2.
So instead of if(1 == 5) (which checks if 1 is 5,)
you now use if(IsApproximately(1, 5, 6)). Now you check if 1 is approximately the same as 5, with a possible difference of 6.
You can use it (for example) to see if someone's Angle is approximately the same as someone else's angle, if someone's money is approximately the same as someone else's and so on.

