You can use a DB to store the people who entered the lottery like this:
DB-NPC: Lottery
PHP Code:
// Adds account to the list of lottery entries
public function addAccount(acct) {
if (inLottery(acct)) {
// Already in lottery
return false;
} else {
// Add to lottery
this.lottery.add(acct);
this.trigger("update"); // Force-saves DB
return true;
}
}
// Checks if acct is entered in the lottery
public function inLottery(acct) {
return (acct in this.lottery);
}
// Clears accounts entered in the lottery
public function clearAccounts() {
this.lottery = "";
}
// Picks a random person entered in the lottery.
public function pickLotteryWinner() {
return this.lottery[int(random(0, this.lottery.size()))];
}
To add a player to the lottery use:
Lottery.addAccount(player.account);
To check if a player is in the lottery use:
if (Lottery.inLottery(player.account))
To pick a winner use:
temp.winner = Lottery.pickLotteryWinner();
To clear the lottery entries:
Lottery.clearAccounts();
You don't have to store any information in the player's or server flags, you can also expand upon this and add/update/store the "Jackpot" amount in it as well but I'm not going to do everything for you.