Guest User

Untitled

a guest
Jul 6th, 2020
29
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // PlayerInfo
  3.  
  4. pQuizLoop[101]
  5.  
  6. //OnGameModeInit
  7. for(new i=0; i<sizeof(OrderText); i++)
  8. {
  9. QuizSystem[i][quiz_id] = -1;
  10. }
  11.  
  12. //
  13.  
  14.  
  15. // OnDialogResponse
  16.  
  17. case DIALOG_ADMIN_SEARCHQUIZ:
  18. {
  19. if(!response) return 0;
  20.  
  21. if(IsNumeric(inputtext))
  22. {
  23. new qid = strval(inputtext);
  24. if(!IsValidQuiz(qid)) return ShowPlayerDialog(playerid,DIALOG_ADMIN_SEARCHQUIZ,DIALOG_STYLE_INPUT,"{FFFFFF}.::Quiz not found!::.","{FFFFFF}Please Insert the exact: [NAME, ID OR KEYWORD] for the {04B431}Quiz you're looking for.","{58D3F7}Search...","Exit");
  25. }
  26. else
  27. {
  28. new count,string[120];
  29. for(new i = 0; i<sizeof(QuizSystem);i++)
  30. {
  31. if(IsValidQuiz(i))
  32. {
  33. new loop = GetFreeQuizLoop(playerid),getIt,stopIt;
  34. //if(loop == -1) return ShowPlayerDialog(playerid,DIALOG_ADMIN_SEARCHQUIZ,DIALOG_STYLE_INPUT,"{FFFFFF}.::Invalid LOOP-ID::.","{FFFFFF}Please Insert the exact: [NAME, ID OR KEYWORD] for the {04B431}Quiz you're looking for.","{58D3F7}Search...","Exit");
  35. loop_start:
  36. if(loop == -1)
  37. {
  38. loop = GetFreeQuizLoop(playerid);
  39. stopIt++;
  40. goto loop_start;
  41. }
  42. if(stopIt > 30)
  43. {
  44. ResetPlayerLoop(playerid);
  45. SCM(playerid,COOLRED,"[Search for Quiz] The server rejected your request because of too many results, use /quizzes");
  46. break;
  47. }
  48. if(strfind(QuizSystem[i][quiz_question], inputtext,true) != -1)
  49. {
  50. PlayerInfo[playerid][pQuizLoop][loop] = i;
  51. count++;
  52. getIt++;
  53. continue;
  54. }
  55. else if(strfind(QuizSystem[i][quiz_name], inputtext,true) != -1)
  56. {
  57. PlayerInfo[playerid][pQuizLoop][loop] = i;
  58. count++;
  59. getIt++;
  60. continue;
  61. }
  62. else if(strfind(QuizSystem[i][quiz_answer], inputtext,true) != -1)
  63. {
  64. PlayerInfo[playerid][pQuizLoop][loop] = i;
  65. count++;
  66. getIt++;
  67. }
  68. printf("Loopid: %d",loop);
  69. }
  70. }
  71. printf("Count: %d",count);
  72. format(string,sizeof(string),"{FFFFFF}A total of {01DF01}%d{FFFFFF} Quizzes have been found!",count);
  73. ShowPlayerDialog(playerid,DIALOG_ADMIN_SEARCHQUIZ_2,DIALOG_STYLE_MSGBOX,"{FFFFFF}.::Quizzes found: ::.",string,"{58D3F7}Okay","");
  74.  
  75. }
  76. }
  77. case DIALOG_ADMIN_SEARCHQUIZ_2:
  78. {
  79. new string2[256],count;
  80. for(new i=0;i<100;i++)
  81. {
  82. printf("QUIZ_LOOP: %d, %d, %d",PlayerInfo[playerid][pQuizLoop][i],i,QuizSystem[i][quiz_active]);
  83. if(PlayerInfo[playerid][pQuizLoop][i] != -1 && IsValidQuiz(PlayerInfo[playerid][pQuizLoop][i]))
  84. {
  85. printf("Abgerufen, da! %s %s",QuizSystem[i][quiz_name],QuizSystem[i][quiz_creator]);
  86. format(string2,sizeof(string2),"%s %s, Made by: %s\n",string2,QuizSystem[i][quiz_name],QuizSystem[i][quiz_creator]); // Need to put string itself before it OR it will just get reformatted all the time
  87. count++;
  88. }
  89. }
  90. if(count == 0) return ShowPlayerDialog(playerid,DIALOG_ADMIN_SEARCHQUIZ_3, DIALOG_STYLE_LIST, "{FFFFFF}.::Quizzes result: ::.", "Nothing found...", "{58D3F7}Oh.Okay", "");
  91. ShowPlayerDialog(playerid,DIALOG_ADMIN_SEARCHQUIZ_3, DIALOG_STYLE_LIST, "{FFFFFF}.::Quizzes result: ::.", string2, "{58D3F7}Select", "Exit");
  92.  
  93. ResetPlayerLoop(playerid);
  94.  
  95. }
  96.  
  97. case DIALOG_ADMIN_SEARCHQUIZ_2:
  98. {
  99. new string2[256],count;
  100. for(new i=0;i<100;i++)
  101. {
  102. printf("QUIZ_LOOP: %d, %d, %d",PlayerInfo[playerid][pQuizLoop][i],i,QuizSystem[i][quiz_active]);
  103. if(PlayerInfo[playerid][pQuizLoop][i] != -1 && IsValidQuiz(PlayerInfo[playerid][pQuizLoop][i]))
  104. {
  105. printf("Abgerufen, da! %s %s",QuizSystem[i][quiz_name],QuizSystem[i][quiz_creator]);
  106. format(string2,sizeof(string2),"%s %s, Made by: %s\n",string2,QuizSystem[i][quiz_name],QuizSystem[i][quiz_creator]); // Need to put string itself before it OR it will just get reformatted all the time
  107. count++;
  108. }
  109. }
  110. if(count == 0) return ShowPlayerDialog(playerid,DIALOG_ADMIN_SEARCHQUIZ_3, DIALOG_STYLE_LIST, "{FFFFFF}.::Quizzes result: ::.", "Nothing found...", "{58D3F7}Oh.Okay", "");
  111. ShowPlayerDialog(playerid,DIALOG_ADMIN_SEARCHQUIZ_3, DIALOG_STYLE_LIST, "{FFFFFF}.::Quizzes result: ::.", string2, "{58D3F7}Select", "Exit");
  112.  
  113. ResetPlayerLoop(playerid);
  114.  
  115. }
  116.  
  117.  
  118.  
  119. //Public
  120. stock ResetPlayerLoop(playerid)
  121. {
  122. for(new i=0;i<100;i++)
  123. {
  124. PlayerInfo[playerid][pQuizLoop][i] = -1;
  125. }
  126. return 1;
  127. }
  128.  
  129.  
  130. ocmd:startquiz(playerid,params[]) // find by STRFIND
  131. {
  132. if(!IsPlayerAdminEx(playerid,2))return SCM(playerid,COLOR_RED,"You are not permitted.");
  133. ShowPlayerDialog(playerid,DIALOG_ADMIN_SEARCHQUIZ,DIALOG_STYLE_INPUT,"{FFFFFF}.::Choose a Quiz::.","{FFFFFF}Please Insert the exact: [NAME, ID] or a KEYWORD for the {04B431}Quiz {FFFFFF}you're looking for.","{58D3F7}Search...","Exit");
  134. return 1;
  135. }
  136.  
  137.  
  138. stock GetFreeQuizLoop(playerid)
  139. {
  140. for(new i=0; i<100;i++)
  141. {
  142. if(PlayerInfo[playerid][pQuizLoop][i] == -1) return i;
  143. }
  144. return -1;
  145. }
  146.  
  147. stock IsValidQuiz(quizid)
  148. {
  149. if(QuizSystem[quizid][quiz_id] == -1 || QuizSystem[quizid][quiz_active] == 0)return 0;
  150. return 1;
  151. }
RAW Paste Data