Reaction Test tutorials
#1

Anybody got a tut for reaction test system ?? dont comment saying that i should search on forums and on ****** cause the FS's on ****** doesnt work and i didnt find tutorials in the tutorials section so.... can anybody teach me how to ?
Reply
#2

Use arrays for this simple purpose.

Here is an example.
pawn Код:
enum e_REACTION_TEST
{
    rtQuestion[150],
    rtAnswer[150]
};
new const gReactionTest[][e_REACTION_TEST] =
{
    {"The first one to write '12345' wins $5000.",  "12345"},
    {"The first one to write 'Test' wins $5000.",  "Test"},
    {"The first one to write weapon id of 'Sniper Rifle' wins $5000.",  "34"}
};
Just like before, you need to check for the rtAnswer in OnPlayerText. If the player's text match with rtAnswer, he wins!
Reply
#3

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Use arrays for this simple purpose.

Here is an example.
pawn Код:
enum e_REACTION_TEST
{
    rtQuestion[150],
    rtAnswer[150]
};
new const gReactionTest[][e_REACTION_TEST] =
{
    {"The first one to write '12345' wins $5000.",  "12345"},
    {"The first one to write 'Test' wins $5000.",  "Test"},
    {"The first one to write weapon id of 'Sniper Rifle' wins $5000.",  "34"}
};
Just like before, you need to check for the rtAnswer in OnPlayerText. If the player's text match with rtAnswer, he wins!
The only thing i know about creating a reaction test is having this array
Код:
new
        xCharacters[][] =
        {
            "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
                "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
            "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
                "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
            "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
        },
but the other things in the FS created by RyDer i cant understand, i kinda need someone to explain it to me so i can edit it. Here's the FS anyways and u can add me on skype so we can talk
http://pastebin.com/5f0pjpWB
Reply
#4

Quote:
Originally Posted by YoussefHammad
Посмотреть сообщение
The only thing i know about creating a reaction test is having this array
Код:
new
        xCharacters[][] =
        {
            "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
                "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
            "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
                "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
            "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
        },
but the other things in the FS created by RyDer i cant understand, i kinda need someone to explain it to me so i can edit it. Here's the FS anyways and u can add me on skype so we can talk
http://pastebin.com/5f0pjpWB
You can also make a manual version, here is my code:
pawn Код:
#include <a_samp>

enum e_REACTION_TEST
{
    rtQuestion[150],
    rtAnswer[150],
    rtMoney,
    rtScore,
};
new const gReactionTest[][e_REACTION_TEST] =
{
    {"The first one to write '12345' wins $5000.", "12345", 5000, 0},
    {"The first one to write 'Test' wins $5000.", "Test", 5000, 0},
    {"The first one to write weapon id of 'Sniper Rifle' wins $5000.", "34", 5000, 0}
};

new rtTimer;
new rtId;
new bool:rtActive;

public OnFilterScriptInit()
{
    rtTimer = SetTimer("OnReactionTest", 2 * 60 * 1000, true);
    rtId = 0;
    return 1;
}

public OnFilterScriptExit()
{
    KillTimer(rtTimer);
    return 1;
}

forward OnReactionTest();
public  OnReactionTest()
{
    SendClientMessageToAll(0x00FF00FF, gReactionTest[rtId][rtQuestion]);
    rtActive = true;
}

public OnPlayerText(playerid, text[])
{
    if (rtActive)
    {
        if (! strcmp(text, gReactionTest[rtId][rtAnswer]))
        {
            new name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, MAX_PLAYER_NAME);
           
            new buf[150];
            strcat(buf, name);
            strcat(buf, "has won the reaction test.");
            SendClientMessageToAll(0x00FF00FF, buf);
           
            format(buf, sizeof(buf), "You have won the reaction test. [+$%i and +%i score]", gReactionTest[rtId][rtMoney], gReactionTest[rtId][rtScore]);
            SendClientMessage(playerid, 0xFFFF00FF, buf);

            GivePlayerMoney(playerid, gReactionTest[rtId][rtMoney]);
            SetPlayerScore(playerid, GetPlayerScore(playerid) + gReactionTest[rtId][rtScore]);

            rtId++;
            if (rtId >= sizeof(gReactionTest))
            {
                rtId = 0;
                rtActive = false;
            }
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by YoussefHammad
Посмотреть сообщение
The only thing i know about creating a reaction test is having this array
Код:
new
        xCharacters[][] =
        {
            "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
                "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
            "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
                "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
            "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
        },
but the other things in the FS created by RyDer i cant understand, i kinda need someone to explain it to me so i can edit it. Here's the FS anyways and u can add me on skype so we can talk
http://pastebin.com/5f0pjpWB
The array stores the characters that can be part of the random word. This is what creates the word:
pawn Код:
Loop(x, xLength) format(xChars, sizeof(xChars), "%s%s", xChars, xCharacters[random(sizeof(xCharacters))][0]);
The loop statement is a definition of the for loop. In this case it loops through xLength times and adds random characters based on the characters in the array.
Reply
#6

Quote:
Originally Posted by Abagail
Посмотреть сообщение
The array stores the characters that can be part of the random word. This is what creates the word:
pawn Код:
Loop(x, xLength) format(xChars, sizeof(xChars), "%s%s", xChars, xCharacters[random(sizeof(xCharacters))][0]);
The loop statement is a definition of the for loop. In this case it loops through xLength times and adds random characters based on the characters in the array.
can you add me on skype ? i wanna learn how to make my own and how to actually get the loop to pick random characters , btw the length is not constant i'll try to make it from 1 to 10 for example. you can add me (itz_rbj)
Reply
#7

https://sampforum.blast.hk/showthread.php?pid=3614620#pid3614620
Reply
#8

Thank you so much +REPPED . just a question, is there a way that i can make the length of your reaction test like from 2 characters to 12 ?
Reply
#9

Quote:
Originally Posted by YoussefHammad
Посмотреть сообщение
Thank you so much +REPPED . just a question, is there a way that i can make the length of your reaction test like from 2 characters to 12 ?
Yes, just increase the value of the definition MAX_LENGTH.
Reply
#10

Quote:
Originally Posted by Kevln
Посмотреть сообщение
Yes, just increase the value of the definition MAX_LENGTH.
every reaction test that comes has 10 characters as defined in MAX_LENGTH so if i increase it the length will still be constant. i want to make a range from 1 character to 12 characters . its supposed to pick a random length everytime before it picks random characters , after the length is picked the characters are randomly chosen according to the chosen length , u get me ?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)