Advertisement
Guest User

Untitled

a guest
Mar 17th, 2012
1,132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. //Reaction Tests By [BP]Tony
  2.  
  3. #include <a_samp>
  4.  
  5. #if !defined Loop
  6. #define Loop(%0,%1) \
  7. for(new %0 = 0; %0 != %1; %0++)
  8. #endif
  9.  
  10. #if !defined function
  11. #define function%0(%1) \
  12. forward%0(%1); public%0(%1)
  13. #endif
  14.  
  15. #if !defined PURPLE
  16. #define PURPLE \
  17. 0xBF60FFFF
  18. #endif
  19.  
  20. #if !defined GREEN
  21. #define GREEN \
  22. 0x94D317FF
  23. #endif
  24.  
  25. #if !defined TIME
  26. #define TIME \
  27. 180000
  28. #endif
  29.  
  30. new
  31. xCharacters[][] =
  32. {
  33. "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
  34. "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
  35. "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
  36. "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
  37. "0", "1", "2", "3", "4", "5", "6", "7", "8", "9","!",":","'",";",
  38. "^","%","#","<",">",",",".","/","?","*","@","$","&","(",")"
  39. },
  40. xChars[16] = "",
  41. xReactionTimer,
  42. xCash,
  43. xScore,
  44. bool: xTestBusy
  45. ;
  46.  
  47. public OnFilterScriptInit()
  48. {
  49. xReactionTimer = SetTimer("xReactionTest", TIME, 1);
  50. return 1;
  51. }
  52.  
  53. public OnFilterScriptExit()
  54. {
  55. KillTimer(xReactionTimer);
  56. return 1;
  57. }
  58.  
  59. public OnPlayerText(playerid, text[])
  60. {
  61. switch(xTestBusy)
  62. {
  63. case true:
  64. {
  65. if(!strcmp(xChars, text, false))
  66. {
  67. new
  68. string[128],
  69. pName[MAX_PLAYER_NAME]
  70. ;
  71. GetPlayerName(playerid, pName, sizeof(pName));
  72. format(string, sizeof(string), "« \%s\" has won the reaction test. »", pName);
  73. SendClientMessageToAll(GREEN, string);
  74. format(string, sizeof(string), "« You have earned $%d + %d score points. »", xCash, xScore);
  75. SendClientMessage(playerid, GREEN, string);
  76. GivePlayerMoney(playerid, xCash);
  77. SetPlayerScore(playerid, GetPlayerScore(playerid) + xScore);
  78. xReactionTimer = SetTimer("xReactionTest", TIME, 1);
  79. xTestBusy = false;
  80. }
  81. }
  82. }
  83. return 1;
  84. }
  85.  
  86. function xReactionProgress()
  87. {
  88. switch(xTestBusy)
  89. {
  90. case true:
  91. {
  92. new
  93. string[128]
  94. ;
  95. format(string, sizeof(string), "« No-one won the reaction-test. New one starting in %d minutes. »", (TIME/60000));
  96. SendClientMessageToAll(PURPLE, string);
  97. xReactionTimer = SetTimer("xReactionTest", TIME, 1);
  98. }
  99. }
  100. return 1;
  101. }
  102.  
  103. function xReactionTest()
  104. {
  105. new
  106. xLength = (random(8) + 2),
  107. string[128]
  108. ;
  109. xCash = (random(10000) + 20000);
  110. xScore = (random(2)+1);
  111. format(xChars, sizeof(xChars), "");
  112. Loop(x, xLength) format(xChars, sizeof(xChars), "%s%s", xChars, xCharacters[random(sizeof(xCharacters))][0]);
  113. format(string, sizeof(string), "« Who first types %s wins $%d + %d score points. »", xChars, xCash, xScore);
  114. SendClientMessageToAll(PURPLE, string);
  115. KillTimer(xReactionTimer);
  116. xTestBusy = true;
  117. SetTimer("xReactionProgress", 30000, 0);
  118. return 1;
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement