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

I'm making a lottery system.
The way it should work is:

randomNumber chosen --> /lotto <number> <amount to bet> --> Lotto ends --> If player number is not random number --> loop until a player has the right number

However, I'm not sure how to loop until a player has the right number.

Code:
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(LottoNumber[i] == LottoNum)
		{
                  // Award player 
		}
		else
		    if(LottoNumber[i] != 0 && LottoNumber[i] != LottoNum)
		    	SendClientMessage(i, COLOR_WHITE, "{FFFF00}LOTTO: Unfortunately you haven't won the lottery. Good luck next time!");
			else return 0;
	}
The only way I could think of doing it is in the last condition. If the player doesn't have it, it adds to a variable and then checks if no one on the server has it.

For example:

Code:
wrongNumber++;

// check if the wrong number is equal to the number of participants in the lottery
// if so, choose another number and repeat
Finally, would this work? If not, why not and is there a better way?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 7 Guest(s)