08.06.2014, 19:14
pawn Код:
if(gminutes == 11 && gseconds == 0)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(LottoPurchased[i] == true && LottoNumber[i] == RandomNumber)
{
GivePlayerMoney(i, CurrentJackpot);
format(string, sizeof(string), "winning num is %i, %s(%d) has won the lottery of $%i", RandomNumber , GetName(i), i, Jackpot);
}
else
{
format(string, sizeof(string), "winning num is %i, Nobody has won the lottery of $%i", RandomNumber , Jackpot);
}
LottoPurchased[i] = false;
LottoNumber[i] = -1;
}
SendClientMessageToAll(-1, string);
Jackpot = jackrand;
RandomNumber = numrand;
}
/lotto [random num]
on OnGameModeinIt i have a random number to win the lotto. so if the player is lucky and choosed this num, he's the winner.
i don't know why this only works for the last player id in the server.
example: if there are 4 players in the server
so ID 0,1,2,3 in the server
and each of them did /lotto
if ID 3 is the winner, on 11 oclock he will get the money with a message to all:
"winning num is %i, %s(%d) has won the lottery of $%i"
if someone else below this ID like (0,1,2) is the winner, he will get the money with a message to all:
"winning num is %i, Nobody has won the lottery of $%i"
can somebody tell me why ?