How to check if the player wrote something in dialog ?
#1

Hello guys, and maybe girls

I want to check on a dialog if the player wrote something in the dialog, how i can do that ?
And if somebody can modify it to sscanf..


pawn Код:
if(dialogid == DIALOG_REGAGE)
    {
        if(response)
        {
            format(input, sizeof(input), "%d", inputtext);
            if(!IsNumeric(inputtext)) return  ShowPlayerDialog(playerid, DIALOG_REGAGE, 1, "Registration Step 2:", "How old are you ?", "Next", "");
            if(strval(inputtext) >= 7 || strval(inputtext) <= 50)
            {
                new age = strval(inputtext);
                PlayerInfo[playerid][pAge] = age;
                format(string, sizeof(string), "Ok, so you have %d years.", age);
                SendClientMessage(playerid, COLOR_YELLOW2, string);
                ShowPlayerDialog(playerid, DIALOG_REGSPAWN, 2, "Where do you want to be spawned ?", "Los Santos\nSan Fierro\nLas Venturas", "Select", "");
            }
            else
            {
                SendClientMessage(playerid, COLOR_YELLOW2, "Type numbers betwen 7 and 50.");
                ShowPlayerDialog(playerid, DIALOG_REGAGE, 1, "Registration Step 2:", "How old are you ?", "Next", "");
            }
        }
        else
        {
            ShowPlayerDialog(playerid, DIALOG_REGAGE, 1, "Registration Step 2:", "How old are you ?", "Next", "");
        }
        return 1;
    }
Reply
#2

pawn Код:
new age;
if(sscanf(inputtext, "d", age)) // checks if integer, or if any text is there.
if(age < min_age_here || age > max_age_here) // if they enter a number above / below.
//alternatively.
if(age >= min_age_here && age <= max_age_here)
{
    //if they enter it in between min age / max age
}
Reply
#3

Doesnt work good, i write insid the case my age (24) and shows again that dialog, after i press the SPACE on keyboard shows the next dialog, and ofc. with message "Ok, so you have 0 years."
pawn Код:
if(dialogid == DIALOG_REGAGE)
    {
        if(response)
        {
            new age = strval(inputtext);
            if(sscanf(inputtext, "d", age))
            {
                if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGAGE, 1, "Registration Step 2:", "How old are you ?", "Next", "");
                if(age >= 7 || age <= 50)
                {
                    PlayerInfo[playerid][pAge] = age;
                    format(string, sizeof(string), "Ok, so you have %d years.", age);
                    SendClientMessage(playerid, COLOR_YELLOW2, string);
                    ShowPlayerDialog(playerid, DIALOG_REGSPAWN, 2, "Where do you want to be spawned ?", "Los Santos\nSan Fierro\nLas Venturas", "Select", "");
                }
                else
                {
                    SendClientMessage(playerid, COLOR_YELLOW2, "Type numbers betwen 5 and 50.");
                    ShowPlayerDialog(playerid, DIALOG_REGAGE, 1, "Registration Step 2:", "How old are you ?", "Next", "");
                }
            } else ShowPlayerDialog(playerid, DIALOG_REGAGE, 1, "Registration Step 2:", "How old are you ?", "Next", "");
        } else ShowPlayerDialog(playerid, DIALOG_REGAGE, 1, "Registration Step 2:", "How old are you ?", "Next", "");
        return 1;
    }
Reply
#4

bump
Reply
#5

Код:
if(!strval(inputtext)) return SendClientMessage(playerid,-1,"Please write your age"");
Reply
#6

Invert the sscanf-statement (just add a ! in front). Sscanf returns 0 on match just like strcmp.

I also want to point out that this:
Quote:
PHP код:
if(age >= || age <= 50
Does nothing. Because numbers greater than 7 are 7 -> inifnity and numbers smaller than 50 are -infinity -> 50. And only one of the conditions needs to be fulfilled. You're using an OR where you should be using an AND.

Also in Germanic languages (like English) you don't "have" years. You "are" years.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)