04.08.2014, 02:24
How I can do a test via a dialog box. random questions and answers? an example please
#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");
}
#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");
}
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;
}
#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
#define DIALOG_QUESTION1 1
#define DIALOG_QUESTION2 2
public Somewhere()
{
new id = random(15)
if(id == 0) { id = 1; }
ShowPlayerDialog(playerid, id, DIALOG_STYLE_INPUT, "Questions", "How old are you?", "Submit", "Cancel");
}
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");
}
}