29.10.2019, 14:06
Well, first, use GetPlayerPoolSize instead of MAX_PLAYERS, no need to loop through whole 1000 player if they're not connected.
Second, you're making it correct, but return is extra, you don't need that. remove return from code.
so correct code looks like this
Second, you're making it correct, but return is extra, you don't need that. remove return from code.
so correct code looks like this
PHP Code:
new TotalWinners = 0;
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i)) continue; //make loop faster.
if(LottoNumber[i] != 0 && LottoNumber[i] != LottoNum) //check if they got a wrong number
{
SendClientMessage(i, COLOR_WHITE, "{FFFF00}LOTTO: Unfortunately you haven't won the lottery. Good luck next time!");
}
else
{
TotalWinners++; //so we got a one more winner
//Award
}
}
if(TotalWinners == 0) SendClientMessageToAll(-1, "nobody won");