Checking if no one's player-specific variable is equal to value
#10

okay, it means that we have to prioritize the lotto numbers first, then if there is not a winner by that number, we should start a new lottery by the players, so, I'll write a code here to do that.
PHP Code:
        LottoNum random(59);

        for(new 
0GetPlayerPoolSize(); <= ji++)
        {
            if(!
IsPlayerConnected(i)) continue;
            if(
LottoNumber[i] == LottoNum)
            {
                
// Get the player's name
                
GetPlayerName(iNamesizeof(Name));
                
                
format(Msgsizeof(Msg), "{FFFF00}LOTTO: Congratulations, you have won $%i in the lottery!"LottoPrize);
                
SendClientMessage(iCOLOR_WHITEMsg);
                
                
format(Msgsizeof(Msg), "{FFFF00}LOTTO: %s has won $%i in the lottery. Congratulations!"NameLottoPrize);
                
SendClientMessageToAll(COLOR_WHITEMsg);
                
GivePlayerMoney(iLottoPrize);

                
TotalWinners++;

                
LottoNumber[i] = 0;

                
//break; NO NEED, WILL CAUSE ISSUES
            
}
            else if(
LottoNumber[i] != && LottoNumber[i] != LottoNum && TotalWinners 0)
            {
                    
SendClientMessage(iCOLOR_WHITE"{FFFF00}LOTTO: Unfortunately you haven't won the lottery. Good luck next time!");
            }
            
//else return 0; NO NEED, THIS WILL STOP WHOLE FUNCTION
            
LottoNumber[i] = 0;
        }

        
LottoNum 0;

        if(
TotalWinners == 0//So if there is not a winner, start a second lottery.
        
{
            new 
winnerID random(GetPlayerPoolSize());
            while(
IsPlayerConnected(winnerID))
            {
                
winnerID random(GetPlayerPoolSize());
            }
            
GetPlayerName(winnerIDNamesizeof(Name));
            
            
format(Msgsizeof(Msg), "{FFFF00}LOTTO: Congratulations, you have won $%i in the lottery!"LottoPrize);
            
SendClientMessage(winnerIDCOLOR_WHITEMsg);
            
            
format(Msgsizeof(Msg), "{FFFF00}LOTTO: %s has won $%i in the lottery. Congratulations!"NameLottoPrize);
            
SendClientMessageToAll(COLOR_WHITEMsg);
            
GivePlayerMoney(winnerIDLottoPrize);
        }

        
LottoPrize 0
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 9 Guest(s)