Post by natzy24 on Dec 30, 2010 20:02:58 GMT
What it does: Generates a random item when a link is clicked on once every 24 hours, user is required to send a pm to the admin to let them know what they've got
Placement: Headers or Footers, might be wise to build a table around first
Code:
Edit by ZINC: Fixed a few errors.
Placement: Headers or Footers, might be wise to build a table around first
Code:
<script type="text/javascript">
// Treasure Chest Code
// Created by Nats aka Reno of ShinRas Turks
// With Help from Wormopolis and Michael of PBS
// May not be Reposted anywhere
//Array goes here
item=new Array();
item[0]="nothing, sorry today wasn't your day";
item[1]="200 Karma";
item[2]="nothing, sorry today wasn't your day";
item[3]="a Phoenix Down";
item[4]="nothing, sorry today wasn't your day";
item[5]="A Guardhound Pup";
item[6]="nothing, sorry today wasn't your day";
item[7]="nothing, sorry today wasn't your day";
item[8]="1 Restorative items Bundle";
item[9]="nothing, sorry today wasn't your day";
item[10]="3 Phoenix Downs";
item[11]="2000 Karma";
item[12]="nothing, sorry today wasn't your day";
item[13]="nothing, sorry today wasn't your day";
//randomization
var now = new Date();
var secs = now.getSeconds();
var raw_random_number = Math.random(secs);
var random_number = Math.round(raw_random_number * (item.length));
if (random_number == item.length){random_number = 0}
//set item
var itemrand = item[random_number];
//output goes here
if (document.cookie.match(/treasurec=1/)) {
document.write("<br>Sorry you can only play the treasure chest once every 24 hours, try again some other time");
}else {
document.write("Congratulations! You have won " +itemrand+ ". Please Message the main admin to retrieve your award <br>");
document.write("you can contact the main admin by clicking <a href='/index.cgi?action=pmsend&to=admin&subject=I%20have%20won%20an%20item&message=I%20have%20won%20an%20item%20from%20the%20treasure%20chest%20the%20item%20is%20as%20follows'>here</a>") ;
}
//Cookie
now.setDate(now.getDate() + 1);
document.cookie = 'treasurec=1;expires=' + now.toUTCString();
</script>
Edit by ZINC: Fixed a few errors.