New Mission
#8

I'm not saying this is first rate, but it does the job.. Edit the strings to suit your liking, add your own commands to the array at the top... It has a built in mechanism so you don't get the same command twice in a row.. The prize is currently 10k, change this too..

Ironically it's made up of the past 2 scripts I made stuck together..

pawn Код:
#include <a_samp>

new RandomCommands[][50] = { "/hi", "/lol" };
new Current, Next, Command = -1, string[128];
forward Reaction();

public OnFilterScriptInit()
{
    SetTimer("Reaction", 60000, 1);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(Command != -1)
    {
    if (strcmp(RandomCommands[Command], cmdtext, true) == 0)
    {
            format(string, sizeof(string), "ID %d typed %s the fastest!", playerid, RandomCommands[Command]);
            SendClientMessageToAll(0xFF00FFFF, string);
            GivePlayerMoney(playerid, 10000);
            Command = -1;
            return 1;
        }
    }
    return 0;
}

public Reaction()
{
    RandomCM();
    format(string, sizeof(string), "First to type %s wins a prize!", RandomCommands[Command]);
    SendClientMessageToAll(0xFF00FFFF, string);
    return 1;
}

stock RandomCM()
{
    Next = random(sizeof(RandomCommands));
    if(Next == Current) return RandomCM();
    else
    {
        Command = Next;
        Current = Next;
        return 1;
    }
}
EDIT: Wait, you want this for non commands?

This will do it for questions and answers:

pawn Код:
#include <a_samp>

#define PRIZE 10000
#define INTERVAL 60000 //time in ms

enum Questions {
    Question [128],
    Answer[50]
}

new RandomCommands[][Questions] = {
    { "Type cookies for free cookies", "cookies" },
    { "Type milk for free milk to go with the cookies", "milk" }
};

new Current, Next, Command = -1, string[128];
forward Reaction();

public OnFilterScriptInit()
{
    SetTimer("Reaction", INTERVAL, 1);
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(Command != -1)
    {
    if (strcmp(RandomCommands[Command][Answer], text, true) == 0)
    {
            format(string, sizeof(string), "ID %d typed %s the fastest and won %d!", playerid, RandomCommands[Command][Answer], PRIZE);
            SendClientMessageToAll(0xFF00FFFF, string);
            GivePlayerMoney(playerid, PRIZE);
            Command = -1;
        }
    }
}

public Reaction()
{
    RandomCM();
    SendClientMessageToAll(0xFF00FFFF, RandomCommands[Command][Question]);
    return 1;
}

stock RandomCM()
{
    Next = random(sizeof(RandomCommands));
    if(Next == Current) return RandomCM();
    else
    {
        Command = Next;
        Current = Next;
        return 1;
    }
}
eg. Questions could be.. "How many in a dozen?" and Answer could be "6"

Alternatively you could just do "Type fifty" and have the answer as "fifty" w/e floats your boat..
Reply


Messages In This Thread
New Mission - by Frikandel - 16.05.2009, 16:27
Re: New Mission - by miokie - 16.05.2009, 16:38
Re: New Mission - by Think - 16.05.2009, 16:43
Re: New Mission - by Frikandel - 16.05.2009, 17:17
Re: New Mission - by Rks25 - 16.05.2009, 17:20
Re: New Mission - by member - 16.05.2009, 17:42
Re: New Mission - by Frikandel - 16.05.2009, 17:52
Re: New Mission - by Weirdosport - 16.05.2009, 18:11
Re: New Mission - by Andom - 16.05.2009, 18:33
Re: New Mission - by Frikandel - 16.05.2009, 22:29

Forum Jump:


Users browsing this thread: 1 Guest(s)