SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/11/2019, 10:34 AM   #1
Ponga
Big Clucker
 
Ponga's Avatar
 
Join Date: Oct 2017
Posts: 77
Reputation: 9
Default [QUIZ ROLEPLAY]

How do i make quiz roleplay like this : https://www.*******.com/watch?v=bdFy...mc9wcyEh5sI_hI
__________________
Ponga is offline   Reply With Quote
Old 14/11/2019, 05:46 PM   #2
TheLeech
Big Clucker
 
Join Date: Aug 2015
Location: Under your bed
Posts: 154
Reputation: 6
Default Re: [QUIZ ROLEPLAY]

Note this is just example code, it may not work on your server learn from it only.

Code:
#define MAX_APPLICATIONS 150 // Max applications that can be stored at once.
enum AppData
{
    ID,
    Name[MAX_PLAYER_NAME + 1],
    AcceptBy[MAX_PLAYER_NAME + 1],
    Question1[250],
    Question2[250],
    Question3[250],
    Question4[250],
    Question5[250],
    Question6[250],
    AppPassed,
    SentIn,
    PlayerID
}
new ApplicationInfo[MAX_APPLICATIONS][AppData];
new PlayerSelect[MAX_PLAYERS][950];
new ReviewingApplicationID[MAX_PLAYERS];
Dialogs - Note I use easy dialogs.
Code:
Dialog:TestQuestions(playerid, response, listitem, inputtext[])
{
    if(!response) {
        new String[150];

		//SetPVarInt(playerid, "Questions", 2);

		format(String, sizeof(String), "{FFFFFF}What does OOC and IC stand for?\n\
		{0099FF}Please, input an answer below.\n\n");
		Dialog_Show(playerid, TestQuestions, DIALOG_STYLE_INPUT, "Question 1 of 6", String, "Next", "Leave");
	}

	if(strlen(inputtext) <= 5 || strlen(inputtext) > 256)
	{
 		if(GetPVarInt(playerid, "Questions") == 1)
		{
 			SendClientMessage(playerid, 0x969696FF, "Invalid answer length, should be 5 - 256.");

			new String[150];

			//SetPVarInt(playerid, "Questions", 2);

			format(String, sizeof(String), "{FFFFFF}What does OOC and IC stand for?\n\
			{0099FF}Please, input an answer below.\n\n");
			Dialog_Show(playerid, TestQuestions, DIALOG_STYLE_INPUT, "Question 1 of 6", String, "Next", "Leave");
		}
		if(GetPVarInt(playerid, "Questions") == 2)
		{
 			SendClientMessage(playerid, 0x969696FF, "Invalid answer length, should be 5 - 256.");

			new String[150];

			//SetPVarInt(playerid, "Questions", 3);

			format(String, sizeof(String), "{FFFFFF}What is Revenge killing?\n\
			{0099FF}Please, input an answer below.\n\n");
			Dialog_Show(playerid, TestQuestions, DIALOG_STYLE_INPUT, "Question 2 of 6", String, "Next", "Leave");
		}
		if(GetPVarInt(playerid, "Questions") == 3)
		{
 			SendClientMessage(playerid, 0x969696FF, "Invalid answer length, should be 5 - 256.");

			new String[150];

			//SetPVarInt(playerid, "Questions", 4);

			format(String, sizeof(String), "{FFFFFF}Give  us an example of a /me command.\n\
			{0099FF}Please, input an answer below.\n\n");
			Dialog_Show(playerid, TestQuestions, DIALOG_STYLE_INPUT, "Question 3 of 6", String, "Next", "Leave");
		}
		if(GetPVarInt(playerid, "Questions") == 4)
		{
 			SendClientMessage(playerid, 0x969696FF, "Invalid answer length, should be 5 - 256.");

			new String[150];

			//SetPVarInt(playerid, "Questions", 5);

			format(String, sizeof(String), "{FFFFFF}Give us an example of a /do command.\n\
			{0099FF}Please, input an answer below.\n\n");
			Dialog_Show(playerid, TestQuestions, DIALOG_STYLE_INPUT, "Question 4 of 6", String, "Next", "Leave");
		}
		if(GetPVarInt(playerid, "Questions") == 5)
		{
 			SendClientMessage(playerid, 0x969696FF, "Invalid answer length, should be 5 - 256.");

			new String[150];

			//SetPVarInt(playerid, "Questions", 6);

			format(String, sizeof(String), "{FFFFFF}What do you do when you spot a hacker?\n\
			{0099FF}Please, input an answer below.\n\n");
			Dialog_Show(playerid, TestQuestions, DIALOG_STYLE_INPUT, "Question 5 of 6", String, "Next", "Leave");
		}
		if(GetPVarInt(playerid, "Questions") == 6)
		{
 			SendClientMessage(playerid, 0x969696FF, "Invalid answer length, should be 5 - 256.");

			new String[256];

			//SetPVarInt(playerid, "Questions", 6);

			format(String, sizeof(String), "{FFFFFF}What is pg powergaming?\n\
			{0099FF}Please, input an answer below.\n\n");
			Dialog_Show(playerid, TestQuestions, DIALOG_STYLE_INPUT, "Question 6 of 6", String, "Next", "Leave");
		}
	}
	else
	{
		if(GetPVarInt(playerid, "Questions") == 1)
		{
			new String[150];

			PlayerData[playerid][AppID] = GetApplications();

			ApplicationInfo[PlayerData[playerid][AppID]][ID] = PlayerData[playerid][AppID];

			ApplicationInfo[PlayerData[playerid][AppID]][PlayerID] = playerid;

			SetPVarInt(playerid, "Questions", 2);

			format(ApplicationInfo[PlayerData[playerid][AppID]][Question1], 256, inputtext);
   			format(ApplicationInfo[PlayerData[playerid][AppID]][Name], MAX_PLAYER_NAME + 1, PlayerData[playerid][pUsername]);

			new querylist[256];
   			mysql_format(g_iHandle, querylist, sizeof(querylist), "INSERT INTO `applications` (`ID`, `Name`, `Question1`, `Accepted`)\
			VALUES ('%d', '%e', '%e', 0)", PlayerData[playerid][AppID], PlayerData[playerid][pUsername], inputtext);
			mysql_query(g_iHandle, querylist);


			format(String, sizeof(String), "{FFFFFF}What is Revenge killing?\n\
			{0099FF}Please, input an answer below.\n\n");
			Dialog_Show(playerid, TestQuestions, DIALOG_STYLE_INPUT, "Question 2 of 6", String, "Next", "Leave");
			return 1;
		}
		if(GetPVarInt(playerid, "Questions") == 2)
		{
			new String[150];

			SetPVarInt(playerid, "Questions", 3);

			format(ApplicationInfo[PlayerData[playerid][AppID]][Question2], 256, inputtext);

			new querylist[256];
   			mysql_format(g_iHandle, querylist, sizeof(querylist), "UPDATE `applications` SET `Question2` = '%e' WHERE `Name` = '%e'" , inputtext, PlayerData[playerid][pUsername]);
			mysql_query(g_iHandle, querylist);

			format(String, sizeof(String), "{FFFFFF}Give  us an example of a /me command.\n\
			{0099FF}Please, input an answer below.\n\n");
			Dialog_Show(playerid, TestQuestions, DIALOG_STYLE_INPUT, "Question 3 of 6", String, "Next", "Leave");
			return 1;
		}
		if(GetPVarInt(playerid, "Questions") == 3)
		{
			new String[150];

			SetPVarInt(playerid, "Questions", 4);

			format(ApplicationInfo[PlayerData[playerid][AppID]][Question3], 256, inputtext);

			new querylist[256];
   			mysql_format(g_iHandle, querylist, sizeof(querylist), "UPDATE `applications` SET `Question3` = '%e' WHERE `Name` = '%e'" , inputtext, PlayerData[playerid][pUsername]);
			mysql_query(g_iHandle, querylist);

			format(String, sizeof(String), "{FFFFFF}Give us an example of a /do command.\n\
			{0099FF}Please, input an answer below.\n\n");
			Dialog_Show(playerid, TestQuestions, DIALOG_STYLE_INPUT, "Question 4 of 6", String, "Next", "Leave");
			return 1;
		}
		if(GetPVarInt(playerid, "Questions") == 4)
		{
			new String[150];

			SetPVarInt(playerid, "Questions", 5);

			format(ApplicationInfo[PlayerData[playerid][AppID]][Question4], 256, inputtext);

			new querylist[256];
   			mysql_format(g_iHandle, querylist, sizeof(querylist), "UPDATE `applications` SET `Question4` = '%e' WHERE `Name` = '%e'" , inputtext, PlayerData[playerid][pUsername]);
			mysql_query(g_iHandle, querylist);

			format(String, sizeof(String), "{FFFFFF}What do you do when you spot a hacker?\n\
			{0099FF}Please, input an answer below.\n\n");
			Dialog_Show(playerid, TestQuestions, DIALOG_STYLE_INPUT, "Question 5 of 6", String, "Next", "Leave");
			return 1;
		}
		if(GetPVarInt(playerid, "Questions") == 5)
		{
			new String[150];

			SetPVarInt(playerid, "Questions", 6);

			format(ApplicationInfo[PlayerData[playerid][AppID]][Question5], 256, inputtext);

			new querylist[556];
			mysql_format(g_iHandle, querylist, sizeof(querylist), "UPDATE `applications` SET `Question5` = '%e' WHERE `Name` = '%e'" , inputtext, PlayerData[playerid][pUsername]);
			mysql_query(g_iHandle, querylist);

			format(String, sizeof(String), "{FFFFFF}What is pg or powergaming?\n\
			{0099FF}Please, input an answer below.\n\n");
			Dialog_Show(playerid, TestQuestions, DIALOG_STYLE_INPUT, "Question 6 of 6", String, "Next", "Leave");
			return 1;
		}
		if(GetPVarInt(playerid, "Questions") == 6)
		{
  			new str[128];
   			new pName[24];

			GetPlayerName(playerid, pName, 24);
			GiveNameSpace(pName);

			SendClientMessage(playerid, COLOR_ORANGE, "Server: Thank you for taking the quiz, A member of staff will review it shortly.");
 			SetPVarInt(playerid, "AppMade", 1);
  			SetPVarInt(playerid, "AppPassed", 0);

			format(str, sizeof(str), "Server: New application to be reviewed posted by %s (%d) (/applications).", pName, playerid);
			SendAdminMessage(COLOR_ORANGE, str);

			format(ApplicationInfo[PlayerData[playerid][AppID]][Question6], 256, inputtext);

			ApplicationInfo[PlayerData[playerid][AppID]][SentIn] = 1;

			new querylist[256];
   			mysql_format(g_iHandle, querylist, sizeof(querylist), "UPDATE `applications` SET `Question6` = '%e', `SentIn` = 1 WHERE `Name` = '%e'" , inputtext, PlayerData[playerid][pUsername]);
			mysql_query(g_iHandle, querylist);
			
			mysql_format(g_iHandle, querylist, sizeof(querylist), "UPDATE `accounts` SET `AppMade` = 1, `AppID` = %d, `AppPassed` = 0 WHERE `Username` = '%s'" , PlayerData[playerid][AppID], PlayerData[playerid][pUsername]);
			mysql_query(g_iHandle, querylist);
			return 1;
		}
	}
	return 1;
}

Dialog:ApplicationPick(playerid, response, listitem, inputtext[])
{
    if(!response)
	{
		SendClientMessage(playerid, COLOR_ORANGE, "Server: You have closed the application viewer, you shouldn't keep players waiting.");
		return 1;
	}
	new str[956];
	ReviewingApplicationID[playerid] = PlayerSelect[playerid][listitem];
	new id = ApplicationInfo[ReviewingApplicationID[playerid]][PlayerID];
	format(str, sizeof(str), "Server: %s has started to review %s application.", PlayerData[playerid][pUsername], ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
	SendAdminMessage(COLOR_ORANGE, str);
	format(str, sizeof(str), "{0099FF}Application by %s\n\nQuestion 1:{FFFFFF}What does OOC and IC stand for?\n\
	{0099FF}Answer: %s\nQuestion 2:{FFFFFF}What is Revenge killing?\n{0099FF}Answer: %s", ApplicationInfo[ReviewingApplicationID[playerid]][Name], ApplicationInfo[ReviewingApplicationID[playerid]][Question1], ApplicationInfo[ReviewingApplicationID[playerid]][Question2]);
	Dialog_Show(playerid, ApplicationReview, DIALOG_STYLE_MSGBOX, "Reviewing application", str, "Next", "Cancel");
	SetPVarInt(playerid, "Questions", 1);
	if(ApplicationInfo[ReviewingApplicationID[playerid]][PlayerID] >= 0) {
		format(str, sizeof(str), "Server: %s has started to review your application.", PlayerData[playerid][pUsername]);
		SendClientMessage(id, COLOR_ORANGE, str);
	}
	return 1;
}

Dialog:ApplicationReview(playerid, response, listitem, inputtext[])
{
	if(!response)
	{
	    if(GetPVarInt(playerid, "Questions") < 3)
		{
			SendClientMessage(playerid, COLOR_ORANGE, "Server: You have closed the application viewer, you shouldn't keep players waiting.");
			return 1;
		}
		else {
		    new id = ApplicationInfo[ReviewingApplicationID[playerid]][PlayerID];
        	if(ApplicationInfo[ReviewingApplicationID[playerid]][PlayerID] >= 0) {
        	    new query[128];
		    	mysql_format(g_iHandle, query, sizeof(query), "DELETE FROM `applications` WHERE `Name`= '%e'", ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
				mysql_pquery(g_iHandle, query);
				ApplicationInfo[ReviewingApplicationID[playerid]][ID] = 0;
				ApplicationInfo[ReviewingApplicationID[playerid]][SentIn] = 0;
				new str[256];
                format(str, sizeof(str), "Server: %s has denied your application, Please re-submit with better answers.", PlayerData[playerid][pUsername]);
				SendClientMessage(id, COLOR_RED, str);
				SetPVarInt(playerid, "Questions", 0);
				SetPVarInt(id, "Questions", 1);
				SetPVarInt(id, "AppMade", 0);
				AdminsOnline(id);
        	}
        	else {
        	    new query[128];
		    	mysql_format(g_iHandle, query, sizeof(query), "DELETE FROM `applications` WHERE `Name`= '%e'", ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
				mysql_pquery(g_iHandle, query);
				ApplicationInfo[ReviewingApplicationID[playerid]][ID] = 0;
				ApplicationInfo[ReviewingApplicationID[playerid]][SentIn] = 0;
        	}
		}
	}
	if(GetPVarInt(playerid, "Questions") == 1)
	{
		new str[956];
		format(str, sizeof(str), "{0099FF}Application by %s\n\nQuestion 3:{FFFFFF}Give us an example of a /me command\n\
		{0099FF}Answer: %s\nQuestion 4:{FFFFFF}Give us an example of a /do command\n{0099FF}Answer: %s", ApplicationInfo[ReviewingApplicationID[playerid]][Name], ApplicationInfo[ReviewingApplicationID[playerid]][Question3], ApplicationInfo[ReviewingApplicationID[playerid]][Question4]);
		Dialog_Show(playerid, ApplicationReview, DIALOG_STYLE_MSGBOX, "Reviewing application", str, "Next", "Cancel");
		SetPVarInt(playerid, "Questions", 2);
		return 1;
	}
	if(GetPVarInt(playerid, "Questions") == 2)
	{
		new str[956];
		format(str, sizeof(str), "{0099FF}Application by %s\n\nQuestion 5:{FFFFFF}What do you do when you spot a hacker?\n\
		{0099FF}Answer: %s\nQuestion 6:{FFFFFF}What is pg or powergaming?\n{0099FF}Answer: %s", ApplicationInfo[ReviewingApplicationID[playerid]][Name], ApplicationInfo[ReviewingApplicationID[playerid]][Question5], ApplicationInfo[ReviewingApplicationID[playerid]][Question6]);
		Dialog_Show(playerid, ApplicationReview, DIALOG_STYLE_MSGBOX, "Reviewing application", str, "Accept", "Deny");
		SetPVarInt(playerid, "Questions", 3);
		return 1;
	}
	if(GetPVarInt(playerid, "Questions") == 3)
	{
	    new id = ApplicationInfo[ReviewingApplicationID[playerid]][PlayerID];
        if(ApplicationInfo[ReviewingApplicationID[playerid]][PlayerID] >= 0) {
            new str[256];
            format(str, sizeof(str), "Server: %s has accepted your application.", PlayerData[playerid][pUsername]);
			SendClientMessage(id, COLOR_ORANGE, str);
			SetPVarInt(id, "PassedRPTest", 1);
			new query[128];
	    	mysql_format(g_iHandle, query, sizeof(query), "DELETE FROM `applications` WHERE `Name`= '%e'", ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
			mysql_pquery(g_iHandle, query);
			mysql_format(g_iHandle, query, sizeof(query), "UPDATE `accounts` SET `AppPassed` = 1 WHERE `Username` = '%s'" , ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
		    mysql_query(g_iHandle, query);
			ApplicationInfo[ReviewingApplicationID[playerid]][ID] = 0;
			ApplicationInfo[ReviewingApplicationID[playerid]][SentIn] = 0;
			SetPVarInt(playerid, "Questions", 0);
			format(query, sizeof(query), "SELECT * FROM `characters` WHERE `Username` = '%s' LIMIT 3", PlayerData[ApplicationInfo[ReviewingApplicationID[playerid]][PlayerID]][pUsername]);
			mysql_tquery(g_iHandle, query, "OnQueryFinished", "dd", ApplicationInfo[ReviewingApplicationID[playerid]][PlayerID], THREAD_CHARACTERS);
			return 1;
        }
        else {
            new query[128];
	    	mysql_format(g_iHandle, query, sizeof(query), "DELETE FROM `applications` WHERE `Name`= '%e'", ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
			mysql_pquery(g_iHandle, query);
			ApplicationInfo[ReviewingApplicationID[playerid]][ID] = 0;
			ApplicationInfo[ReviewingApplicationID[playerid]][SentIn] = 0;
			new str[256];
            format(str, sizeof(str), "Server: %s is offline, When they come back on they will have passed.", ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
			SendClientMessage(playerid, COLOR_ORANGE, str);
		    mysql_format(g_iHandle, query, sizeof(query), "UPDATE `accounts` SET `AppPassed` = 1 WHERE `Username` = '%s'" , ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
		    mysql_query(g_iHandle, query);
		    SetPVarInt(playerid, "Questions", 0);
		    return 1;
        }
	}
	return 1;
}
Command to read
Code:
COMMAND:applications(playerid, params[])
{
    if (PlayerData[playerid][LoggedIn] == false) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this.");
	if(PlayerData[playerid][pAdmin] >= 1 || IsPlayerAdmin(playerid))
	{
		GetPlayerApplicationToView(playerid);
		return 1;
	}
	else return SendClientMessage(playerid, COLOR_RED, "Server: You do not have permission to use this command.");
}
Stocks / functions

Code:
stock GetApplications()
{
	for(new i = 0; i < MAX_APPLICATIONS;i++)
	{
		if(ApplicationInfo[i][ID] == 0 && ApplicationInfo[i][SentIn] == 0)
		{
		    return i;
		}
	}
 	return -1;
}

stock GetPlayerApplicationToView(playerid)
{
    new sendername[24];
    GetPlayerName(playerid, sendername, 24);
	new string[956];
	//new str[956];
	new combine[956];
	new found = 0;
	new item = 0;
	for(new i = 0; i < MAX_APPLICATIONS; i++)
	{
        if(ApplicationInfo[i][SentIn] == 1)
		{
			if(ApplicationInfo[i][ID] >= 0)
			{
			    format(string, sizeof (string), "%s %s\n", string, ApplicationInfo[i][Name]);
				format(combine, sizeof(combine), "%s", string);
				found = 1;
				PlayerSelect[playerid][item] = i;
				item = item + 1;
			}
		}
    }
    if(found == 0) return SendClientMessage(playerid, COLOR_RED, "Error: Can't find any applications to review.");
	Dialog_Show(playerid, ApplicationPick, DIALOG_STYLE_LIST, "Applications", combine, "Review", "Cancel");
	return 1;
}

forward Application_Load();
public Application_Load()
{
	static
	    rows,
	    fields,
		string[128];

	cache_get_data(rows, fields, g_iHandle);

	for (new id = 0; id < rows; id ++) if (id < MAX_APPLICATIONS)
	{
		ApplicationInfo[id][ID] = cache_get_field_int(id, "ID");
		cache_get_field_content(id, "Name", string);
		format(ApplicationInfo[id][Name], 128, string);
		cache_get_field_content(id, "Question1", string);
		format(ApplicationInfo[id][Question1], 128, string);
		cache_get_field_content(id, "Question2", string);
		format(ApplicationInfo[id][Question2], 128, string);
		cache_get_field_content(id, "Question3", string);
		format(ApplicationInfo[id][Question3], 128, string);
		cache_get_field_content(id, "Question4", string);
		format(ApplicationInfo[id][Question4], 128, string);
		cache_get_field_content(id, "Question5", string);
		format(ApplicationInfo[id][Question5], 128, string);
		cache_get_field_content(id, "Question6", string);
		format(ApplicationInfo[id][Question6], 128, string);
		ApplicationInfo[id][AppPassed] = cache_get_field_int(id, "Accepted");
		ApplicationInfo[id][SentIn] = cache_get_field_int(id, "SentIn");
		ApplicationInfo[id][PlayerID] = -1;
		format(string, sizeof(string), "Application for %s loaded", ApplicationInfo[id][Name]);
		print(string);
	}
}
__________________
R.i.p Sa-mp.

#Save DL
TheLeech is offline   Reply With Quote
Old 15/11/2019, 07:50 AM   #3
Ponga
Big Clucker
 
Ponga's Avatar
 
Join Date: Oct 2017
Posts: 77
Reputation: 9
Default Re: [QUIZ ROLEPLAY]

Thanks man i appreciate it.
__________________
Ponga is offline   Reply With Quote
Old 15/11/2019, 08:33 AM   #4
Ponga
Big Clucker
 
Ponga's Avatar
 
Join Date: Oct 2017
Posts: 77
Reputation: 9
Default Re: [QUIZ ROLEPLAY]

Can someone send me full codes?
__________________
Ponga is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HELP] Quiz roleplay to register!! AtomicSAMP Scripting Help 1 30/04/2016 05:58 AM
Roleplay Quiz won't save? Please help Goldino Scripting Help 2 14/01/2013 05:11 PM
Roleplay quiz help Benzke Scripting Help 1 17/08/2012 02:34 PM
Dialog Quiz Roleplay Dare Devil..... Scripting Help 6 11/08/2012 12:40 PM
Roleplay Quiz aa Help Archive 1 31/10/2010 10:13 AM


All times are GMT. The time now is 02:25 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.