Code:
new playerNum[33]; // Global
public giveNum(id)
{
if(id>=1)
{
new number = random_num(1,32)
if(checkNum(number))
{
playerNum[id] = number;
} else {
giveNum(id)
}
return PLUGIN_HANDLED
}
new i,players[32],num
get_players(players,num)
for(i;i<num;i++)
{
new randomNum = random_num(1,32)
if(checkNum(randomNum))
{
playerNum[i] = randomNum;
} else {
giveNum(i) // Someone has the number, call the function again. Only for this player
}
}
}
public checkNum(number)
{
for(new i;i<sizeof(playerNum);i++) {
if(number == playerNum[i]) {
return 0;
} else {
return 1;
}
}
}
I think i'm making this way over complicated, but... This might, but probably wont, work.
Just call the function with id being zero.
__________________