Guest User

BuzZ's Math System

a guest
Mar 3rd, 2013
1,035
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. //Math System by BuzZ
  2.  
  3. #include <a_samp>
  4.  
  5. #define TIME 1 //When the contest will start (Minutes)
  6. #define PRIZE 3000 //Reward ($$$) when win in Math Contest
  7. #define PRIZESCORE 5 //Reward (Score) when win in Math Contest
  8.  
  9. new answer;
  10. new endm = 0;
  11. new no1, no2, no3;
  12. new typem = -1;
  13. new timermath;
  14. new timermath2;
  15. new str[128];
  16.  
  17. forward Math();
  18. forward MathEnd();
  19.  
  20. #define COLOR_YELLOW 0xFFFF00FF
  21.  
  22. #define white "{FFFFFF}"
  23. #define red "{FF002B}"
  24. #define orange "{F2C80C}"
  25.  
  26. #define FILTERSCRIPT
  27. #if defined FILTERSCRIPT
  28.  
  29. public OnFilterScriptInit()
  30. {
  31. print("\n");
  32. print("* Math System by BuzZ *");
  33. print("* Loaded *");
  34. print("\n");
  35. typem = -1;
  36. endm = 0;
  37. timermath = SetTimer("Math", 1000*60*TIME, true);
  38. return 1;
  39. }
  40.  
  41. public OnFilterScriptExit()
  42. {
  43. print("\n");
  44. print("* Math System by BuzZ *");
  45. print("* Unloaded *");
  46. print("\n");
  47. typem = -1;
  48. endm = 0;
  49. KillTimer(timermath);
  50. return 1;
  51. }
  52.  
  53. #endif
  54.  
  55. public Math()
  56. {
  57. typem = random(2);
  58. no1 = random(600);
  59. no2 = random(50);
  60. no3 = random(100);
  61.  
  62. endm = 1;
  63. switch(typem)
  64. {
  65. case 0:
  66. {
  67. answer = no1 + no2 + no3;
  68. format(str, sizeof(str), "MATH: "white"The first one who answers (solve) this "red"%d+%d+%d "orange"wins $3,000 + 5 score", no1, no2, no3);
  69. SendClientMessageToAll(COLOR_YELLOW, str);
  70. }
  71. case 1:
  72. {
  73. answer = no1 - no2 - no3;
  74. format(str, sizeof(str), "MATH: "white"The first one who answers (solve) this "red"%d-%d-%d "orange"wins $3,000 + 5 score", no1, no2, no3);
  75. SendClientMessageToAll(COLOR_YELLOW, str);
  76. }
  77. case 2:
  78. {
  79. answer = no1 * no2 * no3;
  80. format(str, sizeof(str), "MATH: "white"The first one who answers (solve) this "red"%dx%dx%d "orange"wins $3,000 + 5 score", no1, no2, no3);
  81. SendClientMessageToAll(COLOR_YELLOW, str);
  82. }
  83. }
  84. SendClientMessageToAll(-1, "Math will end on 30 seconds!");
  85. timermath2 = SetTimer("MathEnd", 1000*30, false);
  86. return 1;
  87. }
  88.  
  89. public MathEnd()
  90. {
  91. switch(typem)
  92. {
  93. case 0:
  94. {
  95. format(str, sizeof(str), "MATH: "white"No one won the Math Contest the answer is '%d'", answer);
  96. SendClientMessageToAll(COLOR_YELLOW, str);
  97. }
  98. case 1:
  99. {
  100. format(str, sizeof(str), "MATH: "white"No one won the Math Contest the answer is '%d'", answer);
  101. SendClientMessageToAll(COLOR_YELLOW, str);
  102. }
  103. case 2:
  104. {
  105. format(str, sizeof(str), "MATH: "white"No one won the Math Contest the answer is '%d'", answer);
  106. SendClientMessageToAll(COLOR_YELLOW, str);
  107. }
  108. }
  109. endm = 0;
  110. KillTimer(timermath2);
  111. return 1;
  112. }
  113.  
  114. public OnPlayerText(playerid, text[])
  115. {
  116. if(strval(text) == answer && endm == 1)
  117. {
  118. format(str, sizeof(str), "MATH: %s(%d) won the Math Contest, He/She won the $%d + %i score [ Answer: %d ]", GetName(playerid), playerid, PRIZE, PRIZESCORE, answer);
  119. SendClientMessageToAll(COLOR_YELLOW, str);
  120. GivePlayerMoney(playerid, PRIZE);
  121. SetPlayerScore(playerid, GetPlayerScore(playerid) + PRIZESCORE);
  122. KillTimer(timermath2);
  123. endm = 0;
  124. return 0;
  125. }
  126. return 1;
  127. }
  128.  
  129. stock GetName(playerid)
  130. {
  131. new pName[24];
  132. GetPlayerName(playerid, pName, 24);
  133. return pName;
  134. }
Advertisement
Add Comment
Please, Sign In to add comment