[Help]: GivePlayerMoney
#1

I am currently editing a lottery system.

I want a players be rewarded equally. (Example: prize $5000 given to five people $1000 per one people).

Edit: I try use GivePlayerMoney(i, Jackpot/i); but have bug: players hasn't money and lottery number not reset to 0.

pawn Код:
//Original code from The Godfather Gamemode.
public Lotto(number)
{
    new JackpotFallen = 0;
    new string[128];
    new winnername[MAX_PLAYER_NAME];
    format(string, sizeof(string), "Lottery News: Today the Winning Number has fallen on: %d.", number, Jackpot);
    OOCOff(-1, string);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pLottoNr] > 0)
            {
                if(PlayerInfo[i][pLottoNr] == number)
                {
                    JackpotFallen = 1;
                    GetPlayerName(i, winnername, sizeof(winnername));
                    format(string, sizeof(string), "Lottery News: %s has won the Jackpot of $%d with his Lottery Ticket.", winnername, Jackpot);
                    OOCOff(-1, string);
                    format(string, sizeof(string), "* You have Won $%d with your Lottery Ticket.", Jackpot);
                    SendClientMessage(i, COLOR_YELLOW, string);
                    ConsumingMoney[i] = 1;
                    GivePlayerMoney(i, Jackpot);
                }
                else
                {
                    SendClientMessage(i, COLOR_LIGHTBLUE, "* You haven't won with your Lottery Ticket this time.");
                }
            }
            PlayerInfo[i][pLottoNr] = 0;
        }
    }
    if(JackpotFallen)
    {
        Jackpot = 1000;
        SaveStuff();
        format(string, sizeof(string), "Lottery News: The new Jackpot has been started with $%d.", Jackpot);
        OOCOff(-1, string);
    }
    else
    {
        new rand = random(100); rand += 50;
        Jackpot += rand;
        SaveStuff();
        format(string, sizeof(string), "Lottery News: The Jackpot has been raised to $%d.", Jackpot);
        OOCOff(-1, string);
    }
    return 1;
}
I'm sorry I'm not good at English. - I use ****** Translate.
Thank for all comments.

CMDX
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)