SA-MP Forums Archive
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)
+--- Thread: Inputtext (/showthread.php?tid=298320)



Inputtext - HondaCBR - 20.11.2011

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", "");
        }



Re: Inputtext - NessaHD - 20.11.2011

Post your OnPlayerDialogResponse.


Re: Inputtext - iJumbo - 20.11.2011

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


Re: Inputtext - Eo - 20.11.2011

Post the complete code of all the action.


Re: Inputtext - Joshb93 - 20.11.2011

Read SmiT's Post


Re: Inputtext - HondaCBR - 20.11.2011

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


Re: Inputtext - Joshb93 - 20.11.2011

----->


Re: Inputtext - SmiT - 20.11.2011

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;
}



Re: Inputtext - Sinner - 20.11.2011

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", "");
        }



Re: Inputtext - Sinc - 20.11.2011

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.