SA-MP Forums Archive
Random Questions with Answers - 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)
+--- Thread: Random Questions with Answers (/showthread.php?tid=593734)



Random Questions with Answers - Hayden_Almeida - 08.11.2015

Hello Guys!

I am trying to create Questions and Answers with Dialogs, let me give one example:

Will open one Dialog style Input with this question:
Код:
What is your level?
The player need to write the answer:
Код:
2
The Main question is: how can i create multiple variables with the Questions and the respectively answers?
And how can i introduce this in ShowPlayerDialog?


Re: Random Questions with Answers - iGetty - 09.11.2015

pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <foreach>

#define DIALOG_LEVEL 1

new PlayerLevel[MAX_PLAYERS];

CMD:question(playerid, params[]){
    foreach(Player, i){
        ShowPlayerDialog(i, DIALOG_LEVEL, DIALOG_STYLE_INPUT, "Question", "What is your level?", "Ok", "Cancel");
    }    
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
    if(dialogid == DIALOG_LEVEL){
        if(response){
            if(strval(inputtext) == PlayerLevel[playerid]){
                //Code for correct here
            }
            else {
                //Code for incorrect here
            }
        }
        else return 1;
    }
    return 0;
}



Re: Random Questions with Answers - Hayden_Almeida - 09.11.2015

My idea is to do something like this:

Код:
new RandomQuestions [3][][] { // dont know how to use this :P
{5, "QUestion 1", "Answer 1"), // Where 5 is the DialogID, and the String is the question, and next string is the  correctly answer of the first quest.
{6, "QUestion 2", "Answer 2"),
{7, "QUestion 3", "Answer 4")
}
MIXED with the function: random.

Randomize the lines of the array:
Or use the line of DialogID 5
Or use the line of DialogID 6
Or use the line of DialogID 7


Re: Random Questions with Answers - Hayden_Almeida - 10.11.2015

upppppppppp