Dialog Problem
#1

Okay, I have got this problem:
Firstly, it shows a dialog and asks you to type your age.
The problem comes when I type as a number:"asdasda"
It sends me message saying "ERROR: Whole string has to consist only numbers!", but it doesn't open me new 'AgeDialog'. I am asking why is happening that?
Same issue comes if I submit/type age over then 95 or less then 10.

pawn Код:
AgeDialog1(playerid)
{
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "In Game age", "Type your IG age:", "Submit", "Cancel");
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response)
    {
        switch(dialogid)
        {
            case 2:
          {
            if(CheckStringIfNumbers(inputtext))
            {
                new age=StringToNumber(inputtext);
                if(age<10 || age>95)
                {
                    SendClientMessage(playerid,COLOUR_GREY,"ERROR: Your age can be from 10 to 95!");
                    AgeDialog1(playerid);
                }
                else
                {
                          gPLAYER_AGE[playerid]=age;
                          new string[9];
                          format(string,sizeof(string),"Age: %d",age);
                          SendClientMessage(playerid,COLOUR_LIGHTBLUE,string);
                }
            }
            else
            {
                SendClientMessage(playerid,COLOUR_GREY,"ERROR: Whole string has to consist only numbers!");
                AgeDialog1(playerid);
            }
            gPlayerInfo[playerid][INITIALIZATION]=3;
          }

        }

    }
    return true;
}
This two functions you don't need to look at, they work perfectly.
pawn Код:
CheckStringIfNumbers(inputtext[])
{
    for(new i=0;i<strlen(inputtext);i++)
    {
        if(inputtext[i]<'0'||inputtext[i]>'9')
        return 0;
    }
    return 1;
}

StringToNumber(inputtext[])
{
    new counter=0;
    for(new i=0;i<strlen(inputtext);i++)
    {
        counter=counter*10;
        counter=counter+inputtext[i]-'0'+0;
    }
    return counter;
}
Reply
#2

Actualy the only reason why I put StringToNumber instead of strval is cause I forgot it exists. I understand that indentation here is very wrong, but I can't understand why it shows "ERROR: Your age can be from 10 to 95!" and doesn't show the dialog (they are in the same clause )
Reply
#3

Okay, I found the mistake. Thanks a lot for your time. This last reply helped me a lot.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)