SA-MP Forums Archive
strfloat comparison issues - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: strfloat comparison issues (/showthread.php?tid=208245)



strfloat comparison issues - MisterTickle - 08.01.2011

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?


Re: strfloat comparison issues - admantis - 08.01.2011

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


Re: strfloat comparison issues - Joe Staff - 08.01.2011

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



Re: strfloat comparison issues - MisterTickle - 08.01.2011

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.


Re: strfloat comparison issues - Joe Staff - 08.01.2011

it should just fine.