Inputtext
#1

Basically for age whatever you put in you can have it so you can have age as 90000 or as Halbla or something

How can i limit this so you can only input numbers and between 7 and 80?

pawn Код:
new age;
        age = strval(inputtext);
        if(age < 80 || age > 7)
        {
            PlayerInfo[playerid][pAge] = age;
            RegistrationStep[playerid] = 3;
            HidePlayerDialog(playerid);
            ShowPlayerDialog(playerid, 1501, DIALOG_STYLE_LIST, "Where you from?", "{FF0000} - USA\n{37DB45} - Europe\n{15D4ED} - Other", "Ok", "");
        }
        else
        {
            HidePlayerDialog(playerid);
            ShowPlayerDialog(playerid, 1500, DIALOG_STYLE_INPUT, "Age", "Input the correct age.", "Ok", "");
        }
Reply
#2

Post your OnPlayerDialogResponse.
Reply
#3

Код:
if(strval(inputtext) < 7 || strval(inputtext) > 80) return "you have to put right age message"
?
Reply
#4

Post the complete code of all the action.
Reply
#5

Read SmiT's Post
Reply
#6

that is the whole action that is the dialog response, you can still enter letters i just want numbers
Reply
#7

----->
Reply
#8

pawn Код:
if ( strval ( inputtext ) > 80 || strval ( inputtext ) < 7 )
{
    HidePlayerDialog(playerid);
    ShowPlayerDialog(playerid, 1500, DIALOG_STYLE_INPUT, "Age", "Input the correct age.", "Ok", "");
}
if ( !IsNumeric ( inputtext ) ) return ShowPlayerDialog(playerid, 1500, DIALOG_STYLE_INPUT, "Age", "Input the correct age.", "Ok", "");
PlayerInfo[ playerid ][ pAge ] = strval ( inputtext );
RegistrationStep[ playerid ] = 3;
HidePlayerDialog( playerid );
ShowPlayerDialog(playerid, 1501, DIALOG_STYLE_LIST, "Where you from?", "{FF0000} - USA\n{37DB45} - Europe\n{15D4ED} - Other", "Ok", "");


IsNumeric(const string[])
{
        for ( new i = 0, j = strlen ( string ); i < j; i++ )
        {
                if ( string[ i ] > '9' || string[ i ] < '0') return 0;
        }
        return 1;
}
Reply
#9

use && not ||

pawn Код:
new age;
        age = strval(inputtext);
        if(age < 80 && age > 7)
        {
            PlayerInfo[playerid][pAge] = age;
            RegistrationStep[playerid] = 3;
            HidePlayerDialog(playerid);
            ShowPlayerDialog(playerid, 1501, DIALOG_STYLE_LIST, "Where you from?", "{FF0000} - USA\n{37DB45} - Europe\n{15D4ED} - Other", "Ok", "");
        }
        else
        {
            HidePlayerDialog(playerid);
            ShowPlayerDialog(playerid, 1500, DIALOG_STYLE_INPUT, "Age", "Input the correct age.", "Ok", "");
        }
Reply
#10

Quote:
Originally Posted by Sinner
Посмотреть сообщение
use && not ||

pawn Код:
new age;
        age = strval(inputtext);
        if(age < 80 && age > 7)
        {
            PlayerInfo[playerid][pAge] = age;
            RegistrationStep[playerid] = 3;
            HidePlayerDialog(playerid);
            ShowPlayerDialog(playerid, 1501, DIALOG_STYLE_LIST, "Where you from?", "{FF0000} - USA\n{37DB45} - Europe\n{15D4ED} - Other", "Ok", "");
        }
        else
        {
            HidePlayerDialog(playerid);
            ShowPlayerDialog(playerid, 1500, DIALOG_STYLE_INPUT, "Age", "Input the correct age.", "Ok", "");
        }
No, * though it won't, the 'or' operator (||) is correct.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)