TEST RANDOM DIALOG
#1

How I can do a test via a dialog box. random questions and answers? an example please
Reply
#2

pawn Код:
#define DIALOG_QUESTION1    1
#define DIALOG_QUESTION2    2
#define DIALOG_QUESTION3    3

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_QUESTION1:
        {
            if(response) // if yes
            {
           
            }
            else // if no
            {
           
            }
        }
        case DIALOG_QUESTION2:
        {
            if(response) // if yes
            {

            }
            else // if no
            {

            }
        }
        case DIALOG_QUESTION3:
        {
            if(response) // if yes
            {

            }
            else // if no
            {

            }
        }
    }
    return 1;
}

public Somewhere()
{
    ShowPlayerDialog(playerid, DIALOG_QUESTION1, DIALOG_STYLE_MSGBOX, "Questions", "Are you a human?", "Yes", "No");
}
Reply
#3

Thanks

and is the same way with the DIALOG_STYLE_INPUT?

How would such an example DIALOG?
Reply
#4

It would be a little bit different.

Example:
pawn Код:
#define DIALOG_QUESTION1    1

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_QUESTION1:
        {
            if(response) // "Submit"
            {
           
            }
            else // if "Cancel"
            {
           
            }
        }
    }
    return 1;
}

public Somewhere()
{
    ShowPlayerDialog(playerid, DIALOG_QUESTION1, DIALOG_STYLE_INPUT, "Questions", "How old are you?", "Submit", "Cancel");
}
And then to check the inputs:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_QUESTION1:
        {
            if(response) // "Submit"
            {
                if(strval(inputtext))
                {
                    new age = strval(inputtext);
                    if(age < 0 || age > 99) return ShowPlayerDialog(playerid, DIALOG_QUESTION1, DIALOG_TYLE_INPUT, "Questions", "Your age must go above 0 and below 99.");
                   
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_QUESTION1, DIAOG_STYLE_INPUT, "Questions", "Please enter an age.", "Submit", "Cancel");
                }
            }
            else // if "Cancel"
            {
           
            }
        }
    }
    return 1;
}
Reply
#5

Thanks, the problem is that I have 15 questions.

any way to not use so many?

pawn Код:
#define questions. 1
#define questions. 2
#define questions. 3
#define questions. 4
#define questions. 5
#define questions. 6
#define questions. 7
#define questions. 8
#define questions. 9
#define questions. 10
#define questions. 11
#define questions. 12
#define questions. 13
#define questions. 14
#define questions. 15
something else

And I do not think that's random with INPUT, I want to do a random test
Reply
#6

If you use a define to define the dialog, it just means you don't have to remember the dialogid in future. So if you have:
pawn Код:
#define DIALOG_QUESTION1 1
#define DIALOG_QUESTION2 2
It means that you can always use "DIALOG_QUESTION1" when referring to dialogid 1, it's helpful when you have hundreds of dialogs. Just imagine if you had 50 dialogs before the questions, and then you had question1 which was dialogid 62, you would just need to remember "question1" instead of 62.
Reply
#7

Thank you. I understand.

but I want to make the random test. and do not understand how random
Reply
#8

pawn Код:
public Somewhere()
{
    new id = random(15)
    if(id == 0) { id = 1; }
    ShowPlayerDialog(playerid, id, DIALOG_STYLE_INPUT, "Questions", "How old are you?", "Submit", "Cancel");
}
Reply
#9

Thanks again friend, last thing I ask and I hope you do not bother.

I want to make questions and answers. example

Question: what is my favorite color?

response options: red and white.

Correct answer: red.
Incorrect answer: white. kick ():

Do you understand?.

but it is with "DIALOG_STYLE_INPUT"
Reply
#10

Example:
pawn Код:
case DIALOG_QUESTION2: //or whatever it is..
        {
            if(response)
            {
                if(!strlen(inputtext))
                {
                    ShowPlayerDialog(playerid, DIALOG_QUESTION2, DIALOG_STYLE_INPUT, "What is my favorite color?", "Please enter Red or White", "Submit", "Cancel");
                    return 1;
                }
                if(strcmp(inputtext, "Red", true) == 0)
                {
                    //correct answer..
                    return 1;
                }
                else if(strcmp(inputtext, "White", true) == 0)
                {
                    SendClientMessage(playerid, -1, "Wrong Answer!");
                    Kick(playerid);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_QUESTION2, DIALOG_STYLE_INPUT, "What is my favorite color?", "Please enter Red or White.", "Submit", "Cancel");
                    return 1;
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOG_QUESTION2, DIALOG_STYLE_INPUT, "What is my favorite color?", "Red or White?", "Submit", "Cancel");
            }
        }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)