Just a few things...//ENTER GEEK MODE
The names that appeared in the display were random. It loaded the entire list of possible entries
HTML Code:
temp.player = randomstring(this.db.vip_raffle);
Every time it was time to select a new person (every 5 seconds) it would use this function. As you can see, it's not in any specific order, if your name appeared more than once in the 60 minutes then you're lucky. There's no logic behind it, it's entirely random.
After each winner is drawn, it then keeps on that winner for 60 seconds and starts a new round. This is repeated till there are 10 winners. After 10 winners, the script destroys itself. (No way could I be on for 10 hours straight #life)
The winner is then removed from the list of other players.
HTML Code:
//Remove the player from the list
DB_VIP_Raffle.vip_raffle.remove(temp.player);
//Load it again (we shouldn't have to, but why not)
this.db = ("DB_VIP_Raffle").link();
And this process is repeated.
Here are the winners if you're interested
HTML Code:
Time: Sat Aug 10 10:30:01 2013
VIP Prize added the item:Gun_M4_Gold x1 to offline that willy thing (iBurger) (Graal813945) - now has x1 of Gold M4. They did have 0. Reason: VIP for July 2013. Staff Account: No.
Time: Sat Aug 10 11:32:03 2013
VIP Prize added the item:Gun_M4_Gold x1 to offline BO$$ Johnny monkons troll arch (Monkons) (Graal821237) - now has x1 of Gold M4. They did have 0. Reason: VIP for July 2013. Staff Account: No.
Time: Sat Aug 10 12:33:32 2013
VIP Prize added the item:Gun_M4_Gold x1 to offline Flake * (Graal901490) - now has x1 of Gold M4. They did have 0. Reason: VIP for July 2013. Staff Account: No.
Time: Sat Aug 10 13:35:03 2013
VIP Prize added the item:Gun_M4_Gold x1 to offline Eric Rage* (Rage Family) (Graal849677) - now has x1 of Gold M4. They did have 0. Reason: VIP for July 2013. Staff Account: No.
Time: Sat Aug 10 14:36:33 2013
VIP Prize added the item:Gun_M4_Gold x1 to offline {*LEADER*} Gret (Graal952172) - now has x1 of Gold M4. They did have 0. Reason: VIP for July 2013. Staff Account: No.
Time: Sat Aug 10 15:38:08 2013
VIP Prize added the item:Gun_M4_Gold x1 to offline Nathan {vip} (Graal1111718) - now has x1 of Gold M4. They did have 0. Reason: VIP for July 2013. Staff Account: No.
Time: Sat Aug 10 16:39:40 2013
VIP Prize added the item:Gun_M4_Gold x1 to dragon (Elements) (Graal817254) - now has x1 of Gold M4. They did have 0. Reason: VIP for July 2013. Staff Account: No.
Time: Sat Aug 10 17:41:14 2013
VIP Prize added the item:Gun_M4_Gold x1 to offline #@ ~JESUS~ (SOUTHRIDGE HIGH) (Graal1037398) - now has x1 of Gold M4. They did have 0. Reason: VIP for July 2013. Staff Account: No.
Time: Sat Aug 10 18:42:47 2013
VIP Prize added the item:Gun_M4_Gold x1 to offline Bich plz (Graal853424) - now has x1 of Gold M4. They did have 0. Reason: VIP for July 2013. Staff Account: No.
Time: Sat Aug 10 19:44:19 2013
VIP Prize added the item:Gun_M4_Gold x1 to offline Intrepid Dynamic (Revolutionaries) (Graal942057) - now has x1 of Gold M4. They did have 0. Reason: VIP for July 2013. Staff Account: No.
Time: Sat Aug 10 20:45:53 2013
VIP Prize added the item:Gun_M4_Gold x1 to offline iTwiztid (Graal984761) - now has x1 of Gold M4. They did have 0. Reason: VIP for July 2013. Staff Account: No.
Sorry if you didn't win, but we're probably going to do this again. I assure you, it wasn't rigged.
Here's the full code (I removed the item stuff)
HTML Code:
function onCreated() {
this.setShape(1, 192, 80);
this.image = "era_luckdrawsign.png";
//Total winners
this.maxWinners = 10;
}
function onActionGrab() {
if (player.account != "xAndrewx") return;
//Start the game
if (player.chat == "start") {
//Drawing is reset
this.drawing = 0;
//Load the variables
this.db = ("DB_VIP_Raffle").link();
//this.db.player_accounts
//this.db.outfit_[account]
this.drawing = 3600;
setTimer(1);
}
}
function onTimeout() {
//Winner check
if (this.winners > this.maxWinners) {
this.destroy();
return;
}
//For loading if it' doesn't exist
if (this.db.vip_raffle == null) {
this.db = ("DB_VIP_Raffle").link();
}
//Choose a player
temp.player = randomstring(this.db.vip_raffle);
temp.outfit = this.db.("outfit_" @ temp.player);
//If it's drawing a winner
temp.winner = false;
//Check if the admin have said so
if (this.drawing > 0) {
this.drawing -= 5;
//Nice time
if (this.drawing <= 60)
temp.time = int(this.drawing) SPC "seconds";
else
temp.time = int(this.drawing / 60) SPC "minutes";
this.chat = "VIP Golden M4 Drawing in" SPC temp.time;
//Do we have a winner?
if (this.drawing <= 0) {
//Show the winner
this.chat = "The winner is..." SPC temp.outfit[2];
//Remove the player from the list
DB_VIP_Raffle.vip_raffle.remove(temp.player);
//Load it again (we shouldn't have to, but why not)
this.db = ("DB_VIP_Raffle").link();
//Winners plus
this.winners++;
//Notify staff
echo("VIP_LuckyDraw: Winner is" SPC temp.player SPC "(" @ this.winners @ "/" @ this.maxWinners @ ")");
//Notify the player
temp.pl = findplayer(temp.player);
if (temp.pl != null) {
temp.pl.sendMessageBox(_("You've won the VIP M4!!"));
}
//Reset the timer
this.drawing = 3600;
//Winner flag
temp.winner = true;
}
}
//Show the outfit
showani(1, this.x + 0.5, this.y + 2, 2, "era_spar-fullhead", temp.outfit[0], temp.outfit[1]);
changeimgvis(1, 3);
//Show the nickname
showtext(2, this.x + 3.5, this.y + 2.3, "Arial", "b", temp.outfit[2].substring(0, 13));
changeimgvis(2, 3);
changeimgzoom(2, 0.7);
//No winner? or a winner!
if (temp.winner == false)
setTimer(5);
else
setTimer(60);
}