08.06.2014, 19:30
Like that, it will send the message as many times as the online players are.
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.
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;
}