07.11.2011, 17:55
I typed the randoms letters, but I didn't win anything. Also, it didn't appear message that I won.
What is wrong with this code?
Something is wrong with OnPlayerText.
Moreover, how can I change the stock except for random letters to have random letters+ numbers.
For example to appears like "f4Sue2Ro"
What is wrong with this code?
pawn Код:
#include <a_samp>
#define CONTEST_PRIZE 5000
#define MAX_CONTESTWORD_LENGTH 6 //Set to whatever you want
new ContestAnswer[MAX_CONTESTWORD_LENGTH],bool:StartTest;
forward NewContest();
stock randomletters(string[], maxlen = sizeof(string))
{
new i;
while(i < maxlen)
{
if(random(2))
string[i] = random(26) + 65; //upper
else
string[i] = random(26) + 97; //lower
i++;
}
return 1;
}
public OnFilterScriptInit()
{
SetTimer("NewContest",180000,true);
return 1;
}
public OnPlayerText(playerid, text[])
{
if(StartTest)
{
if(!strcmp(text,ContestAnswer))
{
OnPlayerWinContest(playerid);
return 0;
}
}
return 1;
}
public NewContest()
{
new string[128];
randomletters(ContestAnswer);
format(string,sizeof string,"A new contest has started. Whoever types %s first, wins $%d.",ContestAnswer,CONTEST_PRIZE);
SendClientMessageToAll(0x00FFFFFF,string);
StartTest=true;
return 1;
}
stock OnPlayerWinContest(playerid)
{
StartTest=false;
new pName[MAX_PLAYER_NAME],string[128];
GetPlayerName(playerid,pName,sizeof pName);
format(string,sizeof string,"Player %s has won the contest and has won %d!",pName,CONTEST_PRIZE);
SendClientMessageToAll(0x00FFFFFF,string);
GivePlayerMoney(playerid,CONTEST_PRIZE);
ContestAnswer="";
return 1;
}
Moreover, how can I change the stock except for random letters to have random letters+ numbers.
For example to appears like "f4Sue2Ro"