21.05.2012, 23:05
Quote:
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:
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:
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:
Example: pawn Code:
(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:
Code:
warning 203: symbol is never used: "OnQuiz" warning 203: symbol is never used: "QuizSection" 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:
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:
pawn Code:
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:
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 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;
}
Nothing happends though all remain the same as b4