Advertisement
Guest User

0Reactions by Zh3r0

a guest
May 6th, 2011
689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.34 KB | None | 0 0
  1. #if defined x
  2.  
  3.     |===========================================|
  4.     |         Reaction Tests by Zh3r0           |
  5.     |-------------------------------------------|
  6.     |       Creation date: May, 06, 2011        |
  7.     |                                           |
  8.     |   Type in console !start to start a test  |
  9.     |                                           |
  10.     |         Please keep the credits!          |
  11.     |===========================================|
  12.    
  13. #endif
  14.  
  15. #include <a_samp>
  16.  
  17. #define INTERVAL     \
  18.     (3 * 60 * 1_000)    
  19.    
  20. #define MAX_RANDOM   \
  21.     15          
  22.  
  23. #define MAX_MESSAGES \
  24.     25
  25.    
  26. new bTest, bMoney, bScore, bString[2][256], bool:Won, Winner[MAX_PLAYER_NAME], mString[30], Timer,
  27.     iMessages[MAX_MESSAGES][129], mCount = 0;
  28.  
  29. AddNewMessage(msg[])
  30. {
  31.  
  32.     memcpy(iMessages[mCount], msg, 0, 129, 129),
  33.     mCount++;
  34.    
  35.     if(mCount >= MAX_MESSAGES){
  36.         print("WARNING!! YOU EXCEEDED THE LIMIT OF "#MAX_MESSAGES" MESSAGES!\n\n\n");}
  37. }
  38.  
  39. public OnFilterScriptInit()
  40. {
  41.     AddNewMessage("This server rocks!!!");
  42.     AddNewMessage("We love to entertain you");
  43.     AddNewMessage("3v3RY0n3 l1k32 l337!!");
  44.     AddNewMessage("7hIz 73X7 iZ h4Rd 70 wRi73!" );
  45.     AddNewMessage("|-|4><0.-3.-2 |\\/||_|57 |)13");
  46.     AddNewMessage("asdasdasd");
  47.  
  48.    
  49.     printf("\n\n\
  50.    |===========================================|\n\
  51.     |         Reaction Tests by Zh3r0           |\n\
  52.     |-------------------------------------------|\n\
  53.     |       Creation date: May, 06, 2011        |\n\
  54.     |                                           |\n\
  55.     |    Type in console !help to more info     |\n\
  56.     |             Loaded %d messages            |\n\
  57.     |                                           |\n\
  58.     |         Please keep the credits!          |\n\
  59.     |===========================================|", mCount);
  60.    
  61.     Timer = SetTimerEx(#StartReaction, INTERVAL, 1, "dd", random(2), random(2));
  62.     return 1;
  63. }
  64. public OnPlayerConnect(playerid)
  65. {
  66.     SendClientMessage(playerid, ~1, "This server uses {CFF55F}Reaction Tests{FFFFFF} by {CFF55F}Zh3r0{FFFFFF}! Wait for them to appear!");
  67.     return 1;
  68. }
  69. public OnRconCommand(cmd[])
  70. {
  71.     if(!strcmp(cmd, "!help", .length = 5))
  72.     {
  73.         print("\n\n\
  74.         |===========================================|\n\
  75.         |         Reaction Tests by Zh3r0           |\n\
  76.         |-------------------------------------------|\n\
  77.         |   Type /start in-game logged as admin     |\n\
  78.         |   to initiate a reaction test!            |\n\
  79.         |   Type in console !showmsgs to list the   |\n\
  80.         |   messages created.                       |\n\
  81.         |===========================================|\n\n\n");
  82.         return 1;
  83.     }
  84.     if(!strcmp(cmd, "!showmsgs", .length = 9))
  85.     {
  86.         print("\n\n\nDisplaying created messages:\n-----------------------\n");
  87.         for( new m; m < mCount; m++)
  88.         {
  89.             print(iMessages[m]);
  90.         }
  91.     }
  92.     return 1;
  93. }
  94. public OnPlayerCommandText(playerid, cmdtext[])
  95. {
  96.     if(!strcmp(cmdtext, "/start", true, 6))
  97.     {
  98.         if(IsPlayerAdmin(playerid))
  99.         {
  100.             if((cmdtext[6] != ' ') || (cmdtext[7] == EOS))
  101.                 return SendClientMessage(playerid, ~1, "USAGE: {C3C3C3}/start math/message [text]/reaction/random");
  102.                
  103.             if(!strcmp(cmdtext[7], "math"))
  104.             {
  105.                 StartReaction(0, 0);
  106.                 SendClientMessage(playerid, ~1, "You started the {CFF55F}Math Reaction Test");
  107.             }
  108.             else if(!strcmp(cmdtext[7], "message", true, 7))
  109.             {
  110.                 if(cmdtext[14] == ' ' || cmdtext[15 || 14] != EOS)
  111.                     StartReaction(1, 0, cmdtext[15]);
  112.  
  113.                 else if( cmdtext[15] >= EOS )
  114.                     StartReaction(1, 0);
  115.                    
  116.                 SendClientMessage(playerid, ~1, "You started the {CFF55F}Message Reaction Test");
  117.             }
  118.             else if(!strcmp(cmdtext[7], "reaction"))
  119.             {
  120.                 StartReaction(1, 1);
  121.                 SendClientMessage(playerid, ~1, "You started the {CFF55F}Reaction Test");
  122.             }
  123.             else if(!strcmp(cmdtext[7], "random"))
  124.             {
  125.                 KillTimer(Timer);
  126.                 StartReaction(random(2), random(2));
  127.                 Timer = SetTimerEx(#StartReaction, INTERVAL, 1, "dd", random(2), random(2) );
  128.             }
  129.             else return SendClientMessage(playerid, ~1, "USAGE: {C3C3C3}/start math/message [text]/reaction");
  130.  
  131.         }else return 0;
  132.         return 1;
  133.     }
  134.     return 0;
  135. }
  136.  
  137. StartReaction( R1 = 2, R2 = 2, text[] = "?????")
  138. {
  139.     if(!Won){
  140.         switch(bTest)
  141.         {
  142.             case (1): format(bString[1], 256, "Nobody was smart enough to calculate {CFF55F}%s{FFFFFF}. The answer was {CFF55F}%s{FFFFFF}.", mString, bString[0]);
  143.             case (2):  format(bString[1], 256, "Nobody wrote {CFF55F}%s{FFFFFF} in time!", bString[0]);
  144.             case (3): format(bString[1], 256, "Nobody was fast enough to write {CFF55F}%s{FFFFFF} in time!", bString[0]);
  145.         }
  146.         if(strlen(bString[1]))SendClientMessageToAll(~1, bString[1]);
  147.     }
  148.     bString[0][0] = EOS;
  149.     bString[1][0] = EOS;
  150.     Winner[0] = EOS;
  151.     mString[0] = EOS;
  152.    
  153.     bMoney = RandomEx(.Min = 9000, .Max = 7000),
  154.     bScore = RandomEx(.Min = 96, .Max = 120);
  155.    
  156.     if(!R1)
  157.     {
  158.         new
  159.             N[4];
  160.                
  161.         for(new n = 0; n != 4; n++) {N[n] = 15 + random(50);}
  162.         switch(random(6))
  163.         {
  164.             case (0): format(mString, sizeof(mString), "%d+%d-%d-%d",N[0],N[1],N[2],N[3]),
  165.                       format(bString[0], 256, "%d", N[0] + N[1] - N[2] - N[3]);
  166.                        
  167.             case (1): format(mString, sizeof(mString), "%d-%d+%d-%d",N[0]+40,N[1],N[2],N[3]),
  168.                       format(bString[0], 256, "%d", N[0]+40 - N[1] + N[2] - N[3]);
  169.  
  170.             case (2): format(mString, sizeof(mString), "%d-%d+%d+%d",N[0]+40,N[1],N[2],N[3]),
  171.                       format(bString[0], 256, "%d", N[0]+40 - N[1] + N[2] + N[3]);
  172.                        
  173.             case (3): format(mString, sizeof(mString), "%d+%d+%d+%d",N[0],N[1],N[2],N[3]),
  174.                       format(bString[0], 256, "%d", N[0] + N[1] + N[2] + N[3]);
  175.  
  176.             case (4): format(mString, sizeof(mString), "%d-%d-%d-%d",N[0]+40,N[1],N[2],N[3]),
  177.                       format(bString[0], 256, "%d", N[0]+40 + N[1] + N[2] + N[3]);
  178.  
  179.             case (5): format(mString, sizeof(mString), "%d+%d+%d*%d",N[0],N[1],N[2],N[3]),
  180.                       format(bString[0], 256, "%d", N[0] + N[1] + N[2] * N[3]);
  181.         }
  182.         format(bString[1], 256, "First to calculate {CFF55F}%s {FFFFFF}receives {D7FFB8}$%i {FFFFFF}and {D7FFB8}%i{FFFFFF} score.",mString, bMoney, bScore );
  183.         SendClientMessageToAll(~1, bString[1] );
  184.         bTest = 1;
  185.     }
  186.     else
  187.     {
  188.         switch(R2)
  189.         {
  190.             case (0):
  191.             {
  192.                 if(!strcmp(text, "?????"))
  193.                     memcpy(bString[0], iMessages[random(mCount)], 0, 256, 256);
  194.                 else memcpy(bString[0], text, 0, 256, 256);
  195.                
  196.                 bTest = 2;
  197.             }
  198.  
  199.             case (1):
  200.             {
  201.                 bString[0][0] = '\0';
  202.                 for( new c; c < MAX_RANDOM; ++c)
  203.                 {
  204.                     bString[0][c] = random(2) ? ( '0' + random(9) ) : ( random(2) ? ( 'a' + random(26) ) : ( 'A' + random(26) ) );
  205.                 }
  206.                 bTest = 3;
  207.             }
  208.         }
  209.         format(bString[1], 256, "First to write {CFF55F}%s {FFFFFF}receives {D7FFB8}$%i {FFFFFF}and {D7FFB8}%i{FFFFFF} score.",bString[0], bMoney, bScore );
  210.         SendClientMessageToAll(~1, bString[1] );
  211.     }
  212. }
  213. EndReaction(playerid, action[])
  214. {
  215.     GivePlayerMoney(playerid, bMoney);
  216.     SetPlayerScore(playerid, GetPlayerScore(playerid) + bScore);
  217.    
  218.     format(bString[1], 256, "Player {58CC00}%s{FFFFFF} %s {58CC00}%s{FFFFFF} first and won {D7FFB8}$%i {FFFFFF}and {D7FFB8}%i{FFFFFF} score.", Name(playerid), action, bString[0], bMoney, bScore);
  219.     for( new i = 0; i != MAX_PLAYERS; ++i){
  220.         if(i != playerid){
  221.             if(IsPlayerConnected(i)){
  222.                 SendClientMessage(i, ~1, bString[1] );
  223.             }
  224.         }
  225.     }
  226.  
  227.     format(bString[1], 256, "You were the first one to write the answer, you won {D7FFB8}$%i {FFFFFF}and {D7FFB8}%i{FFFFFF} score.", bMoney, bScore);
  228.     SendClientMessage(playerid, ~1, bString[1]);
  229.  
  230.     bTest = 0;
  231.     Won = true;
  232.     Winner = Name(playerid);
  233. }
  234. public OnPlayerText(playerid, text[])
  235. {
  236.     if(bTest){
  237.         if(strlen(bString[0])){
  238.             if(!strcmp(text, bString[0], false)){
  239.                 switch(bTest)
  240.                 {
  241.                     case (1): EndReaction(playerid, "calculated");
  242.                     case (2): EndReaction(playerid, "wrote");
  243.                     case (3): EndReaction(playerid, "was faster at writing");
  244.                 }
  245.                 return 0;
  246.             }
  247.         }
  248.     }
  249.     else
  250.     {
  251.         if(!strcmp(text, bString[0], false) && Won){
  252.        
  253.             if(!strcmp(Winner, Name(playerid), false)) bString[1] = "You already answered!";
  254.             else format(bString[1], 256, "Too late! {58CC00}%s{FFFFFF} answered first!", Winner );
  255.            
  256.             SendClientMessage(playerid, ~1, bString[1]);
  257.             return 0;
  258.         }
  259.     }
  260.    
  261.     return 1;
  262. }
  263.  
  264. Name(i){
  265.     new n[24];
  266.     GetPlayerName(i,n,24);
  267.     return n;
  268. }
  269. stock
  270. RandomEx( Min, Max ){
  271.     new Random;
  272.     Random = Min + random( Max );
  273.     return Random;
  274. }
  275. #undef INTERVAL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement