Advertisement
Guest User

Untitled

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