SA-MP Forums Archive
How can I do an "if" with "inputtext"? - 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: How can I do an "if" with "inputtext"? (/showthread.php?tid=157352)



How can I do an "if" with "inputtext"? - Miikkel - 06.07.2010

I need help with a Dialog Box for an age selection.
I need it to check if the "inputtext" is numbers, but how can I make a "if( ..." with inputtext?

Thanks to anyone that helps me.


Re: How can I do an "if" with "inputtext"? - Carlton - 06.07.2010

Yes with strcmp.

pawn Код:
if(!strcmp(inputtext, "MyTextIwan'tmatch", true)) {
   
}
Edit: If you wan't make sure it's a interger use this.

pawn Код:
new MyAge = strval(inputtext);
if(MyAge >= myvalue) ....



Re: How can I do an "if" with "inputtext"? - Betamaster - 06.07.2010

Search the forums for IsNumeric.


Re: How can I do an "if" with "inputtext"? - Miikkel - 06.07.2010

Quote:
Originally Posted by Carlton
Посмотреть сообщение
Yes with strcmp.

pawn Код:
if(!strcmp(inputtext, "MyTextIwan'tmatch", true)) {
   
}
Thanks alot


Re: How can I do an "if" with "inputtext"? - DJBluefader - 06.07.2010

or
pawn Код:
if(strval(inputtext))
{
//Do something if it is the age
} else {
//Do something if it is not
}
or
pawn Код:
if(!strval(inputtext)) return //Do something if it is not the age



Re: How can I do an "if" with "inputtext"? - Carlton - 06.07.2010

Quote:
Originally Posted by Miikkel
Посмотреть сообщение
Thanks alot
I edited my post.


Re: How can I do an "if" with "inputtext"? - DJBluefader - 06.07.2010

I think, he got it.


Re: How can I do an "if" with "inputtext"? - Miikkel - 06.07.2010

Quote:
Originally Posted by DJBluefader
Посмотреть сообщение
I think, he got it.
I only need 1 way

But thanks everyone for helping me.