SA-MP Forums Archive
[Tutorial] How to create a Roleplay Quiz system with OnPlayerText. - 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)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How to create a Roleplay Quiz system with OnPlayerText. (/showthread.php?tid=344281)



How to create a Roleplay Quiz system with OnPlayerText. - iGetty - 20.05.2012

Hello and welcome to my tutorial.

I am here to explain and give a tutorial about "Quiz Systems".

What I will be showing you today:
Note: This will be for use in a Filterscript, you must edit it to work in your own system.

I will be making clear comments about what I am doing, so if you struggle you should be able to read them and then you should be good to continue. Although, if you have any problems, please don't hesitate to post on here!

Let's get started!

At the top of the script, make sure that you have got this included:
pawn Code:
#include <a_samp>
This here, will allow you the usage of the "Pawn" scripting for SA-MP. Without this, you will struggle to script anything.

Now that we have got that part done, we need to define a colour into the script!

We are going to be defining the colour, "White".

To do this, underneath where you have done the "#include" section, add the following piece of script:

pawn Code:
#define WHITE 0xFFFFFFFF
This is defining the colour, so that when we use it in a SendClientMessage; it will work.

Example:
pawn Code:
SendClientMessage(playerid, WHITE, "This will show the colour in WHITE.");
Second section:
(Player variables)

To do this, all we need to do is add "new WhatOurVariableIs[MAX_PLAYERS];", that would define it for the player's that are in the game.

So, to add ours we will need to add this to the top of the script:
pawn Code:
new OnQuiz[MAX_PLAYERS], QuizSection[MAX_PLAYERS];
If you try to compile when you have just added these; you are going to get 2 warnings. Not errors, but warnings because none of the "new's" have been used as of yet. Here is what the warning will look like:
Code:
warning 203: symbol is never used: "OnQuiz"
warning 203: symbol is never used: "QuizSection"
Don't worry about these warnings though, because they will all be removed by you in time, along more of the script.

Under "OnPlayerConnect(playerid)", you will want to notify the script to clear all player variables, so then the player doesn't have any items such as a fishing rod or bait. More is explained below.

pawn Code:
public OnPlayerConnect(playerid)
{
    //You will want to add the following:
    QuizSection[playerid] = -1;
    OnQuiz[playerid] = -1;
    TogglePlayerControllable(playerid, 0); //This sets the player to none controllable.
    SendClientMessage(playerid, WHITE, "What does SA-MP mean?");
    SendClientMessage(playerid, WHITE, "A. San Andreas Multi Player");
    SendClientMessage(playerid, WHITE, "B. Slick Assed Moron Player");
    SendClientMessage(playerid, WHITE, "C. Sausages And Mash Peas");//This sends the first quiz message
    return 1;
}
The reason for this is, to reset all player variables that we have just added.

Having: "OnQuiz[playerid] = 0;" will make it so the script can see that the player isn't on the quiz yet.
Having: "QuizSection[playerid] = 0;" will make it so the script can see that the player isn't on any section of the quiz.

Also, now if you tried to compile. You should have noticed that the warning codes have gone. This is because you have now used the variables in the script, so they aren't "Not being used".

The thing that I have show you above with OnPlayerConnect(playerid), you need to do the same for OnPlayerDisconnect(playerid, reason).

pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    //You will want to add the following:
    OnQuiz[playerid] = 0;
    QuizSection[playerid] = 0;
    return 1;
}
Now, on OnPlayerRequestClass(playerid, classid)

pawn Code:
public OnPlayerRequestClass(playerid, classid)
{
    TogglePlayerSpectating(playerid, true); //This sets the player spectating, so he doesn't see the spawn button.
    SetPlayerPos(playerid, 1544.7887,-1675.4630,13.5591); //This sets the player pos
    SetPlayerCameraPos(playerid, 1541.5293,-1675.4012,13.5527); //This sets the camera pos
    SetPlayerCameraLookAt(playerid, 1544.7887,-1675.4630,13.5591); //This sets the cameras looking at pos
    return 1;
}
That will ensure the script that when a player disconnects, it will remove all of the variables that have been stored in the script, whilst the player has been connected.

Now that we have the defines, includes and player variables out of the way, we can crack on with the rest of the script!

Third section:
(Script functions)

This section of the tutorial, will show you the basics of OnPlayerText, also how to create the actual Quiz.

pawn Code:
public OnPlayerText(playerid, text[])
{
    if(OnQuiz[playerid] == 1) //This is checking if the player is on the quiz.
    {
        if(QuizSection[playerid] == 1) //This is checking if the player is on part 1.
        {
            if(!strcmp(text, "a", true)) //This is checking if the player typed A.
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Correct! Next:");
                QuizSection[playerid] = 2; //This is setting the player to be on part 2.
                SendClientMessage(playerid, WHITE, "What is the creator of SA-MP's name?");
                SendClientMessage(playerid, WHITE, "A. Kalcor");
                SendClientMessage(playerid, WHITE, "B. Dugi");
                SendClientMessage(playerid, WHITE, "C. JaTochNietDan");
                return 0;
            }
            else if(!strcmp(text, "b", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "c", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C else it sends this
                return 0;
            }
        }
        if(QuizSection[playerid] == 2) //This is checking if the player is on section 2.
        {
            if(!strcmp(text, "a", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Correct! Next:");
                QuizSection[playerid] = 3;
                SendClientMessage(playerid, WHITE, "What is a Bullet?");
                SendClientMessage(playerid, WHITE, "A. Car");
                SendClientMessage(playerid, WHITE, "B. Truck");
                SendClientMessage(playerid, WHITE, "C. Weapon");
                return 0;
            }
            else if(!strcmp(text, "b", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "c", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C, else sends this message.
                return 0;
            }
        }
        if(QuizSection[playerid] == 3) //This is checking if the player is on section 3.
        {
            if(!strcmp(text, "a", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Correct! You can spawn!");
                QuizSection[playerid] = 0;
                OnQuiz[playerid] = 0;
                TogglePlayerSpectating(playerid, false);//This is telling the script that the player isn't spectating anymore,
                SetSpawnInfo(playerid, 0, 1, 123.4, 123.4, 123.4, 123.54, 0, 0, 0, 0, 0, 0); //This sets the players position, team and weapons.
                SpawnPlayer(playerid); //This spawns the player
                return 0;
            }
            else if(!strcmp(text, "b", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "c", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C, else sends this message.
                return 0;
            }
        }
    }
    return 1;
}
That comes to an end of my tutorial, thank you for reading and if you have got any questions, please post them here!

I know that there is a lot of writing, but it all will help newbie's in scripting. I hope that people will learn something from this because it will make me feel better :3.

Otherwise, good luck with your scripting!

- iGetty out.


Re : How to create a Roleplay Quiz system with OnPlayerText. - McBaguette - 20.05.2012

9/10 nice works !


Re: How to create a Roleplay Quiz system with OnPlayerText. - iGetty - 20.05.2012

Thank you McBaguette. :P

(PS: Like your name xD)


Re : How to create a Roleplay Quiz system with OnPlayerText. - McBaguette - 20.05.2012

Aha me too ! i like eat that ^^


Re: How to create a Roleplay Quiz system with OnPlayerText. - nmader - 20.05.2012

Nice work iGetty!


Re: How to create a Roleplay Quiz system with OnPlayerText. - iGetty - 20.05.2012

Thanks guys!


Re: How to create a Roleplay Quiz system with OnPlayerText. - TheBetaFox - 20.05.2012

Do you really need to define WHITE? Just use -1 as your colour and it will be 100% awesome pure white.
(True story.)


Re: How to create a Roleplay Quiz system with OnPlayerText. - tyler12 - 20.05.2012

nice


Re: How to create a Roleplay Quiz system with OnPlayerText. - iGetty - 21.05.2012

Thank you guys!


Re: How to create a Roleplay Quiz system with OnPlayerText. - AdamCooper - 21.05.2012

Quote:
Originally Posted by iGetty
View Post
Hello and welcome to my tutorial.

I am here to explain and give a tutorial about "Quiz Systems".

What I will be showing you today:
  • How to add a Quiz system when somebody joins, they have to complete the quiz to play.[/*]
Note: This will be for use in a Filterscript, you must edit it to work in your own system.

I will be making clear comments about what I am doing, so if you struggle you should be able to read them and then you should be good to continue. Although, if you have any problems, please don't hesitate to post on here!

Let's get started!

At the top of the script, make sure that you have got this included:
pawn Code:
#include <a_samp>
This here, will allow you the usage of the "Pawn" scripting for SA-MP. Without this, you will struggle to script anything.

Now that we have got that part done, we need to define a colour into the script!

We are going to be defining the colour, "White".

To do this, underneath where you have done the "#include" section, add the following piece of script:

pawn Code:
#define WHITE 0xFFFFFFFF
This is defining the colour, so that when we use it in a SendClientMessage; it will work.

Example:
pawn Code:
SendClientMessage(playerid, WHITE, "This will show the colour in WHITE.");
Second section:
(Player variables)

To do this, all we need to do is add "new WhatOurVariableIs[MAX_PLAYERS];", that would define it for the player's that are in the game.

So, to add ours we will need to add this to the top of the script:
pawn Code:
new OnQuiz[MAX_PLAYERS], QuizSection[MAX_PLAYERS];
If you try to compile when you have just added these; you are going to get 2 warnings. Not errors, but warnings because none of the "new's" have been used as of yet. Here is what the warning will look like:
Code:
warning 203: symbol is never used: "OnQuiz"
warning 203: symbol is never used: "QuizSection"
Don't worry about these warnings though, because they will all be removed by you in time, along more of the script.

Under "OnPlayerConnect(playerid)", you will want to notify the script to clear all player variables, so then the player doesn't have any items such as a fishing rod or bait. More is explained below.

pawn Code:
public OnPlayerConnect(playerid)
{
    //You will want to add the following:
    QuizSection[playerid] = -1;
    OnQuiz[playerid] = -1;
    TogglePlayerControllable(playerid, 0); //This sets the player to none controllable.
    SendClientMessage(playerid, WHITE, "What does SA-MP mean?");
    SendClientMessage(playerid, WHITE, "A. San Andreas Multi Player");
    SendClientMessage(playerid, WHITE, "B. Slick Assed Moron Player");
    SendClientMessage(playerid, WHITE, "C. Sausages And Mash Peas");//This sends the first quiz message
    return 1;
}
The reason for this is, to reset all player variables that we have just added.

Having: "OnQuiz[playerid] = 0;" will make it so the script can see that the player isn't on the quiz yet.
Having: "QuizSection[playerid] = 0;" will make it so the script can see that the player isn't on any section of the quiz.

Also, now if you tried to compile. You should have noticed that the warning codes have gone. This is because you have now used the variables in the script, so they aren't "Not being used".

The thing that I have show you above with OnPlayerConnect(playerid), you need to do the same for OnPlayerDisconnect(playerid, reason).

pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    //You will want to add the following:
    OnQuiz[playerid] = 0;
    QuizSection[playerid] = 0;
    return 1;
}
Now, on OnPlayerRequestClass(playerid, classid)

pawn Code:
public OnPlayerRequestClass(playerid, classid)
{
    TogglePlayerSpectating(playerid, true); //This sets the player spectating, so he doesn't see the spawn button.
    SetPlayerPos(playerid, 1544.7887,-1675.4630,13.5591); //This sets the player pos
    SetPlayerCameraPos(playerid, 1541.5293,-1675.4012,13.5527); //This sets the camera pos
    SetPlayerCameraLookAt(playerid, 1544.7887,-1675.4630,13.5591); //This sets the cameras looking at pos
    return 1;
}
That will ensure the script that when a player disconnects, it will remove all of the variables that have been stored in the script, whilst the player has been connected.

Now that we have the defines, includes and player variables out of the way, we can crack on with the rest of the script!

Third section:
(Script functions)

This section of the tutorial, will show you the basics of OnPlayerText, also how to create the actual Quiz.

pawn Code:
public OnPlayerText(playerid, text[])
{
    if(OnQuiz[playerid] == 1) //This is checking if the player is on the quiz.
    {
        if(QuizSection[playerid] == 1) //This is checking if the player is on part 1.
        {
            if(!strcmp(text, "a", true)) //This is checking if the player typed A.
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Correct! Next:");
                QuizSection[playerid] = 2; //This is setting the player to be on part 2.
                SendClientMessage(playerid, WHITE, "What is the creator of SA-MP's name?");
                SendClientMessage(playerid, WHITE, "A. Kalcor");
                SendClientMessage(playerid, WHITE, "B. Dugi");
                SendClientMessage(playerid, WHITE, "C. JaTochNietDan");
                return 0;
            }
            else if(!strcmp(text, "b", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "c", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C else it sends this
                return 0;
            }
        }
        if(QuizSection[playerid] == 2) //This is checking if the player is on section 2.
        {
            if(!strcmp(text, "a", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Correct! Next:");
                QuizSection[playerid] = 3;
                SendClientMessage(playerid, WHITE, "What is a Bullet?");
                SendClientMessage(playerid, WHITE, "A. Car");
                SendClientMessage(playerid, WHITE, "B. Truck");
                SendClientMessage(playerid, WHITE, "C. Weapon");
                return 0;
            }
            else if(!strcmp(text, "b", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "c", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C, else sends this message.
                return 0;
            }
        }
        if(QuizSection[playerid] == 3) //This is checking if the player is on section 3.
        {
            if(!strcmp(text, "a", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Correct! You can spawn!");
                QuizSection[playerid] = 0;
                OnQuiz[playerid] = 0;
                TogglePlayerSpectating(playerid, false);//This is telling the script that the player isn't spectating anymore,
                SetSpawnInfo(playerid, 0, 1, 123.4, 123.4, 123.4, 123.54, 0, 0, 0, 0, 0, 0); //This sets the players position, team and weapons.
                SpawnPlayer(playerid); //This spawns the player
                return 0;
            }
            else if(!strcmp(text, "b", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "c", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, WHITE, " ");
                SendClientMessage(playerid, WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C, else sends this message.
                return 0;
            }
        }
    }
    return 1;
}
That comes to an end of my tutorial, thank you for reading and if you have got any questions, please post them here!

I know that there is a lot of writing, but it all will help newbie's in scripting. I hope that people will learn something from this because it will make me feel better :3.

Otherwise, good luck with your scripting!

- iGetty out.
I followed the tut and made one of my own as filterscript.
I needed to add question so I did like that :
pawn Code:
//Simple AFK System by Lakiya. Please keep this credit here.

#include <a_samp>

// COLORS DEFINITION
#define COLOR_GM_REG 0xFFFFFFAA     // WHITE (FFFFFF) normal chat to everyone (registered users)
#define COLOR_GM_UNREG 0xFF9999AA   // LIGHT RED(FF9999) normal chat to everyone (unregistered users)
#define COLOR_GM_ADMIN 0xFFCC66AA   // LIGHT ORANGE (FFCC66) normal chat to everyone (admins)
#define COLOR_IRC 0x66CCFFAA        // LIGHT BLUE (66CCFF) irc messages (/me /query (!) /slap)
#define COLOR_ADMINCHAT 0xFF9933AA  // BRIGHT ORANGE (FF9933) admin only chat (@)
#define COLOR_SYSTEM_PM 0x66CC00AA  // LIGHT GREEN (66CC00) system generated personal message (logged in, progress saved, function disabled)
#define COLOR_SYSTEM_GM 0xFF9966AA  // LIGHT ORANGE-RED (FF9966) system generated general message ("x just bought the four dragons!")
#define COLOR_SYSTEM_PW 0xFFFF33AA  // YELLOW (FFFF33) system personal warning ("you must be in a bank")
#define COLOR_SYSTEM_GW 0xCCCCCCAA  // GRAY (CCCCCC) system general warning ("x used a money cheat")
#define COLOR_MONEY_INC 0x00CC66AA  // GREEN (00CC66) money increase related system message ("you earned x money")
#define COLOR_MONEY_DEC 0xFF6600AA  // RED (FF6600) money decrease related system message ("your property has been bought out")
#define COLOR_MENU 0xFFFFFFAA       // WHITE (FFFFFF) menu's (/help)
#define COLOR_CMD 0xFFFFFFAA        // WHITE (FFFFFF)commands (Usage: ...)
#define COLOR_ADMIN_CMD 0xCC6666AA  // RED BROWN (CC6666) admin commands (Usage: ...)
#define COLOR_ADMIN_PM 0x6699CCAA   // GREEN BLUE (6699CC) admin personal message (your money has been set to X)
#define COLOR_ADMIN_PW 0x99CCFFAA   // BLUE (99CCFF) admin personal warning (x is not an active player)
#define COLOR_ADMIN_GM 0xFF6633AA   // LIGHT RED (FF6633) admin general message (was jailed by admin x)
#define COLOR_STATS 0xCCCCFFAA      // LIGHT  PURPLE (CCCCFF) stats (/stat /totalstat)
#define COLOR_MESSAGE 0xFFCCFFAA    // PURPLE (FFCCFF) Message system (anticheat, blog address)
#define COLOR_RULES 0xDC143CAA      // RED
#define COLOR_ADMIN_TOALL 0x00FFFFAA// CYAN
#define COLOR_GROUPTALK 0x87CEEBAA  // SKYBLUE
#define COLOR_ADMIN_ 0xFF69B4AA // HOTPINK
#define COLOR_ADMIN_SPYREPORT 0xB0E0E6AA //POWDERBLUE
#define COLOR_ADMIN 0xFF8200FF
#define COLOR_CARDIVE 0xEE82EEAA //VIOLET
#define COLOR_BLACK_PD 0x000000FF
#define COLOR_WHITE_PD 0xFFFFFFFF
#define COLOR_DISARMING 0xEE82EEBB
#define COLOR_WHITE 0xFFFFFF77
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_IVORY 0xFFFF82FF
#define COLOR_BLUE 0x0000FFFF
#define COLOR_PURPLE 0x800080FF
#define COLOR_RED 0xCC3300FF
#define COLOR_LIGHTRED 0xFF6347AA
#define COLOR_YELLOW2 0xF5DEB3AA

new OnQuiz[MAX_PLAYERS], QuizSection[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    //You will want to add the following:
    QuizSection[playerid] = -1;
    OnQuiz[playerid] = -1;
    TogglePlayerControllable(playerid, 0); //This sets the player to none controllable.
    SendClientMessage(playerid, COLOR_YELLOW2, " ");
    SendClientMessage(playerid, COLOR_LIGHTRED, "|____________________What does OOC and IC stand for?____________________|");
    SendClientMessage(playerid, COLOR_WHITE, "A: Out of clothes and in clothes");
    SendClientMessage(playerid, COLOR_WHITE, "B: Out of character and in character");
    SendClientMessage(playerid, COLOR_WHITE, "C: Out of cars and in cars");
    SendClientMessage(playerid, COLOR_LIGHTRED, "|___________________________________________________|");
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    //You will want to add the following:
    OnQuiz[playerid] = 0;
    QuizSection[playerid] = 0;
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    TogglePlayerSpectating(playerid, true); //This sets the player spectating, so he doesn't see the spawn button.
    SetPlayerPos(playerid, 1544.7887,-1675.4630,13.5591); //This sets the player pos
    SetPlayerCameraPos(playerid, 1541.5293,-1675.4012,13.5527); //This sets the camera pos
    SetPlayerCameraLookAt(playerid, 1544.7887,-1675.4630,13.5591); //This sets the cameras looking at pos
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(OnQuiz[playerid] == 1) //This is checking if the player is on the quiz.
    {
        if(QuizSection[playerid] == 1) //This is checking if the player is on part 1.
        {
            if(!strcmp(text, "b", true)) //This is checking if the player typed B.
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Correct! Next:");
                QuizSection[playerid] = 2; //This is setting the player to be on part 2.
                SendClientMessage(playerid, COLOR_WHITE, "Which one of these do you do not in a Role Play server??");
                SendClientMessage(playerid, COLOR_WHITE, "A. Role play with members");
                SendClientMessage(playerid, COLOR_WHITE, "B. Not mixing OOC with IC");
                SendClientMessage(playerid, COLOR_WHITE, "C. Death matching");
                return 0;
            }
            else if(!strcmp(text, "b", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "a", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C else it sends this
                return 0;
            }
        }
        if(QuizSection[playerid] == 2) //This is checking if the player is on section 2.
        {
            if(!strcmp(text, "c", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Correct! Next:");
                QuizSection[playerid] = 3;
                SendClientMessage(playerid, COLOR_WHITE, "What is PG?");
                SendClientMessage(playerid, COLOR_WHITE, "A. Point Goal");
                SendClientMessage(playerid, COLOR_WHITE, "B. Power Gaming");
                SendClientMessage(playerid, COLOR_WHITE, "C. Price Getting");
                return 0;
            }
            else if(!strcmp(text, "a", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "c", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C, else sends this message.
                return 0;
            }
        }
        if(QuizSection[playerid] == 3) //This is checking if the player is on section 3.
        {
            if(!strcmp(text, "b", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Correct! Next!");
                QuizSection[playerid] = 4;
                SendClientMessage(playerid, COLOR_WHITE, "Which one of these do you use to report only hackers or supicious players?");
                SendClientMessage(playerid, COLOR_WHITE, "A. /repot");
                SendClientMessage(playerid, COLOR_WHITE, "B. /ask");
                SendClientMessage(playerid, COLOR_WHITE, "C. /pm");
                return 0;
            }
            else if(!strcmp(text, "b", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "c", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C, else sends this message.
                return 0;
            }
        }
        if(QuizSection[playerid] == 4) //This is checking if the player is on section 3.
        {
            if(!strcmp(text, "a", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Correct! Next!");
                QuizSection[playerid] = 5;
                SendClientMessage(playerid, COLOR_WHITE, "Which of the following is a proper usage of /me?");
                SendClientMessage(playerid, COLOR_WHITE, "A. /me summons the demons of the underground to kill you");
                SendClientMessage(playerid, COLOR_WHITE, "B. /me picks up the cruiser with his super strength");
                SendClientMessage(playerid, COLOR_WHITE, "C. /me reaches his hand to the belt of his waist, slowly pulls out his gun");
                return 0;
            }
            else if(!strcmp(text, "b", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "a", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C, else sends this message.
                return 0;
            }
        }
        if(QuizSection[playerid] == 5) //This is checking if the player is on section 3.
        {
            if(!strcmp(text, "c", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Correct! Next!");
                QuizSection[playerid] = 6;
                SendClientMessage(playerid, COLOR_WHITE, "What is MG?");
                SendClientMessage(playerid, COLOR_WHITE, "A. Monster Gaming");
                SendClientMessage(playerid, COLOR_WHITE, "B. Metagaming");
                SendClientMessage(playerid, COLOR_WHITE, "C. Make Girls");
                return 0;
            }
            else if(!strcmp(text, "c", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "a", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C, else sends this message.
                return 0;
            }
        }
        if(QuizSection[playerid] == 6) //This is checking if the player is on section 3.
        {
            if(!strcmp(text, "b", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Correct! Next!");
                QuizSection[playerid] = 7;
                SendClientMessage(playerid, COLOR_WHITE, "Which is the proper way to apply for factions?");
                SendClientMessage(playerid, COLOR_WHITE, "A. Apply for it on forums/Roleplay untill get hand picked by admin");
                SendClientMessage(playerid, COLOR_WHITE, "B. Using /ask and requesting");
                SendClientMessage(playerid, COLOR_WHITE, "C. PM the admins and ask for a faction");
                return 0;
            }
            else if(!strcmp(text, "c", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "b", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C, else sends this message.
                return 0;
            }
        }
        if(QuizSection[playerid] == 7) //This is checking if the player is on section 3.
        {
            if(!strcmp(text, "a", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Correct! Next!");
                QuizSection[playerid] = 8;
                SendClientMessage(playerid, COLOR_WHITE, "When are you allowed to go AFK?");
                SendClientMessage(playerid, COLOR_WHITE, "A. During Roleplay");
                SendClientMessage(playerid, COLOR_WHITE, "B. When admin is talking to you");
                SendClientMessage(playerid, COLOR_WHITE, "C. None of the above");
                return 0;
            }
            else if(!strcmp(text, "a", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "c", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C, else sends this message.
                return 0;
            }
        }
        if(QuizSection[playerid] == 8) //This is checking if the player is on section 3.
        {
            if(!strcmp(text, "B", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Correct! Next!");
                QuizSection[playerid] = 9;
                SendClientMessage(playerid, COLOR_WHITE, "When a noob comes up to you and starts DMing you what do you do?");
                SendClientMessage(playerid, COLOR_WHITE, "A. Kill the annyoing cunt");
                SendClientMessage(playerid, COLOR_WHITE, "B. Spamming the admins with /pm");
                SendClientMessage(playerid, COLOR_WHITE, "C. Use /report");
                return 0;
            }
            else if(!strcmp(text, "a", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "b", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C, else sends this message.
                return 0;
            }
        }
        if(QuizSection[playerid] == 9) //This is checking if the player is on section 3.
        {
            if(!strcmp(text, "c", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Correct! Next!");
                QuizSection[playerid] = 10;
                SendClientMessage(playerid, COLOR_WHITE, "When you crash your car during a role play what do you do?");
                SendClientMessage(playerid, COLOR_WHITE, "A. Continue driving");
                SendClientMessage(playerid, COLOR_WHITE, "B. Role play the accident and act hurt");
                SendClientMessage(playerid, COLOR_WHITE, "C. Driving to the neares PaynSpray");
                return 0;
            }
            else if(!strcmp(text, "a", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "c", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C, else sends this message.
                return 0;
            }
        }
             
        if(QuizSection[playerid] == 10) //This is checking if the player is on section 3.
        {
            if(!strcmp(text, "b", true)) //This is checking the player typed A
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Correct! Next!");
                QuizSection[playerid] = 0;
                OnQuiz[playerid] = 0;
                TogglePlayerSpectating(playerid, false);//This is telling the script that the player isn't spectating anymore,
                SetSpawnInfo(playerid, 0, 1, 1676.3783,1447.7172,10.78, 0, 0, 0, 0, 0, 0); //This sets the players position, team and weapons.
                SpawnPlayer(playerid); //This spawns the player
                return 0;
            }
            else if(!strcmp(text, "b", true)) //This is checking the player typed B
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else if(!strcmp(text, "c", true)) //This is checking the player typed C
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Wrong! You were kicked because you got it wrong.");
                Kick(playerid);
                return 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, " ");
                SendClientMessage(playerid, COLOR_WHITE, "Error: You can only use A, B or C."); //This is checking the player typed A B or C, else sends this message.
                return 0;
            }
        }
    }
    return 1;
}
I've located it inside filterscripts and added the name of the FS in server.cfg
Nothing happends though all remain the same as b4


Re: How to create a Roleplay Quiz system with OnPlayerText. - iGetty - 22.05.2012

pawn Code:
public OnPlayerConnect(playerid)
{
    //You will want to add the following:
    QuizSection[playerid] = -1;
    OnQuiz[playerid] = -1;
    TogglePlayerControllable(playerid, 0); //This sets the player to none controllable.
    SendClientMessage(playerid, COLOR_YELLOW2, " ");
    SendClientMessage(playerid, COLOR_LIGHTRED, "|____________________What does OOC and IC stand for?____________________|");
    SendClientMessage(playerid, COLOR_WHITE, "A: Out of clothes and in clothes");
    SendClientMessage(playerid, COLOR_WHITE, "B: Out of character and in character");
    SendClientMessage(playerid, COLOR_WHITE, "C: Out of cars and in cars");
    SendClientMessage(playerid, COLOR_LIGHTRED, "|___________________________________________________|");
    return 1;
}
You've put the variables to -1;

They should be like this:

pawn Code:
public OnPlayerConnect(playerid)
{
    //You will want to add the following:
    QuizSection[playerid] = 1;
    OnQuiz[playerid] = 1;
    TogglePlayerControllable(playerid, 0); //This sets the player to none controllable.
    SendClientMessage(playerid, COLOR_YELLOW2, " ");
    SendClientMessage(playerid, COLOR_LIGHTRED, "|____________________What does OOC and IC stand for?____________________|");
    SendClientMessage(playerid, COLOR_WHITE, "A: Out of clothes and in clothes");
    SendClientMessage(playerid, COLOR_WHITE, "B: Out of character and in character");
    SendClientMessage(playerid, COLOR_WHITE, "C: Out of cars and in cars");
    SendClientMessage(playerid, COLOR_LIGHTRED, "|___________________________________________________|");
    return 1;
}



Re: How to create a Roleplay Quiz system with OnPlayerText. - jstowe96 - 26.07.2013

What if i wanted to have a registration come first an then you would be forced to take the quiz. After that you would be required to see a server tutorial. How would that all be sequenced exactly without te quiz coming before the register or the tutorial before the quiz?