Dialog question
#1

So how can i make people has to only type numbers, they can't type letters.
pawn Код:
if(!strlen(inputtext))
                {
                    ShowPlayerDialog(playerid,83,DIALOG_STYLE_INPUT,"Vehicle Color Change","What do you want your first color to be? 0-255","Accept","Cancel");
                    SCM(playerid,0xFF9900AA,"You must enter your first color.");
                    return 1;
                }
Reply
#2

Use STRVAL.

if is possible to convert a string into a int, it means there is only numbers.

pawn Код:
if(!strval(inputext))
    return SendClientMessage(playerid,-1,"Type only numbers!");
Reply
#3

Thank you.
Reply
#4

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
Thank you.
Glad to help you ^^
Reply
#5

Got a problem, i put 3 but it says i put 51...
pawn Код:
if(dialogid == 83)
        {
            if(response)
            {
                if(!strval(inputtext))
                {
                    ShowPlayerDialog(playerid,83,DIALOG_STYLE_INPUT,"Vehicle Color Change","What do you want your first color to be? 0-255","Accept","Cancel");
                    SCM(playerid,0xFF9900AA,"You must type a number between 0-255");
                }
                if(strval(inputtext) < 0)
                {
                    ShowPlayerDialog(playerid,83,DIALOG_STYLE_INPUT,"Vehicle Color Change","What do you want your first color to be? 0-255","Accept","Cancel");
                    SCM(playerid,0xFF9900AA,"You must type a number between 0-255");
                }
                if(strval(inputtext) > 255)
                {
                    ShowPlayerDialog(playerid,83,DIALOG_STYLE_INPUT,"Vehicle Color Change","What do you want your first color to be? 0-255","Accept","Cancel");
                    SCM(playerid,0xFF9900AA,"You must type a number between 0-255");
                }
                GetPlayerName(playerid,Nam,sizeof(Nam));
                format(str,sizeof(str),"UPDATE PlayerDealership SET Col1 = %d WHERE Owner = '%s'",inputtext,Nam);
                mysql_query(str);
                format(str,sizeof(str),"You have put your vehicle's first color to %d",inputtext);
                SCM(playerid,lightgreen,str);
                format(CarSystem[CarSystem[playerid][vID]][vCols][0],24,"%s",inputtext);
                ShowPlayerDialog(playerid,84,DIALOG_STYLE_INPUT,"Vehicle Color Change","What do you want your second color to be? 0-255","Accept","");
            }
        }
Reply
#6

Any time you want to use inputtext as an integer, you need to use strval(inputtext). This includes in the formatting of your query and message.
Reply
#7

Or create a var to store the value, its faster than always turn into a value.

pawn Код:
new colorid = strval(inputtext);
// i recommend put it where you know it's a real integer. (After some conditions?)
// Example
printf("Color ID %d",colorid);
Reply
#8

Thank you again, for helping .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)