reactiontest
#1

hey, I found a tutorial on how to make maths reaction tests but i want one on how to make random letter reaction tests.

Or if possible can anyone help me convert this i done from the tutorial into random letters?


http://pastebin.com/crtUxb6t

Thanks
Reply
#2

Anyone,

Sorry for bump
Reply
#3

Sorry but can someone answer me
Reply
#4

You have to begin here:

pawn Код:
new ContestAnswer = -1;
To use letters instead of numbers, this of course has to be a string. You can also define constant to set the max length.

pawn Код:
#define MAX_CONTESTWORD_LENGTH 6   //Set to whatever you want

new ContestAnswer[MAX_CONTESTWORD_LENGTH];


pawn Код:
if(strval(text) == ContestAnswer && ContestAnswer != -1)
This is the next thing you have to change. To compare if the string is the same, use strcmp.

pawn Код:
if(!strcmp(text, ContestAnswer, false))


If this is done, you just have to create a random string, instead of an random number.

pawn Код:
ContestAnswer = MINIMUM_VALUE + random(MAXIMUM_VALUE-MINIMUM_VALUE);
format(string,sizeof string,"A new contest has started. Whoever types %d first, wins $%d.",ContestAnswer,CONTEST_PRIZE);
Remove these lines, and replace them.

pawn Код:
randomletters(ContentAnswer);
format(string,sizeof string,"A new contest has started. Whoever types %s first, wins $%d.",ContestAnswer,CONTEST_PRIZE);
Randomletters is a function wrote by Finn I just found in the forum (https://sampforum.blast.hk/showthread.php?tid=159475):

pawn Код:
// By Finn
stock randomletters(string[], maxlen = sizeof(string))
{
    new i;
    while(i < maxlen)
    {
        if(random(2))
        {
            //upper
            string[i] = random(26) + 65;
        }
        else
        {
            //lower
            string[i] = random(26) + 97;
        }
        i++;
    }
    return 1;
}

With those few changes the contest should now work with letters instead of numbers.
But I ensure nothing, i did not test it
Reply
#5

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
You have to begin here:

pawn Код:
new ContestAnswer = -1;
To use letters instead of numbers, this of course has to be a string. You can also define constant to set the max length.

pawn Код:
#define MAX_CONTESTWORD_LENGTH 6   //Set to whatever you want

new ContestAnswer[MAX_CONTESTWORD_LENGTH];


pawn Код:
if(strval(text) == ContestAnswer && ContestAnswer != -1)
This is the next thing you have to change. To compare if the string is the same, use strcmp.

pawn Код:
if(!strcmp(text, ContestAnswer, false))


If this is done, you just have to create a random string, instead of an random number.

pawn Код:
ContestAnswer = MINIMUM_VALUE + random(MAXIMUM_VALUE-MINIMUM_VALUE);
format(string,sizeof string,"A new contest has started. Whoever types %d first, wins $%d.",ContestAnswer,CONTEST_PRIZE);
Remove these lines, and replace them.

pawn Код:
randomletters(ContentAnswer);
format(string,sizeof string,"A new contest has started. Whoever types %s first, wins $%d.",ContestAnswer,CONTEST_PRIZE);
Randomletters is a function wrote by Finn I just found in the forum (https://sampforum.blast.hk/showthread.php?tid=159475):

pawn Код:
// By Finn
stock randomletters(string[], maxlen = sizeof(string))
{
    new i;
    while(i < maxlen)
    {
        if(random(2))
        {
            //upper
            string[i] = random(26) + 65;
        }
        else
        {
            //lower
            string[i] = random(26) + 97;
        }
        i++;
    }
    return 1;
}

With those few changes the contest should now work with letters instead of numbers.
But I ensure nothing, i did not test it
Thanks alot realy!
Reply
#6

Aww i get these errors

pawn Код:
C:\Users\(lewis)\Desktop\New Folder (11)\EX-S.pwn(1399) : error 017: undefined symbol "ContentAnswer"
C:\Users\(lewis)\Desktop\New Folder (11)\EX-S.pwn(1412) : error 033: array must be indexed (variable "ContestAnswer")
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
Reply
#7

Bump, I've slept over it.
Reply
#8

Dam does anyone no my problem?
Reply
#9

Ah, found it. Pastebin just did not work for me.


ContestAnswer = -1;
Has to be
ContestAnswer = "";

Then add the string equivalent to the text check
if(!strcmp(text, ContestAnswer, false))
-->
if(!strcmp(text, ContestAnswer, false) && strlen(ContestAnswer))
Reply
#10

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Ah, found it. Pastebin just did not work for me.


ContestAnswer = -1;
Has to be
ContestAnswer = "";

Then add the string equivalent to the text check
if(!strcmp(text, ContestAnswer, false))
-->
if(!strcmp(text, ContestAnswer, false) && strlen(ContestAnswer))
Omg thanks so much again rly
all errors gone but i've tested it ingame and when a reaction starts i typed the number but i didn't show
the blabla has won the reaction test and received %6000
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)