I'm trying to match users inputted numbers to match an array(winning numbers) for a lottery game but I'm getting errors : How can I solve this?
"undeclared identifier"
uint8[] public numbers; // all numbers being stored in this array
mapping (uint8 => address payable[]) playersByNumber;
Function of setting the winning number.
function setWinNum(uint8 num1,uint8 num2,uint8 num3,uint8 num4,uint8 num5) public onlyOwner returns (uint8[5] memory ){
uint8[5] memory numsFixed = [num1, num2,num3,num4,num5];
// selectedNumber = num; // this works for single number.
return numsFixed;
}
Function to assign winning numbers.
function determineWinner() public {
require(msg.sender == owner);
require(state == LotteryState.SecondRound, "Admin please set to second round");
state = LotteryState.Finished;
uint8[5] memory winningNumbers = setWinNum(numsFixed); -- says undeclared identifier
// uint8 winningNumber = setWinNum(selectedNumber); works for single number.
officialWinner(winningNumbers[]);
selfdestruct(owner);
}
Function to distribute winnings
function officialWinner(uint8 winningNumber) private returns ( uint256 ) {
uint winnerCount = playersByNumber[winningNumber].length;
// require(winnerCount == 1);
if (winnerCount < 0){
ab;
}
// so if theres winners distribute the money
if (winnerCount > 0) {
uint256 balanceToDistribute = address(this).balance/(2*winnerCount);// this gets the contract balance , divide 2 becase its only giving half the bal. w/ the haf balnce x winners
for (uint i = 0; i<winnerCount; i++) {
require(i==0);
playersByNumber[winningNumber][i].transfer(balanceToDistribute);
lotteryHistory[lotteryId] = playersByNumber[winningNumber][i];
address winner = playersByNumber[winningNumber][i];
lastWinner = winner;
lastWinningAmount[winner] = balanceToDistribute;
lastWinnerAmount= lastWinningAmount[winner];
}