Guest User

Typing-Question [0.3x][FS]

a guest
Feb 14th, 2013
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.42 KB | None | 0 0
  1. /*
  2.  
  3. Create ReactionContest or Question by command!
  4.  
  5. Idea in Zher0's script.
  6. Created by BuzZ
  7.  
  8. Credits to
  9. Zher0
  10. Y_Less
  11. BuzZ
  12.  
  13. */
  14.  
  15. #include <a_samp>
  16. #include <sscanf2>
  17. #include <YSI\y_commands>
  18.  
  19. #define PRIZE_PER_CONTEST 1000 //When player types the contest first he gets the $$$ amount putted in the define
  20. #define PRIZE_PER_CONTEST_SCO 5 //When player types the contest first he gets the score amount putted in the define
  21.  
  22. #define COLOR_ORANGE 0xFF8000FF
  23. #define COLOR_YELLOW 0xFFFF00FF
  24.  
  25. #define QUESTION_TIMER 1000*30 //30 seconds - The time where typing contest ends (CHANGE IT)
  26. #define TYPING_TIMER 1000*30 //30 seconds - The time where typing contest ends (CHANGE IT)
  27.  
  28. new bool:Starts = false,
  29. TypeGame = -1,
  30. targetanswer[128],
  31. targetword[128],
  32. Timer,
  33. question[128];
  34.  
  35. forward KillTest();
  36.  
  37. #if defined FILTERSCRIPT
  38. #else
  39.  
  40. public OnFilterScriptInit()
  41. {
  42. print("\n");
  43. print("Create Reaction Contest or Question by command!");
  44. print("All Rights Reserved (c) 2013");
  45. print("[FS] Loaded!");
  46. print("\n");
  47. Starts = false;
  48. TypeGame = -1;
  49. KillTimer(Timer);
  50. return 1;
  51. }
  52.  
  53. public OnFilterScriptExit()
  54. {
  55. print("\n");
  56. print("Create Reaction Contest or Question by command!");
  57. print("All Rights Reserved (c) 2013");
  58. print("[FS] Unloaded!");
  59. print("\n");
  60. Starts = false;
  61. TypeGame = -1;
  62. KillTimer(Timer);
  63. return 1;
  64. }
  65.  
  66. #endif
  67.  
  68. public OnPlayerText(playerid, text[])
  69. {
  70. new str[128];
  71. if(Starts == true)
  72. {
  73. if(TypeGame == 0) //Question
  74. {
  75. if(strcmp(text, targetanswer, true) == 0)
  76. {
  77. format(str, sizeof(str), "ANSWER: Player %s[%d] answer the question '%s' the answer is '%s'", pName(playerid), playerid, question, targetanswer);
  78. SendClientMessageToAll(COLOR_ORANGE, str);
  79. format(str, sizeof(str), "REACTIONTEST: Player %s[%d] wins '$%d + %d score'", pName(playerid), playerid, PRIZE_PER_CONTEST, PRIZE_PER_CONTEST_SCO);
  80. SendClientMessageToAll(COLOR_YELLOW, str);
  81. GivePlayerMoney(playerid, PRIZE_PER_CONTEST);
  82. SetPlayerScore(playerid, GetPlayerScore(playerid) + PRIZE_PER_CONTEST_SCO);
  83. Starts = false;
  84. TypeGame = -1;
  85. KillTimer(Timer);
  86. return 0;
  87. }
  88. }
  89. if(TypeGame == 1) //Typing
  90. {
  91. if(strcmp(text, targetword, true) == 0)
  92. {
  93. format(str, sizeof(str), "REACTIONTEST: Player %s[%d] wins '$%d + %d score' for typing '%s' as first", pName(playerid), playerid, PRIZE_PER_CONTEST, PRIZE_PER_CONTEST_SCO, targetword);
  94. SendClientMessageToAll(COLOR_YELLOW, str);
  95. GivePlayerMoney(playerid, PRIZE_PER_CONTEST);
  96. SetPlayerScore(playerid, GetPlayerScore(playerid) + PRIZE_PER_CONTEST_SCO);
  97. Starts = false;
  98. TypeGame = -1;
  99. KillTimer(Timer);
  100. return 0;
  101. }
  102. }
  103. }
  104. return 1;
  105. }
  106.  
  107. public KillTest()
  108. {
  109. new str[128];
  110. if(Starts == true)
  111. {
  112. if(TypeGame == 0)
  113. {
  114. format(str, sizeof(str), "QUESTION: No one answers the question '%s', The answer is '%s'", question, targetanswer);
  115. SendClientMessageToAll(COLOR_YELLOW, str);
  116. Starts = false;
  117. TypeGame = -1;
  118. }
  119. if(TypeGame == 1)
  120. {
  121. format(str, sizeof(str), "TYPING: No one types the word '%s'", targetword);
  122. SendClientMessageToAll(COLOR_YELLOW, str);
  123. Starts = false;
  124. TypeGame = -1;
  125. }
  126. }
  127. KillTimer(Timer);
  128. return 1;
  129. }
  130.  
  131. YCMD:startquestion(playerid, params[], help)
  132. {
  133. #pragma unused help
  134. new str[128];
  135. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "Invalid: You're not allowed to use this command!");
  136. if(Starts == true) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: There is current contest starting, Please wait...");
  137. if(sscanf(params, "p<,>s[128]s[128]", question, targetanswer)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /startquestion [question] [answer]");
  138. format(str, sizeof(str), "QUESTION: '%s', First who answer it gets '$%d + %d score'", question, PRIZE_PER_CONTEST, PRIZE_PER_CONTEST_SCO);
  139. SendClientMessageToAll(COLOR_YELLOW, str);
  140. SendClientMessageToAll(-1, "QUESTION: You only have 30 seconds to answer it");
  141. SendClientMessage(playerid, -1, "Question has been started, The question timer will end about 30 seconds");
  142. Starts = true;
  143. TypeGame = 0;
  144. Timer = SetTimer("KillTest", QUESTION_TIMER, false);
  145. return 1;
  146. }
  147.  
  148. YCMD:starttype(playerid, params[], help)
  149. {
  150. #pragma unused help
  151. new str[128];
  152. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "Invalid: You're not allowed to use this command!");
  153. if(Starts == true) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: There is current contest starting, Please wait...");
  154. if(sscanf(params, "s[128]", targetword)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /starttype [word]");
  155. format(str, sizeof(str), "REACTION: First who types '%s', gets '$%d + %d score'", targetword, PRIZE_PER_CONTEST, PRIZE_PER_CONTEST_SCO);
  156. SendClientMessageToAll(COLOR_YELLOW, str);
  157. SendClientMessageToAll(-1, "QUESTION: You only have 30 seconds to answer it");
  158. SendClientMessage(playerid, -1, "Question has been started, The type timer will end about 30 seconds");
  159. Starts = true;
  160. TypeGame = 1;
  161. Timer = SetTimer("KillTest", TYPING_TIMER, false);
  162. return 1;
  163. }
  164.  
  165. //==============================================================================
  166.  
  167. stock pName(playerid)
  168. {
  169. new getname[24];
  170. GetPlayerName(playerid, getname, 24);
  171. return getname;
  172. }
Advertisement
Add Comment
Please, Sign In to add comment