strfloat comparison issues
#1

Okay so I convert the string of the inputtext of a dialog to a float than try to compare it between 0.01 and 100.0 but, It doesn't seem to be working properly.


Код:
new Float:amount = floatstr(inputtext);
if(amount < 0.01 || amount > 100.0)
Any ideas?
Reply
#2

stringfloat?
Makes no sense.
If you want to compare floats use Floatcmp
https://sampwiki.blast.hk/wiki/Floatcmp

EDIT: Sorry I didn't thread properly. Ignore ^.
Reply
#3

What he did will work, try rephrasing your 'if' statement a little bit

pawn Код:
if( (amount < 0.01) || (amount > 100.0) ) //This means that the number that was typed is outside of 0.01-100.0
Reply
#4

Thank you but, why wont it allow things such as 50.5 or 30.7? I want them to be able to do anything from 0.01 and 100.0 so they could set it to 0.50 if they wanted to.
Reply
#5

it should just fine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)