Problem to show next dialog on player SetPlayerSpawn (Editing only to learn)
#3

Learn to debug, it'll save a lot of trouble. Learn how to use variables. That will save a lot of CPU usage. I've used sscanf instead your splits, so I don't have to use strval.

Before
pawn Код:
if(dialogid == dregister1)
    {
        if(RegistrationStep[playerid] == 1)
        {
            if(response) // If they clicked 'Male' or pressed enter
            {
                if(strlen(inputtext))
                {
                    new year, month,day;
                    getdate(year, month, day);
                    new DateInfo[3][20];
                    splits(inputtext, DateInfo, '/');
                    if(year - strval(DateInfo[2]) > 100 || strval(DateInfo[2]) < 1 || strval(DateInfo[2]) >= year)
                    {
                        ShowPlayerDialog(playerid,dregister1,DIALOG_STYLE_INPUT,"Error","When is your Birthday? ( DD/MM/YYYY )","Enter","Cancel");
                    }
                    new check = year - strval(DateInfo[2]);
                    if(check == year)
                    {
                        ShowPlayerDialog(playerid,dregister1,DIALOG_STYLE_INPUT,"Error","When is your Birthday? ( DD/MM/YYYY )","Enter","Cancel");
                    }
                    if(strval(DateInfo[1]) > month)
                    {
                        check -= 1;
                    }
                    else if(strval(DateInfo[1]) == month && strval(DateInfo[0]) > day)
                    {
                        check -= 1;
                    }
                    PlayerInfo[playerid][pAge] = check;
                    ShowPlayerDialog(playerid, dregister2, DIALOG_STYLE_LIST, "Okay. Where are you from?","Los Santos\nSan Fierro\nLiberty City\n", "Select", "Cancel");
                    RegistrationStep[playerid] = 2;
                }
            }
        }
    }
After
pawn Код:
if(dialogid == dregister1)
{
    if(RegistrationStep[playerid] == 1)
    {
        if(response && strlen(inputtext))
        {
            new year, month, day;
            getdate(year, month, day);
            new DateInfo[3];
            sscanf(inputtext, "p</>ddd", DateInfo[0], DateInfo[1], DateInfo[2]);
            //Ultrayoung or ultraold
            new age = year - DateInfo[2];
            if(1 > age > 100)
            {
                ShowPlayerDialog(playerid,dregister1,DIALOG_STYLE_INPUT,"Error","When is your Birthday? ( DD/MM/YYYY )","Enter","Cancel");
            }
            if(DateInfo[1] > month || (DateInfo[1] == month && DateInfo[0] > day)) age -= 1;
            PlayerInfo[playerid][pAge] = age;
            ShowPlayerDialog(playerid, dregister2, DIALOG_STYLE_LIST, "Okay. Where are you from?","Los Santos\nSan Fierro\nLiberty City\n", "Select", "Cancel");
            RegistrationStep[playerid] = 2;
        }
    }
}
#e: In case this still doesn't work, debug information everywhere (will pop up in console)

pawn Код:
if(dialogid == dregister1)
{
    if(RegistrationStep[playerid] == 1)
    {
        print("Reached point 1");
        if(response && strlen(inputtext))
        {
            print("Reached point 2");
            new year, month, day;
            getdate(year, month, day);
            new DateInfo[3];
            sscanf(inputtext, "p</>ddd", DateInfo[0], DateInfo[1], DateInfo[2]);
            printf("Data: %d/%02d/%02d, from input %d/%02d/%02d", year, month, day, DateInfo[0], DateInfo[1], DateInfo[2]);
            new age = year - DateInfo[2];
            printf("Age is %d", age);
            if(1 > age > 100)
            {
                return ShowPlayerDialog(playerid,dregister1,DIALOG_STYLE_INPUT,"Error","When is your Birthday? ( DD/MM/YYYY )","Enter","Cancel");
            }
            if(DateInfo[1] > month || (DateInfo[1] == month && DateInfo[0] > day)) age -= 1;
            printf("Age is now %d", age);
            PlayerInfo[playerid][pAge] = age;
            ShowPlayerDialog(playerid, dregister2, DIALOG_STYLE_LIST, "Okay. Where are you from?","Los Santos\nSan Fierro\nLiberty City\n", "Select", "Cancel");
            print("Done");
            RegistrationStep[playerid] = 2;
        }
    }
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)