Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // QuiZ System by Usman Memon You can make answers question and can put price for each question also you can end it.
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- new quiz,
- answers[256],
- answermade,
- qprs;
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("QuiZ System by Usman");
- print("--------------------------------------\n");
- return 1;
- }
- stock pNAME(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- return name;
- }
- CMD:makequiz(playerid, params[])
- {
- new tmp[128], string[256], str[256], pr;
- if(sscanf(params, "s", tmp)) {
- SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /makequiz [option]");
- SendClientMessage(playerid, 0xFFFFFFFF, "Options: question, answer, price, end");
- SendClientMessage(playerid, 0xFFFF00FF, "INFO: Please made the answer first.");
- return 1;
- }
- if(!strcmp(tmp, "question", true, 8))
- {
- if(sscanf(params, "s[128]s[256]", tmp, str)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /quiz question [question]");
- if (quiz == 1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Quiz already started you can end it with /makequiz end.");
- if (answermade == 0) return SendClientMessage(playerid, 0xFF0000FF, "Error: please made the answer first...");
- if (qprs == 0) return SendClientMessage(playerid, 0xFF0000FF, "Error: please add the price cost first.");
- format(string, sizeof(string), "[Quiz]: %s?, price amount {00FF00}%d.", str, qprs);
- SendClientMessageToAll(0xFFFF00FF, string);
- SendClientMessageToAll(0xFFFF00FF, "You can give answer by using /quizans.");
- quiz = 1;
- }
- else if(!strcmp(tmp, "answer", true, 6))
- {
- if(sscanf(params, "s[128]s[256]", tmp, str)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /quiz answer [answer]");
- if (quiz == 1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Quiz already started you can end it with /makequiz end.");
- answers = str;
- answermade = 1;
- format(string, sizeof(string), "You have made an answer, {00FF00}%s.", str);
- SendClientMessage(playerid, 0xFFFFFFFF, string);
- }
- else if(!strcmp(tmp, "price", true, 5))
- {
- if(sscanf(params, "s[128]d", tmp, pr)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /quiz price [amount]");
- if (quiz == 1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Quiz already started you can end it with /makequiz end.");
- if (answermade == 0) return SendClientMessage(playerid, 0xFF0000FF, "Error: Made the answer first...");
- if (pr <= 0) return SendClientMessage(playerid, 0xFF0000FF, "Error: make the price greater then 0!");
- qprs = pr;
- format(string, sizeof(string), "You have put {00FF00}%d as a price amount for quiz.", pr);
- SendClientMessage(playerid, 0xFFFFFFFF, string);
- }
- else if(!strcmp(tmp, "end", true, 3))
- {
- if (quiz == 0) return SendClientMessage(playerid, 0xFF0000FF, "Error: Unfortunately there is no quiz from server admins.");
- SendClientMessageToAll(0xFF0000FF, "Unfortunately server Admin has ended the quiz.");
- answermade = 0;
- quiz = 0;
- qprs = 0;
- answers = "";
- }
- return 1;
- }
- CMD:quizans(playerid, params[])
- {
- new tmp[256], string[256];
- if (quiz == 0) return SendClientMessage(playerid, 0xFF0000FF, "Error: Unfortunately there is no quiz from server admins.");
- if (sscanf(params, "s[256]", tmp)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /quizans [answer]");
- if(strcmp(tmp, answers, true)==0)
- {
- GivePlayerMoney(playerid, qprs);
- format(string, sizeof(string), "[Quiz]: %s has give the correct answer '%s' of quiz and won {00FF00}%d.", pNAME(playerid), answers, qprs);
- SendClientMessageToAll(0xFFFF00FF, string);
- answermade = 0;
- quiz = 0;
- qprs = 0;
- answers = "";
- }
- else
- {
- SendClientMessage(playerid, 0xFF0000FF, "Error: Wrong answer try you luck next time.");
- }
- return 1;
- }
Add Comment
Please, Sign In to add comment