Advertisement
Guest User

math_system

a guest
Aug 11th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf2>
  4.  
  5. #define COLOR_WHITE (0xFFFFFFAA)
  6.  
  7. enum E_MATH_TEST {
  8. m_result,
  9. m_reward,
  10. bool: m_active
  11. }
  12. new MathTest[E_MATH_TEST];
  13.  
  14. public OnGameModeInit() {
  15.  
  16. // reset math-test
  17. MathTest[m_result] = (0);
  18. MathTest[m_active] = (false);
  19. MathTest[m_reward] = (0);
  20.  
  21. return (true);
  22. }
  23.  
  24. public OnPlayerText(playerid, text[]) {
  25. if(strval(text) == MathTest[m_result] && MathTest[m_active] == (true)) {
  26. new tmpString[90];
  27.  
  28. format(tmpString, sizeof(tmpString), "[MATH-TEST]: Odgovorili ste tocno na math-pitanje (rezultat: %d) i zaradili ste %d$.", MathTest[m_result], MathTest[m_reward]);
  29. SendClientMessageToAll(COLOR_WHITE, (tmpString));
  30.  
  31. GivePlayerMoney(playerid, MathTest[m_reward]);
  32.  
  33. MathTest[m_result] = (0);
  34. MathTest[m_active] = (false);
  35. MathTest[m_reward] = (0);
  36. }
  37. return (true);
  38. }
  39.  
  40. CMD:math(playerid, params[]) {
  41.  
  42. if (!IsPlayerAdmin(playerid))
  43. return SendClientMessage(playerid, COLOR_WHITE, "Ne mozete koristiti ovu komandu.");
  44.  
  45. new reward;
  46. if(sscanf(params, "d", reward))
  47. return SendClientMessage(playerid, COLOR_WHITE, "[CMD]: /math [reward].");
  48.  
  49. new tmpString[64],
  50. num1 = (0), num2 = (0), num3 = (0);
  51. MathTest[m_result] = (num1 = random(100)) + (num2 = random(100))-(num3 = random(100));
  52. MathTest[m_active] = (true);
  53. MathTest[m_reward] = (reward);
  54.  
  55. format(tmpString, sizeof(tmpString), "[MATH-TEST]: Unesite rezultat od (%d+%d-%d), nagrada iznosi %d$.", num1, num2, num3, MathTest[m_reward]);
  56. SendClientMessageToAll(COLOR_WHITE, (tmpString));
  57.  
  58. return (true);
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement