Looping problem!
#2

Like that, it will send the message as many times as the online players are.

pawn Код:
if(gminutes == 11 && gseconds == 0)
{
    new winner = INVALID_PLAYER_ID;
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(LottoPurchased[i] == true && LottoNumber[i] == RandomNumber)
            {
                winner = i;
                GivePlayerMoney(i, CurrentJackpot);
            }
            LottoPurchased[i] = false;
            LottoNumber[i] = -1;
        }
    }
    if (winner != INVALID_PLAYER_ID) format(string, sizeof(string), "winning num is %i, %s(%d) has won the lottery of $%i", RandomNumber , GetName(winner), winner, Jackpot);
    else format(string, sizeof(string), "winning num is %i, Nobody has won the lottery of $%i", RandomNumber , Jackpot);
    SendClientMessageToAll(-1, string);
    Jackpot = jackrand;
    RandomNumber = numrand;
}
Keep in mind though that if more than 1 player has got the correct number, it will say the winner is the player with the highest ID.
Reply


Messages In This Thread
Looping problem! - by AnonScripter - 08.06.2014, 19:14
Re: Looping problem! - by Konstantinos - 08.06.2014, 19:30
Re: Looping problem! - by AnonScripter - 08.06.2014, 20:06

Forum Jump:


Users browsing this thread: 1 Guest(s)