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