strval question
#1

Hello all,

pawn Код:
if(isnull(inputtext) || strval(inputtext) < 18 || strval(inputtext) > 60)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "Your age must be between 18 and 60");
                    ShowPlayerDialog(playerid, DIALOG_SET_AGE, DIALOG_STYLE_INPUT, "Age", "Please enter an age between 18-60", "Proceed", "Exit");
                }
For some reason you can enter any age and it does not make you re-enter your age. Am I doing something wrong? Please make me look stupid.
Reply
#2

try add return 1; after that ShowPlayerDialog

pawn Код:
if(isnull(inputtext) || strval(inputtext) < 18 || strval(inputtext) > 60)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "Your age must be between 18 and 60");
                    ShowPlayerDialog(playerid, DIALOG_SET_AGE, DIALOG_STYLE_INPUT, "Age", "Please enter an age between 18-60", "Proceed", "Exit");
                    return 1;
                }
Reply
#3

Paste all your code.... kirollos's suggestion is probably incorrect.
Reply
#4

pawn Код:
case DIALOG_SET_AGE:
        {
            if(!response)
            {
                ClearChat(playerid);
                SendClientMessage(playerid, COLOR_RED, "You have been kicked");
                SendClientMessage(playerid, COLOR_WHITE, "You have chosen to not partake in the registering process. If you change your mind, you are more than welcome to come back!");
                KickPlayer(playerid);
            }
            if(response)
            {
                if(isnull(inputtext) || strval(inputtext) < 17 || strval(inputtext) > 61)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "Your age must be between 18 and 60");
                    ShowPlayerDialog(playerid, DIALOG_SET_AGE, DIALOG_STYLE_INPUT, "Age", "Please enter an age between 18-60", "Proceed", "Exit");
                }
                pInfo[playerid][pAge] = strval(inputtext);
                ClearChat(playerid);
                SendClientMessage(playerid, COLOR_WHITE, "Good!  Now select your gender");
                ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, "Gender", "Please select your gender", "Male", "Female");
            }
        }
Reply
#5

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Paste all your code.... kirollos's suggestion is probably incorrect.
he posted the whole code = im correct :>
Reply
#6

Quote:
Originally Posted by kirollos
Посмотреть сообщение
he posted the whole code = im correct :>
You were
Reply
#7

It will work but is still not good in practice.

Why use return 1;

Good program flow you would use else

pawn Код:
case DIALOG_SET_AGE:
        {
            if(!response)
            {
                ClearChat(playerid);
                SendClientMessage(playerid, COLOR_RED, "You have been kicked");
                SendClientMessage(playerid, COLOR_WHITE, "You have chosen to not partake in the registering process. If you change your mind, you are more than welcome to come back!");
                KickPlayer(playerid);
            }
            if(response)
            {
                if(isnull(inputtext) || strval(inputtext) < 17 || strval(inputtext) > 61)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "Your age must be between 18 and 60");
                    ShowPlayerDialog(playerid, DIALOG_SET_AGE, DIALOG_STYLE_INPUT, "Age", "Please enter an age between 18-60", "Proceed", "Exit");
                }
                else
                {
                    pInfo[playerid][pAge] = strval(inputtext);
                    ClearChat(playerid);
                    SendClientMessage(playerid, COLOR_WHITE, "Good!  Now select your gender");
                    ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, "Gender", "Please select your gender", "Male", "Female");
                }
            }
        }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)