SA-MP Forums Archive
Dialog Problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Dialog Problem (/showthread.php?tid=264048)



Dialog Problem - Roko_foko - 24.06.2011

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



Re: Dialog Problem - Roko_foko - 24.06.2011

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 )


Re: Dialog Problem - Roko_foko - 24.06.2011

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