Guest User

QuiZ System By Areeb memon/Usman Memon

a guest
May 19th, 2018
1,378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.01 KB | None | 0 0
  1. // QuiZ System by Usman Memon You can make answers question and can put price for each question also you can end it.
  2.  
  3. #include <a_samp>
  4. #include <zcmd>
  5. #include <sscanf2>
  6.  
  7. new quiz,
  8. answers[256],
  9. answermade,
  10. qprs;
  11.  
  12.  
  13. public OnFilterScriptInit()
  14. {
  15. print("\n--------------------------------------");
  16. print("QuiZ System by Usman");
  17. print("--------------------------------------\n");
  18. return 1;
  19. }
  20.  
  21. stock pNAME(playerid)
  22. {
  23. new name[MAX_PLAYER_NAME];
  24. GetPlayerName(playerid, name, sizeof(name));
  25. return name;
  26. }
  27.  
  28. CMD:makequiz(playerid, params[])
  29. {
  30. new tmp[128], string[256], str[256], pr;
  31. if(sscanf(params, "s", tmp)) {
  32. SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /makequiz [option]");
  33. SendClientMessage(playerid, 0xFFFFFFFF, "Options: question, answer, price, end");
  34. SendClientMessage(playerid, 0xFFFF00FF, "INFO: Please made the answer first.");
  35. return 1;
  36. }
  37. if(!strcmp(tmp, "question", true, 8))
  38. {
  39. if(sscanf(params, "s[128]s[256]", tmp, str)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /quiz question [question]");
  40. if (quiz == 1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Quiz already started you can end it with /makequiz end.");
  41. if (answermade == 0) return SendClientMessage(playerid, 0xFF0000FF, "Error: please made the answer first...");
  42. if (qprs == 0) return SendClientMessage(playerid, 0xFF0000FF, "Error: please add the price cost first.");
  43. format(string, sizeof(string), "[Quiz]: %s?, price amount {00FF00}%d.", str, qprs);
  44. SendClientMessageToAll(0xFFFF00FF, string);
  45. SendClientMessageToAll(0xFFFF00FF, "You can give answer by using /quizans.");
  46. quiz = 1;
  47. }
  48. else if(!strcmp(tmp, "answer", true, 6))
  49. {
  50. if(sscanf(params, "s[128]s[256]", tmp, str)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /quiz answer [answer]");
  51. if (quiz == 1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Quiz already started you can end it with /makequiz end.");
  52. answers = str;
  53. answermade = 1;
  54. format(string, sizeof(string), "You have made an answer, {00FF00}%s.", str);
  55. SendClientMessage(playerid, 0xFFFFFFFF, string);
  56. }
  57. else if(!strcmp(tmp, "price", true, 5))
  58. {
  59. if(sscanf(params, "s[128]d", tmp, pr)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /quiz price [amount]");
  60. if (quiz == 1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Quiz already started you can end it with /makequiz end.");
  61. if (answermade == 0) return SendClientMessage(playerid, 0xFF0000FF, "Error: Made the answer first...");
  62. if (pr <= 0) return SendClientMessage(playerid, 0xFF0000FF, "Error: make the price greater then 0!");
  63. qprs = pr;
  64. format(string, sizeof(string), "You have put {00FF00}%d as a price amount for quiz.", pr);
  65. SendClientMessage(playerid, 0xFFFFFFFF, string);
  66. }
  67. else if(!strcmp(tmp, "end", true, 3))
  68. {
  69. if (quiz == 0) return SendClientMessage(playerid, 0xFF0000FF, "Error: Unfortunately there is no quiz from server admins.");
  70. SendClientMessageToAll(0xFF0000FF, "Unfortunately server Admin has ended the quiz.");
  71. answermade = 0;
  72. quiz = 0;
  73. qprs = 0;
  74. answers = "";
  75. }
  76. return 1;
  77. }
  78.  
  79. CMD:quizans(playerid, params[])
  80. {
  81. new tmp[256], string[256];
  82. if (quiz == 0) return SendClientMessage(playerid, 0xFF0000FF, "Error: Unfortunately there is no quiz from server admins.");
  83. if (sscanf(params, "s[256]", tmp)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /quizans [answer]");
  84. if(strcmp(tmp, answers, true)==0)
  85. {
  86. GivePlayerMoney(playerid, qprs);
  87. format(string, sizeof(string), "[Quiz]: %s has give the correct answer '%s' of quiz and won {00FF00}%d.", pNAME(playerid), answers, qprs);
  88. SendClientMessageToAll(0xFFFF00FF, string);
  89. answermade = 0;
  90. quiz = 0;
  91. qprs = 0;
  92. answers = "";
  93. }
  94. else
  95. {
  96. SendClientMessage(playerid, 0xFF0000FF, "Error: Wrong answer try you luck next time.");
  97. }
  98. return 1;
  99. }
Add Comment
Please, Sign In to add comment