Who type first winss....
#5

Quote:
Originally Posted by [HK]Ryder[AN]
Посмотреть сообщение
Use this code
pawn Код:
#include <a_samp>
 
#define COLOR_GREEN 0x00A800AA
 
new MinQuestionScore = 1;
new MaxQuestionScore = 7;
new RandomQuestionScore;
 
new QuestionStarted;
new Question[32];
 
new PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME];
 
forward SendQuestionForScore();
 
public OnFilterScriptInit()
{
        SetTimer("SendQuestionForScore", 240000, true);
        return 1;
}
 
public OnFilterScriptExit()
{
        return 1;
}
 
public SendQuestionForScore()
{
        new string[128];
        new qstring[32];
        RandomQuestionScore = MinQuestionScore+random(MaxQuestionScore-MinQuestionScore);
        format(qstring, sizeof(qstring), "%d%d%d%d%d%d%d%d", random(9), random(9), random(9), random(9), random(9), random(9), random(9), random(9));
        strmid(Question, qstring, false, strlen(qstring), 32);
    format(string, sizeof(string), "** Question: Are you still alive? **: The fastest who types %s will earn $%d,-!", qstring, RandomQuestionMoney);
        SendClientMessageToAll(COLOR_GREEN, string);
        QuestionStarted = 1;
        return 1;
}
 
public OnPlayerText(playerid, text[])
{
        if(QuestionStarted == 1 && strfind(text[0], Question, false) == 0)
        {
            new string[128];
                format(string, sizeof(string), "$$$ %s has won $%d,- by typing '%s' the fastest! $$$", PlayerName[playerid], RandomQuestionMoney, Question);
                SendClientMessageToAll(COLOR_GREEN, string);
                SetPlayerScore(playerid, GetPlayerScore(playerid) + RandomQuestionScore);
                QuestionStarted = 0;
                return 0;
        }
        return 1;
}
I'm gonna try that. But I have a question here I have already make my own return 0 at OnplayerCommandText but why after I typed the Words correctly it shows nothing?

pawn Код:
/*

#if !defined Loop
#define Loop(%0,%1) \
    for(new %0 = 0; %0 != %1; %0++)
#endif

#if !defined function
#define function%0(%1) \
    forward%0(%1); public%0(%1)
#endif

#if !defined PURPLE
#define PURPLE \
    0xBF60FFFF
#endif

#if !defined GREEN
#define GREEN \
    0x94D317FF
#endif

#if !defined TIME
#define TIME \
    180000
#endif

new
    xCharacters[][] =
    {
        "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
        "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
        "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
        "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
        "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
    },
    xChars[16] = "",
    xReactionTimer,
    xCash,
    xScore,
    bool: xTestBusy
;

public OnFilterScriptInit()
{
    xReactionTimer = SetTimer("xReactionTest", TIME, 1);
    return 1;
}

public OnFilterScriptExit()
{
    KillTimer(xReactionTimer);
    return 1;
}

public OnPlayerText(playerid, text[])
{
    switch(xTestBusy)
    {
        case true:
        {
            if(!strcmp(xChars, text, false))
            {
                new
                    string[128],
                    pName[MAX_PLAYER_NAME]
                ;
                GetPlayerName(playerid, pName, sizeof(pName));
                format(string, sizeof(string), "« \%s\" has won the reaction test. »", pName);
                SendClientMessageToAll(GREEN, string);
                format(string, sizeof(string), "« You have earned $%d + %d score points. »", xCash, xScore);
                SendClientMessage(playerid, GREEN, string);
                GivePlayerMoney(playerid, xCash);
                SetPlayerScore(playerid, GetPlayerScore(playerid) + xScore);
                xReactionTimer = SetTimer("xReactionTest", TIME, 1);
                xTestBusy = false;
            return 0;
            }
        }
    }
    return 1;
}

function xReactionProgress()
{
    switch(xTestBusy)
    {
        case true:
        {
            new
                string[128]
            ;
            format(string, sizeof(string), "« No-one won the reaction-test. New one starting in %d minutes. »", (TIME/60000));
            SendClientMessageToAll(PURPLE, string);
            xReactionTimer = SetTimer("xReactionTest", TIME, 1);
        }
    }
    return 1;
}

function xReactionTest()
{
    new
        xLength = (random(8) + 2),
        string[128]
    ;
    xCash = (random(10000) + 20000);
    xScore = (random(2)+1);
    format(xChars, sizeof(xChars), "");
    Loop(x, xLength) format(xChars, sizeof(xChars), "%s%s", xChars, xCharacters[random(sizeof(xCharacters))][0]);
    format(string, sizeof(string), "« Who first types %s wins $%d + %d score points. »", xChars, xCash, xScore);
    SendClientMessageToAll(PURPLE, string);
    KillTimer(xReactionTimer);
    xTestBusy = true;
    SetTimer("xReactionProgress", 30000, 0);
    return 1;
}
Reply


Messages In This Thread
Who type first winss.... - by kbalor - 30.08.2012, 14:30
Re: Who type first winss.... - by Dan. - 30.08.2012, 14:32
Re: Who type first winss.... - by C00K13M0N$73R - 30.08.2012, 14:32
Re: Who type first winss.... - by [HK]Ryder[AN] - 30.08.2012, 15:32
Re: Who type first winss.... - by kbalor - 30.08.2012, 15:50
Re: Who type first winss.... - by romas3110 - 30.08.2012, 16:05

Forum Jump:


Users browsing this thread: 1 Guest(s)