Reaction Help
#1

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?
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;
}
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"
Reply


Messages In This Thread
Reaction Help - by Kostas' - 07.11.2011, 17:55
Re: Reaction Help - by RyDeR` - 07.11.2011, 17:57
Re: Reaction Help - by Kostas' - 07.11.2011, 19:04
Re: Reaction Help - by RyDeR` - 07.11.2011, 19:06
Re: Reaction Help - by Kostas' - 07.11.2011, 20:15
Re: Reaction Help - by Jefff - 07.11.2011, 23:14
Re: Reaction Help - by Kostas' - 08.11.2011, 12:48

Forum Jump:


Users browsing this thread: 1 Guest(s)