reactiontest -
Jay. - 27.08.2010
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
Re: reactiontest -
Jay. - 27.08.2010
Anyone,
Sorry for bump
Re: reactiontest -
Jay. - 27.08.2010
Sorry but can someone answer me
Re: reactiontest -
Mauzen - 27.08.2010
You have to begin here:
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
Re: reactiontest -
Jay. - 27.08.2010
Quote:
Originally Posted by Mauzen
You have to begin here:
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!
Re: reactiontest -
Jay. - 27.08.2010
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.
Re: reactiontest -
Jay. - 28.08.2010
Bump, I've slept over it.
Re: reactiontest -
Jay. - 28.08.2010
Dam does anyone no my problem?
Re: reactiontest -
Mauzen - 28.08.2010
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))
Re: reactiontest -
Jay. - 28.08.2010
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