Advertisement
Guest User

Math Test

a guest
Dec 22nd, 2013
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. new isnow;
  4. new result;
  5. new string_script[100];
  6. new numb[4];
  7. #define TIME 5
  8. #define RANDOMM 6
  9.  
  10. new playername_script[MAX_PLAYERS][MAX_PLAYER_NAME+1];
  11.  
  12. public OnPlayerConnect(playerid)
  13. {
  14. GetPlayerName(playerid, playername_script[playerid], MAX_PLAYER_NAME+1);
  15. return 1;
  16. }
  17.  
  18. public OnFilterScriptInit() {
  19. SetTimer("math", 1000 * 60 * TIME, true);
  20. return 1;
  21. }
  22.  
  23. forward math();
  24. public math() {
  25. if(!isnow)
  26. {
  27. switch(random(RANDOMM))
  28. {
  29. case 0: {
  30. result = (numb[0]=random(1000)) + (numb[1]=random(840));
  31. format(string_script, sizeof(string_script),"A new mathematical puzzle {00AAFF}%d{FFFFFF} + {00AAFF}%d{FFFFFF} Send the result to chat",numb[0], numb[1]);
  32. }
  33. case 1: {
  34. do
  35. {
  36. result = (numb[0]=random(500)) - (numb[1]=random(500));
  37. } while(numb[0] < numb[1]);
  38. format(string_script, sizeof(string_script),"A new mathematical puzzle {00AAFF}%d{FFFFFF} - {00AAFF}%d{FFFFFF} Send the result to chat",numb[0], numb[1]);
  39. }
  40. case 2: {
  41. result = (numb[0]=random(100)) * (numb[1]=random(80));
  42. format(string_script, sizeof(string_script),"A new mathematical puzzle %d*%d - Send the result to chat",numb[0], numb[1]);
  43. }
  44. case 3: {
  45. do {
  46. result = (numb[0]=random(1000)+1) / (numb[1]=random(600)+1);
  47. } while(numb[0] % numb[1]);
  48. format(string_script, sizeof(string_script),"A new mathematical puzzle {00AAFF}%d{FFFFFF} / {00AAFF}%d{FFFFFF} Send the result to chat",numb[0], numb[1]);
  49. }
  50. case 4: {
  51. result = (numb[0]=random(10)+1) * numb[0];
  52. format(string_script, sizeof(string_script),"A new mathematical puzzle kwadrat liczby {00AAFF}%d{FFFFFF} Send the result to chat",numb[0]);
  53. }
  54. case 5: {
  55. result = (numb[0]=random(10)+1) * numb[0] * numb[0];
  56. format(string_script, sizeof(string_script),"A new mathematical puzzle sześcian liczby {00AAFF}%d{FFFFFF} Send the result to chat",numb[0]);
  57. }
  58. }
  59. SendClientMessageToAll(-1, string_script);
  60. isnow = true;
  61. }
  62. else {
  63. isnow = false;
  64. format(string_script, sizeof(string_script),"No one guessed the riddle of mathematical");
  65. SendClientMessageToAll(-1, string_script);
  66. }
  67. return 1;
  68. }
  69.  
  70. public OnPlayerText(playerid, text[])
  71. {
  72. if(isnow && text[0] && result == strval(text))
  73. {
  74. isnow = false;
  75. format(string_script, sizeof(string_script),"%s Won math riddle!",playername_script);
  76. SendClientMessageToAll(-1, string_script);
  77. Prize(playerid);
  78. return 0;
  79. }
  80. return 1;
  81. }
  82.  
  83. stock Prize(playerid)
  84. {
  85. GivePlayerMoney(playerid, 444444);
  86. return 1;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement