Advertisement
Kovacs_Bela

[FS] >HUN< Reakcióteszt

Dec 18th, 2011
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.90 KB | None | 0 0
  1. /*
  2.  
  3. Reaction Contest v1.0
  4. ---------------------------
  5. Made by Kostas
  6. ---------------------------
  7. Copyright(c), Kostas™
  8.  
  9. *//*
  10.  
  11. ================================================================================
  12.  
  13. *//*
  14. ________________________________________________________________________________
  15. Credits:
  16.  
  17. * The SA-MP Team
  18. - SA-MP Client + Server & making SA-MP
  19.  
  20. * Sascha
  21. - Contest Function, Random Numbers, GetTickCount in Milliseconds,
  22.  
  23. * Kostas(me)
  24. - Creating the Script
  25. ________________________________________________________________________________
  26.  
  27. Information:
  28.  
  29. Hello, thanks for reading this. I worked on this script for three days and I would appretiate
  30. if you don't re-release it as your own. Since the Reaction Contest(Filterscript) has been finished
  31. on November 18,2011 is free for everyone to use it!
  32.  
  33. Script features:
  34.  
  35. -Two Reaction types(Typing Part) & (Maths Part),
  36. -Maths includes three types of mathematical operation(addition '+', subtraction '-', multiplication '*')
  37.  
  38. *//*
  39.  
  40. ================================================================================
  41.  
  42. *//*Includes*/
  43. #include <a_samp>
  44. /*Defines*/
  45. #define Loop(%0,%1) for(new %0 = 0; %0 != %1; %0++)
  46. #define function%0(%1) forward%0(%1); public%0(%1)
  47. #define CONTEST_PRIZE 40000
  48. #define CONTEST_TIME 3
  49. #define CONTEST_MATH 0
  50. #define CONTEST_TYPE 1
  51. /*Defines Colours*/
  52. #define COLOR_ORANGE 0xFF9600FF
  53. #define COLOR_RED 0xFF0000FF
  54. /*Variables*/
  55. new rName[MAX_PLAYER_NAME], string[128], ReactionTest[2], ReactionTimer,
  56. ContestType = -1, MathsResult, Characters[][] =
  57. {
  58. "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M",
  59. "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y",
  60. "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
  61. "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
  62. "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
  63. },
  64. Chars[17] = "";
  65. /*
  66.  
  67. ================================================================================
  68.  
  69. *//*Main Part*/
  70. public OnFilterScriptInit()
  71. {
  72. ReactionTimer = SetTimerEx("Contest_Function", (1000*60*CONTEST_TIME), false, "i", 1);
  73. return 1;
  74. }
  75. public OnFilterScriptExit()
  76. {
  77. KillTimer(ReactionTimer);
  78. return 1;
  79. }
  80. public OnPlayerText(playerid, text[])
  81. {
  82. switch(ContestType) {
  83. case CONTEST_MATH:
  84. {
  85. if(strval(text) == MathsResult) {
  86. GetPlayerName(playerid, rName, sizeof(rName));
  87. ReactionTest[1] = GetTickCount();
  88. new timeresult = ReactionTest[1] - ReactionTest[0];
  89. format(string, sizeof(string), "[Reakcióteszt]: %s megnyerte a reakciótesztet ( ''%i'' ) %d másodperc alatt! Ezért kapott %d$-t!", rName, MathsResult, timeresult,CONTEST_PRIZE);
  90. SendClientMessageToAll(COLOR_RED, string);
  91. GivePlayerMoney(playerid, CONTEST_PRIZE);
  92. ReactionTimer = SetTimerEx("Contest_Function", (1000*60*CONTEST_TIME), false, "i", 1);
  93. ContestType = false;
  94. }
  95. }
  96. case CONTEST_TYPE:
  97. {
  98. if(!strcmp(Chars, text, false)) {
  99. GetPlayerName(playerid, rName, sizeof(rName));
  100. ReactionTest[1] = GetTickCount();
  101. new timeresult = ReactionTest[1] - ReactionTest[0];
  102. format(string, sizeof(string), "[Reakcióteszt]: %s megnyerte a reakciótesztet ( ''%i'' ) %d másodperc alatt! Ezért kapott %d$-t!", rName, Chars, timeresult,CONTEST_PRIZE);
  103. SendClientMessageToAll(COLOR_RED, string);
  104. GivePlayerMoney(playerid, CONTEST_PRIZE);
  105. ReactionTimer = SetTimerEx("Contest_Function", (1000*60*CONTEST_TIME), false, "i", 1);
  106. ContestType = false;
  107. }
  108. }
  109. }
  110. return 1;
  111. }
  112. forward Contest_Function(type);
  113. public Contest_Function(type)
  114. {
  115. switch(type) {
  116. case 0:
  117. {
  118. new xLength = (10);
  119. format(Chars, sizeof(Chars), "");
  120. Loop(x, xLength) format(Chars, sizeof(Chars), "%s%s", Chars, Characters[random(sizeof(Characters))][0]);
  121. format(string, sizeof(string), "[Reakcióteszt]: Ha beírod ezt: '%s', és te vagy az első, akkor kapsz %d$-t!", Chars, CONTEST_PRIZE);
  122. SendClientMessageToAll(COLOR_RED, string);
  123. KillTimer(ReactionTimer);
  124. ReactionTest[0] = GetTickCount();
  125. ContestType = true;
  126. ContestType = CONTEST_TYPE;
  127. ReactionTimer = SetTimerEx("Contest_Function", (1000*60*CONTEST_TIME), false, "i", 1);
  128. return 1;
  129. }
  130. case 1:
  131. {
  132. new number1 = random(101), number2 = random(101), maths = random(2);
  133. if(maths == 0) {
  134. MathsResult = number1 + number2;
  135. format(string, sizeof(string), "[Reakcióteszt]: Ha kiszámolod ezt: '%d + %d', és te vagy az első akkor kapsz %d$-t", number1, number2,CONTEST_PRIZE);
  136. }
  137. else if (maths == 2) {
  138. MathsResult = number1 - number2;
  139. format(string, sizeof(string), "[Reakcióteszt]: Ha kiszámolod ezt: '%d - %d', és te vagy az első akkor kapsz %d$-t", number1, number2,CONTEST_PRIZE);
  140. }
  141. else {
  142. MathsResult = number1 * number2;
  143. format(string, sizeof(string), "[Reakcióteszt]: Ha kiszámolod ezt: '%d x %d', és te vagy az első akkor kapsz %d$-t", number1, number2,CONTEST_PRIZE);
  144. }
  145. SendClientMessageToAll(COLOR_RED, string);
  146. KillTimer(ReactionTimer);
  147. ReactionTest[0] = GetTickCount();
  148. ContestType = true;
  149. ContestType = CONTEST_MATH;
  150. ReactionTimer = SetTimerEx("Contest_Function", (1000*60*CONTEST_TIME), false, "i", 0);
  151. return 1;
  152. }
  153. }
  154. return 1;
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement