Re: [mccode v2] Easter Egg Hunt (Finished)
Nice mod, I cleaned it up a bit:
To make this work though I had to switch the west.gif and the east.gif, You could rename the image files. if you dont the the arrows wont point in the right direction.
<?php
include "globals.php";
print "<h3>Easter Egg Hunt</h3>
";
if($ir['hospital']) { die("This page cannot be accessed while in hospital."); }
if($ir['easterturns'] < 1) { die("You've already hunted today, come back tomorrow for the next stage"); }
switch($_GET['action'])
{
case 'huntnorth': hunt_north(); break;
case 'hunteast': hunt_east(); break;
case 'huntsouth':hunt_south(); break;
case 'huntwest': hunt_west(); break;
default: index(); break;
}
function hunt_north()
{
global $db,$ir,$c,$h,$userid;
$chance = rand(1,10);
$db->query("UPDATE users SET easterturns=easterturns-1 where userid=$userid",$c);
if($ir['eastertime'] == 0) {
if($ir['easterturns'] == 25) {
mysql_query("UPDATE `users` SET `eastertime` = 60, `easterturns` = 24 WHERE `userid` = ".$ir['userid']);
//Display first attempt here
}
}
if($ir['eastertime'] < 1) { die("Sorry, time's up! Come back tomorrow for the next hunt"); }
if ($chance == 1) {
print "You look behind a bush, you think you've found an easter egg, but its only a big rock.
";
}
if ($chance == 2) {
print "Nothing here.
";
}
if ($chance == 3) {
print "Nothing here, just a few stones.
";
}
if ($chance == 4) {
$hosptime=(int) rand(1,5);
$loseruser = $ir['userid'];
$reasonhosp = 'Tried to beat someone up and failed!';
$db->query("UPDATE users SET hospital=$hosptime WHERE userid=$loseruser",$c);
$db->query("UPDATE users SET hospreason='$reasonhosp' WHERE userid=$loseruser",$c);
event_add($ir['userid'],"Don't mess with people bigger than you!",$c);
die ("You try to beat up a guy with an easter egg. He turns round and beats you down. You wake up in hospital.");
}
if ($chance == 5) {
print "You found an easter egg but a squirrel jumps out and takes it from your hands.
";
}
if ($chance == 6) {
$gain = rand(1,5);
print "While looking for easter eggs you coincidencially you found [b]$gain[/b] crystals.
";
$db->query("UPDATE users SET crystals=crystals+$gain where userid=$userid",$c);
}
if ($chance == 7) {
$gain = rand(50,100);
print "You turn over a rock and find [b] \$$gain[/b]. You pocket it and carry on hunting.
";
$db->query("update users set money=money+$gain where userid=$userid",$c);
}
if ($chance == 8) {
print "Nothing here. Just a few chavs.
";
}
if ($chance == 9) {
print "You look behind a giant leaf and find an easter egg! Look in your inventory for a special prize!
";
$itemidexplore =rand(38,42);
$db->query("INSERT INTO inventory VALUES('',$itemidexplore,$userid,1)",$c);
}
if ($chance == 10) {
print "You fall into a bush of nettles. You are stinging all over.
";
}
print "Turns used: {$ir['easterturns']}
";
print "Time remaining: {$ir['eastertime']}
";
print "
<table width=20% height=80% border=0>
<tr>
<td> </td>
<td align=north><center>[url='easter.php?action=huntnorth'][img=north.gif][/url]</center></td>
<td> </td>
</tr>
<tr>
<td align=right>[url='easter.php?action=hunteast'][img=west.gif][/url]</td>
<td> </td>
<td>[url='easter.php?action=huntwest'][img=east.gif][/url]</td>
</tr>
<tr>
<td> </td>
<td align=bottom><center>[url='easter.php?action=huntsouth'][img=south.gif][/url]</center></td>
<td> </td>
</tr>";
}
function hunt_east()
{
global $db,$ir,$c,$h,$userid;
$chance = rand(1,10);
$db->query("UPDATE users SET easterturns=easterturns-1 where userid=$userid",$c);
if($ir['eastertime'] == 0) {
if($ir['easterturns'] == 25) {
mysql_query("UPDATE `users` SET `eastertime` = 60, `easterturns` = 24 WHERE `userid` = ".$ir['userid']);
//Display first attempt here
}
}
if($ir['eastertime'] < 1) { die("Sorry, time's up! Come back tomorrow for the next hunt"); }
if ($chance == 1) {
print "You look behind a bush, you think you've found an easter egg, but its only a big rock.
";
}
if ($chance == 2) {
print "Nothing here.
";
}
if ($chance == 3) {
print "Nothing here, just a few stones.
";
}
if ($chance == 4) {
$hosptime=(int) rand(1,5);
$loseruser = $ir['userid'];
$reasonhosp = 'Tried to beat someone up and failed!';
$db->query("UPDATE users SET hospital=$hosptime WHERE userid=$loseruser",$c);
$db->query("UPDATE users SET hospreason='$reasonhosp' WHERE userid=$loseruser",$c);
event_add($ir['userid'],"Don't mess with people bigger than you!",$c);
die ("You try to beat up a guy with an easter egg. He turns round and beats you down. You wake up in hospital.");
}
if ($chance == 5) {
print "You found an easter egg but a squirrel jumps out and takes it from your hands.
";
}
if ($chance == 6) {
$gain = rand(1,5);
print "While looking for easter eggs you coincidencially you found [b]$gain[/b] crystals.
";
$db->query("UPDATE users SET crystals=crystals+$gain where userid=$userid",$c);
}
if ($chance == 7) {
$gain = rand(50,100);
print "You turn over a rock and find [b] \$$gain[/b]. You pocket it and carry on hunting.
";
$db->query("update users set money=money+$gain where userid=$userid",$c);
}
if ($chance == 8) {
print "Nothing here. Just a few chavs.
";
}
if ($chance == 9) {
print "You look behind a giant leaf and find an easter egg! Look in your inventory for a special prize!
";
$itemidexplore =rand(38,42);
$db->query("INSERT INTO inventory VALUES('',$itemidexplore,$userid,1)",$c);
}
if ($chance == 10) {
print "You fall into a bush of nettles. You are stinging all over.
";
}
print "Turns used: {$ir['easterturns']}
";
print "Time remaining: {$ir['eastertime']}
";
print "
<table width=20% height=80% border=0>
<tr>
<td> </td>
<td align=north><center>[url='easter.php?action=huntnorth'][img=north.gif][/url]</center></td>
<td> </td>
</tr>
<tr>
<td align=right>[url='easter.php?action=hunteast'][img=west.gif][/url]</td>
<td> </td>
<td>[url='easter.php?action=huntwest'][img=east.gif][/url]</td>
</tr>
<tr>
<td> </td>
<td align=bottom><center>[url='easter.php?action=huntsouth'][img=south.gif][/url]</center></td>
<td> </td>
</tr>";
}
function hunt_south()
{
global $db,$ir,$c,$h,$userid;
$chance = rand(1,10);
$db->query("UPDATE users SET easterturns=easterturns-1 where userid=$userid",$c);
if($ir['eastertime'] == 0) {
if($ir['easterturns'] == 25) {
mysql_query("UPDATE `users` SET `eastertime` = 60, `easterturns` = 24 WHERE `userid` = ".$ir['userid']);
//Display first attempt here
}
}
if($ir['eastertime'] < 1) { die("Sorry, time's up! Come back tomorrow for the next hunt"); }
if ($chance == 1) {
print "You look behind a bush, you think you've found an easter egg, but its only a big rock.
";
}
if ($chance == 2) {
print "Nothing here.
";
}
if ($chance == 3) {
print "Nothing here, just a few stones.
";
}
if ($chance == 4) {
$hosptime=(int) rand(1,5);
$loseruser = $ir['userid'];
$reasonhosp = 'Tried to beat someone up and failed!';
$db->query("UPDATE users SET hospital=$hosptime WHERE userid=$loseruser",$c);
$db->query("UPDATE users SET hospreason='$reasonhosp' WHERE userid=$loseruser",$c);
event_add($ir['userid'],"Don't mess with people bigger than you!",$c);
die ("You try to beat up a guy with an easter egg. He turns round and beats you down. You wake up in hospital.");
}
if ($chance == 5) {
print "You found an easter egg but a squirrel jumps out and takes it from your hands.
";
}
if ($chance == 6) {
$gain = rand(1,5);
print "While looking for easter eggs you coincidencially you found [b]$gain[/b] crystals.
";
$db->query("UPDATE users SET crystals=crystals+$gain where userid=$userid",$c);
}
if ($chance == 7) {
$gain = rand(50,100);
print "You turn over a rock and find [b] \$$gain[/b]. You pocket it and carry on hunting.
";
$db->query("update users set money=money+$gain where userid=$userid",$c);
}
if ($chance == 8) {
print "Nothing here. Just a few chavs.
";
}
if ($chance == 9) {
print "You look behind a giant leaf and find an easter egg! Look in your inventory for a special prize!
";
$itemidexplore =rand(38,42);
$db->query("INSERT INTO inventory VALUES('',$itemidexplore,$userid,1)",$c);
}
if ($chance == 10) {
print "You fall into a bush of nettles. You are stinging all over.
";
}
print "Turns used: {$ir['easterturns']}
";
print "Time remaining: {$ir['eastertime']}
";
print "
<table width=20% height=80% border=0>
<tr>
<td> </td>
<td align=north><center>[url='easter.php?action=huntnorth'][img=north.gif][/url]</center></td>
<td> </td>
</tr>
<tr>
<td align=right>[url='easter.php?action=hunteast'][img=west.gif][/url]</td>
<td> </td>
<td>[url='easter.php?action=huntwest'][img=east.gif][/url]</td>
</tr>
<tr>
<td> </td>
<td align=bottom><center>[url='easter.php?action=huntsouth'][img=south.gif][/url]</center></td>
<td> </td>
</tr>";
}
function hunt_west()
{
global $db,$ir,$c,$h,$userid;
$chance = rand(1,10);
$db->query("UPDATE users SET easterturns=easterturns-1 where userid=$userid",$c);
if($ir['eastertime'] == 0) {
if($ir['easterturns'] == 25) {
mysql_query("UPDATE `users` SET `eastertime` = 60, `easterturns` = 24 WHERE `userid` = ".$ir['userid']);
//Display first attempt here
}
}
if($ir['eastertime'] < 1) { die("Sorry, time's up! Come back tomorrow for the next hunt"); }
if ($chance == 1) {
print "You look behind a bush, you think you've found an easter egg, but its only a big rock.
";
}
if ($chance == 2) {
print "Nothing here.
";
}
if ($chance == 3) {
print "Nothing here, just a few stones.
";
}
if ($chance == 4) {
$hosptime=(int) rand(1,5);
$loseruser = $ir['userid'];
$reasonhosp = 'Tried to beat someone up and failed!';
$db->query("UPDATE users SET hospital=$hosptime WHERE userid=$loseruser",$c);
$db->query("UPDATE users SET hospreason='$reasonhosp' WHERE userid=$loseruser",$c);
event_add($ir['userid'],"Don't mess with people bigger than you!",$c);
die ("You try to beat up a guy with an easter egg. He turns round and beats you down. You wake up in hospital.");
}
if ($chance == 5) {
print "You found an easter egg but a squirrel jumps out and takes it from your hands.
";
}
if ($chance == 6) {
$gain = rand(1,5);
print "While looking for easter eggs you coincidencially you found [b]$gain[/b] crystals.
";
$db->query("UPDATE users SET crystals=crystals+$gain where userid=$userid",$c);
}
if ($chance == 7) {
$gain = rand(50,100);
print "You turn over a rock and find [b] \$$gain[/b]. You pocket it and carry on hunting.
";
$db->query("update users set money=money+$gain where userid=$userid",$c);
}
if ($chance == 8) {
print "Nothing here. Just a few chavs.
";
}
if ($chance == 9) {
print "You look behind a giant leaf and find an easter egg! Look in your inventory for a special prize!
";
$itemidexplore =rand(38,42);
$db->query("INSERT INTO inventory VALUES('',$itemidexplore,$userid,1)",$c);
}
if ($chance == 10) {
print "You fall into a bush of nettles. You are stinging all over.
";
}
print "Turns used: {$ir['easterturns']}
";
print "Time remaining: {$ir['eastertime']}
";
print "
<table width=20% height=80% border=0>
<tr>
<td> </td>
<td align=north><center>[url='easter.php?action=huntnorth'][img=north.gif][/url]</center></td>
<td> </td>
</tr>
<tr>
<td align=right>[url='easter.php?action=hunteast'][img=west.gif][/url]</td>
<td> </td>
<td>[url='easter.php?action=huntwest'][img=east.gif][/url]</td>
</tr>
<tr>
<td> </td>
<td align=bottom><center>[url='easter.php?action=huntsouth'][img=south.gif][/url]</center></td>
<td> </td>
</tr>";
}
function index()
{
global $db,$ir,$c,$h,$userid;
print "<h3>You Are About To Start The 1 Hour Easter Hunt</h3>
You Arrive At The Hunt, Ready To Win Some Eggs And Prove Everyone Wrong
<table width=20% height=80% border=0>
<tr>
<td> </td>
<td align=north><center>[url='easter.php?action=huntnorth'][img=north.gif][/url]</center></td>
<td> </td>
</tr>
<tr>
<td align=right>[url='easter.php?action=hunteast'][img=west.gif][/url]</td>
<td> </td>
<td>[url='easter.php?action=huntwest'][img=east.gif][/url]</td>
</tr>
<tr>
<td> </td>
<td align=bottom><center>[url='easter.php?action=huntsouth'][img=south.gif][/url]</center></td>
<td> </td>
</tr>";
}
$h->endpage;
?>