Hello everyone,
I want to make a raffle program consisting of people selected from an excel table. I have done many things but the giveaway system is not working properly.
For example, let’s do a raffle in which 3 people from a list of 100 people will win. But the winner should not win again. So one person cannot win an award twice. I just couldn’t do this. Sorry for my bad english and terrible software knowledge. Thanks.
Here is the some part of the code
public void RandomFuncNew()//raffle is running...
{
WinnerId = Random.Range(1, i + 1);//a random person is selected from the Excel(.csv) table
Debug.Log(WinnerId);
Debug.Log(playerList.player[WinnerId - 1].name + " - " + playerList.player[WinnerId - 1].id);//Print the name and ID number of the selected person
}
public void RandomFunc()//Main func...
{
RandomFuncNew();
if(systemManager.Raffles.Count == 1)//The 1st draw is being held now.
{
if(WinnerExcept == true)//the chosen one should not win again
{
for(int c = 0; c < systemManager.Lines[0].GetComponent<LineManager>().WinnerNum; c++)//for example, let's have a winner list consisting of 3 people and repeat the cycle 3 times.
{
RandomFuncNew();
if(systemManager.Lines[0].GetComponent<LineManager>().WinnerNames.Contains(playerList.player[WinnerId - 1].name))
{
do
{
RandomFuncNew();
string WN = playerList.player[WinnerId - 1].name;
systemManager.Lines[0].GetComponent<LineManager>().WinnerNames[c] = WN;
} while (!systemManager.Lines[0].GetComponent<LineManager>().WinnerNames.Contains(playerList.player[WinnerId - 1].name));
}
}
}
}
}