no, i havnt tried debugging it. i dont know how to do tasks that advanced.
here is the db npc script
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()))];
}
here is whats in the npc that does it
PHP Code:
function onCreated(){
onUpdateText();
}
function onUpdateText(){
if(server.jackpot == 0){
this.chat = "The Current Jackpot Is 0 Gralats.";
return;
}
this.chat = "The Current Jackpot Is "@server.jackpot@" Gralats.";
}
function onPlayerchats(){
if(player.chat == "/Buy Ticket"){
if (Lottery.inLottery(player.account)){
player.chat = "I Have Already Purchased A Ticket!";
return;
}
if(player.rupees < 20){
player.chat = "I Dont Have Enough Money!";
}
if(player.rupees > 19){
player.chat = "I Brought A Lottery Ticket!";
Lottery.addAccount(player.account);
player.rupees -= 20;
server.jackpot += 20;
onUpdateText();
}
}
if(player.chat == "/Draw Lottery"){
if(clientr.isStaff){
onAwardWinner();
}
}
}
function onAwardWinner(){
server.winner = Lottery.pickLotteryWinner();
echo("Lottery: "@server.winner@" Has Won The Lottery! They Won: "@server.jackpot@" Gralats!");
findplayer(server.winner).chat = "I Just Won The Lottery! I Won "@server.jackpot@" Gralats!";
savelog2("Lottery.txt", server.winner@" Won The Lottery! They Won "@server.jackpot@" Gralats!");
server.jackpot = 0;
Lottery.clearAccounts();
onUpdateText();
}