Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if defined x
- |===========================================|
- | Reaction Tests by Zh3r0 |
- |-------------------------------------------|
- | Creation date: May, 06, 2011 |
- | |
- | Type in console !start to start a test |
- | |
- | Please keep the credits! |
- |===========================================|
- #endif
- #include <a_samp>
- #define INTERVAL \
- (3 * 60 * 1_000)
- #define MAX_RANDOM \
- 15
- #define MAX_MESSAGES \
- 25
- new bTest, bMoney, bScore, bString[2][256], bool:Won, Winner[MAX_PLAYER_NAME], mString[30], Timer,
- iMessages[MAX_MESSAGES][129], mCount = 0;
- AddNewMessage(msg[])
- {
- memcpy(iMessages[mCount], msg, 0, 129, 129),
- mCount++;
- if(mCount >= MAX_MESSAGES){
- print("WARNING!! YOU EXCEEDED THE LIMIT OF "#MAX_MESSAGES" MESSAGES!\n\n\n");}
- }
- public OnFilterScriptInit()
- {
- AddNewMessage("This server rocks!!!");
- AddNewMessage("We love to entertain you");
- AddNewMessage("3v3RY0n3 l1k32 l337!!");
- AddNewMessage("7hIz 73X7 iZ h4Rd 70 wRi73!" );
- AddNewMessage("|-|4><0.-3.-2 |\\/||_|57 |)13");
- AddNewMessage("asdasdasd");
- printf("\n\n\
- |===========================================|\n\
- | Reaction Tests by Zh3r0 |\n\
- |-------------------------------------------|\n\
- | Creation date: May, 06, 2011 |\n\
- | |\n\
- | Type in console !help to more info |\n\
- | Loaded %d messages |\n\
- | |\n\
- | Please keep the credits! |\n\
- |===========================================|", mCount);
- Timer = SetTimerEx(#StartReaction, INTERVAL, 1, "dd", random(2), random(2));
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SendClientMessage(playerid, ~1, "This server uses {CFF55F}Reaction Tests{FFFFFF} by {CFF55F}Zh3r0{FFFFFF}! Wait for them to appear!");
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- if(!strcmp(cmd, "!help", .length = 5))
- {
- print("\n\n\
- |===========================================|\n\
- | Reaction Tests by Zh3r0 |\n\
- |-------------------------------------------|\n\
- | Type /start in-game logged as admin |\n\
- | to initiate a reaction test! |\n\
- | Type in console !showmsgs to list the |\n\
- | messages created. |\n\
- |===========================================|\n\n\n");
- return 1;
- }
- if(!strcmp(cmd, "!showmsgs", .length = 9))
- {
- print("\n\n\nDisplaying created messages:\n-----------------------\n");
- for( new m; m < mCount; m++)
- {
- print(iMessages[m]);
- }
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/start", true, 6))
- {
- if(IsPlayerAdmin(playerid))
- {
- if((cmdtext[6] != ' ') || (cmdtext[7] == EOS))
- return SendClientMessage(playerid, ~1, "USAGE: {C3C3C3}/start math/message [text]/reaction/random");
- if(!strcmp(cmdtext[7], "math"))
- {
- StartReaction(0, 0);
- SendClientMessage(playerid, ~1, "You started the {CFF55F}Math Reaction Test");
- }
- else if(!strcmp(cmdtext[7], "message", true, 7))
- {
- if(cmdtext[14] == ' ' || cmdtext[15 || 14] != EOS)
- StartReaction(1, 0, cmdtext[15]);
- else if( cmdtext[15] >= EOS )
- StartReaction(1, 0);
- SendClientMessage(playerid, ~1, "You started the {CFF55F}Message Reaction Test");
- }
- else if(!strcmp(cmdtext[7], "reaction"))
- {
- StartReaction(1, 1);
- SendClientMessage(playerid, ~1, "You started the {CFF55F}Reaction Test");
- }
- else if(!strcmp(cmdtext[7], "random"))
- {
- KillTimer(Timer);
- StartReaction(random(2), random(2));
- Timer = SetTimerEx(#StartReaction, INTERVAL, 1, "dd", random(2), random(2) );
- }
- else return SendClientMessage(playerid, ~1, "USAGE: {C3C3C3}/start math/message [text]/reaction");
- }else return 0;
- return 1;
- }
- return 0;
- }
- StartReaction( R1 = 2, R2 = 2, text[] = "?????")
- {
- if(!Won){
- switch(bTest)
- {
- case (1): format(bString[1], 256, "Nobody was smart enough to calculate {CFF55F}%s{FFFFFF}. The answer was {CFF55F}%s{FFFFFF}.", mString, bString[0]);
- case (2): format(bString[1], 256, "Nobody wrote {CFF55F}%s{FFFFFF} in time!", bString[0]);
- case (3): format(bString[1], 256, "Nobody was fast enough to write {CFF55F}%s{FFFFFF} in time!", bString[0]);
- }
- if(strlen(bString[1]))SendClientMessageToAll(~1, bString[1]);
- }
- bString[0][0] = EOS;
- bString[1][0] = EOS;
- Winner[0] = EOS;
- mString[0] = EOS;
- bMoney = RandomEx(.Min = 9000, .Max = 7000),
- bScore = RandomEx(.Min = 96, .Max = 120);
- if(!R1)
- {
- new
- N[4];
- for(new n = 0; n != 4; n++) {N[n] = 15 + random(50);}
- switch(random(6))
- {
- case (0): format(mString, sizeof(mString), "%d+%d-%d-%d",N[0],N[1],N[2],N[3]),
- format(bString[0], 256, "%d", N[0] + N[1] - N[2] - N[3]);
- case (1): format(mString, sizeof(mString), "%d-%d+%d-%d",N[0]+40,N[1],N[2],N[3]),
- format(bString[0], 256, "%d", N[0]+40 - N[1] + N[2] - N[3]);
- case (2): format(mString, sizeof(mString), "%d-%d+%d+%d",N[0]+40,N[1],N[2],N[3]),
- format(bString[0], 256, "%d", N[0]+40 - N[1] + N[2] + N[3]);
- case (3): format(mString, sizeof(mString), "%d+%d+%d+%d",N[0],N[1],N[2],N[3]),
- format(bString[0], 256, "%d", N[0] + N[1] + N[2] + N[3]);
- case (4): format(mString, sizeof(mString), "%d-%d-%d-%d",N[0]+40,N[1],N[2],N[3]),
- format(bString[0], 256, "%d", N[0]+40 + N[1] + N[2] + N[3]);
- case (5): format(mString, sizeof(mString), "%d+%d+%d*%d",N[0],N[1],N[2],N[3]),
- format(bString[0], 256, "%d", N[0] + N[1] + N[2] * N[3]);
- }
- format(bString[1], 256, "First to calculate {CFF55F}%s {FFFFFF}receives {D7FFB8}$%i {FFFFFF}and {D7FFB8}%i{FFFFFF} score.",mString, bMoney, bScore );
- SendClientMessageToAll(~1, bString[1] );
- bTest = 1;
- }
- else
- {
- switch(R2)
- {
- case (0):
- {
- if(!strcmp(text, "?????"))
- memcpy(bString[0], iMessages[random(mCount)], 0, 256, 256);
- else memcpy(bString[0], text, 0, 256, 256);
- bTest = 2;
- }
- case (1):
- {
- bString[0][0] = '\0';
- for( new c; c < MAX_RANDOM; ++c)
- {
- bString[0][c] = random(2) ? ( '0' + random(9) ) : ( random(2) ? ( 'a' + random(26) ) : ( 'A' + random(26) ) );
- }
- bTest = 3;
- }
- }
- format(bString[1], 256, "First to write {CFF55F}%s {FFFFFF}receives {D7FFB8}$%i {FFFFFF}and {D7FFB8}%i{FFFFFF} score.",bString[0], bMoney, bScore );
- SendClientMessageToAll(~1, bString[1] );
- }
- }
- EndReaction(playerid, action[])
- {
- GivePlayerMoney(playerid, bMoney);
- SetPlayerScore(playerid, GetPlayerScore(playerid) + bScore);
- 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);
- for( new i = 0; i != MAX_PLAYERS; ++i){
- if(i != playerid){
- if(IsPlayerConnected(i)){
- SendClientMessage(i, ~1, bString[1] );
- }
- }
- }
- 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);
- SendClientMessage(playerid, ~1, bString[1]);
- bTest = 0;
- Won = true;
- Winner = Name(playerid);
- }
- public OnPlayerText(playerid, text[])
- {
- if(bTest){
- if(strlen(bString[0])){
- if(!strcmp(text, bString[0], false)){
- switch(bTest)
- {
- case (1): EndReaction(playerid, "calculated");
- case (2): EndReaction(playerid, "wrote");
- case (3): EndReaction(playerid, "was faster at writing");
- }
- return 0;
- }
- }
- }
- else
- {
- if(!strcmp(text, bString[0], false) && Won){
- if(!strcmp(Winner, Name(playerid), false)) bString[1] = "You already answered!";
- else format(bString[1], 256, "Too late! {58CC00}%s{FFFFFF} answered first!", Winner );
- SendClientMessage(playerid, ~1, bString[1]);
- return 0;
- }
- }
- return 1;
- }
- Name(i){
- new n[24];
- GetPlayerName(i,n,24);
- return n;
- }
- stock
- RandomEx( Min, Max ){
- new Random;
- Random = Min + random( Max );
- return Random;
- }
- #undef INTERVAL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement