Lottery problem
#4

I found your problem.
pawn Код:
// ---
    foreach(Player, i)
    {
        GetPlayerName(i, name, sizeof(name));
        if(PlayerInfo[i][pLottoNum] == LottoNum)
        {
            LottoNum = 0;
            format(string, sizeof(string), "Congratulations! You have won the lottery of {FFFFFF}$%d.", LottoPrize);
            SCM(i, COLOR_GREY, string);
            format(string, sizeof(string), "Congratulations to %s! He has won the lottery of $%d!", RPN(i), LottoPrize);
            SCMTA(COLOR_ORANGE, string);
            GiveZaiatMoney(i, LottoPrize);
            LottoPrize = 0;
        }
        else
        {
            LottoNum = 0; // This
            SCM(i, COLOR_GREY, "You haven't won the lottery! Better luck next time.");
        }
        PlayerInfo[i][pLottoNum] = 0;
    }
Let's say there are 5 players online and the winner is id 4. It checks if ID 0's pLottoNum is equal to LottoNum. If it's not, it calls the else statement and sets LottoNum to 0. Then it checks if ID 1's pLottoNum is equal to LottoNum which is 0 and it's equal, so the winner is ID 1.

I'd use it like that:
pawn Код:
forward Lottery(playerid);
public Lottery(playerid)
{
    new name[MAX_PLAYER_NAME], string[256];
    format(string, sizeof(string), "The lottery winning number is %d!",LottoNum);
    SCMTA(COLOR_ORANGE, string);
    foreach(Player, i)
    {
        GetPlayerName(i, name, sizeof(name));
        if(PlayerInfo[i][pLottoNum] == LottoNum)
        {
            format(string, sizeof(string), "Congratulations! You have won the lottery of {FFFFFF}$%d.", LottoPrize);
            SCM(i, COLOR_GREY, string);
            format(string, sizeof(string), "Congratulations to %s! He has won the lottery of $%d!", RPN(i), LottoPrize);
            SCMTA(COLOR_ORANGE, string);
            GiveZaiatMoney(i, LottoPrize);
            LottoNum = 0;
        }
        else SCM(i, COLOR_GREY, "You haven't won the lottery! Better luck next time.");
        PlayerInfo[i][pLottoNum] = 0;
    }
    LottoPrize = 0;
    return 1;
}
Reply


Messages In This Thread
Lottery problem - by L.Hudson - 17.03.2013, 19:24
Re: Lottery problem - by mastermax7777 - 17.03.2013, 19:59
Re: Lottery problem - by stabker - 17.03.2013, 20:12
Re: Lottery problem - by Konstantinos - 17.03.2013, 20:18
Re: Lottery problem - by L.Hudson - 17.03.2013, 20:44

Forum Jump:


Users browsing this thread: 1 Guest(s)