Making a command throw random numbers
#1

So, I was wondering

How would I go about making a lottery system that lets the users actually pick there numbers

then when it draws every hour.

it displays those numbers which will be 10 random numbers

and players get money based on how many numbers they picked correct.


Example.

Lotto Winning Numbers are: 7, 25, 13, 11, 67, 33, 56, 23, 17, 05

If player a for instance only got 2 numbers.

He might get 20 bucks

Whereas if Player B got all 10 numbers correct.

He has just one the jackpot of 1000
Reply
#2

pawn Код:
new Playernumber[MAX_PLAYERS][10];
new LotteryNumber[10];
new Correctnumbers[MAX_PLAYERS];

forward OnLottery();
public OnLottery()
{
    for(new i = 0; i < 10; i++)
    {
        LotteryNumber[i] = random(100);
    }
    return 1;
}

forward LotteryCheck();
public LotteryCheck()
{   for(new i = 0; i < MAX_PLAYERS; i++)
    {
        for(new a = 0; a < MAX_PLAYERS; a++)
        if(Playernumber[i][a] == LotteryNumber[1])
        {
            Correctnumbers[i]++;
        }
        switch(Correctnumbers[i])
        {
            case 1:
            {
                GivePlayerMoney(i, 20)
            }
            case 2:
            {
                GivePlayerMoney(i, 50)
            }
            case 3:
            {
                GivePlayerMoney(i, 100)
            }
            case 4:
            {
                GivePlayerMoney(i, 200)
            }
            case 5:
            {
                GivePlayerMoney(i, 300)
            }
            case 6:
            {
                GivePlayerMoney(i, 400)
            }
            case 7:
            {
                GivePlayerMoney(i, 500)
            }
            case 8:
            {
                GivePlayerMoney(i, 600)
            }
            case 9:
            {
                GivePlayerMoney(i, 700)
            }
            case 10:
            {
                GivePlayerMoney(i, 1000)
            }
        }

    }
    return 1;
}
Try something like this.
Reply
#3

Awesome, I'll try it out when I get home. Thanks bud!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)