Hey everyone, well I started this mod this morning after finding out I've torn a ligament in my knee :D
This is only the 'bare bones' of the mod, there is a lot more to come after hearing personal views ect.
NOTE: This has not been tested to its fullest extent.
SQL:
CREATE TABLE IF NOT EXISTS `monkeys` (
`ID` int(11) NOT NULL auto_increment,
`User` int(11) NOT NULL,
`speed` int(11) NOT NULL default '10',
`intel` int(11) NOT NULL default '10',
`power` int(11) NOT NULL default '10',
`energy` int(11) NOT NULL default '10',
`cage` int(11) NOT NULL default '0',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM;
Cron_Fivemins edit:
$db->query("UPDATE `monkeys` SET `energy` = `energy` + 1 WHERE energy < 10 ");
Also Add this in PHPMYADMIN:
ALTER TABLE users ADD monkeys INT(11) DEFAULT 10;
Call this monkeys.php
<?php
//made by whizzbang
//do not re-sell or claim as your own
include_once(DIRNAME(__FILE__).'/globals.php');
$db->query("UPDATE `monkeys` SET `energy` = `energy` + 1 WHERE energy < 10 ");
$monkeys = mysql_query("SELECT `energy` , `power` , `speed` , `intel` FROM `monkeys` WHERE (ID = $userid) ");
$row = mysql_fetch_array($monkeys);
printf("
<span class = 'grey'>Welcome to the monkey cage, here you can send your monkeys to work.
You currently have %u Monkeys
</span>" , number_format($ir['monkeys']));
echo '
<table border = 1 width = 75% cellspacing = 1>
<td>Energy</td><td>Power</td><td>Speed</td><td>Intelligence</td>
<tr>
<td width = "18.75%" >'.number_format($row['energy']).'</td>
<td width = "18.75%">'.number_format($row['power']).'</td>
<td width = "18.75%">'.number_format($row['speed']).'</td>
<td width = "18.75%">'.number_format($row['intel']).'</td>
</tr>
</table>
';
echo '
<table border = 1 width = 75% cellspacing = 1>
<tr>
<th>
Actions
</th>
</tr>
<tr>
<td>Send to work</td>
<td><a href = "/monkeys.php?page=work">Go</a></td>
</tr>
<td>Train your monkeys</td>
<td><a href = "/monkeys.php?page=train">Go</a></td>
<tr>
<td>Buy more Monkeys</td>
<td><a href = "/monkeys.php?page=buy&item=monkeys">Go</a></td>
</tr>
<tr>
<td>Buy A Cage</td>
<td><a href = "/monkeys.php?page=buy&item=cage">Go</a></td>
</tr>
<tr>
<td>Battle Monkeys</td>
<td><a href = "/monkeys.php?page=battle">Go</a></td>
</tr>
</table>
';
if(isset($_GET['page']))
{
switch($_GET['page'])
{
case 'work' : work(); break;
case 'buy' : buy(); break;
case 'train' : train(); break;
case 'battle' : battle(); break;
}
}
function buy()
{
global $ir , $r , $userid;
if($_GET['item'] == 'monkeys')
{
echo '
<span class = "grey">Here you can buy some more monkeys from the Zoo
You currently have '.$ir['monkeys'].' Monkeys
It costs $200 per monkey
<form action = "/monkeys.php?page=buy&item=monkeys" method = "post">
Amount:<input type = "text" name = "amount" value = "0">
<input type = "submit" value = "Buy Monkeys">
';
}
if($_GET['item'] == 'cage')
{
echo '<span class = "grey">Buying a cage will slightly boost your stat gains while training.
Buying a cage costs $10,000</span>
';
echo '
<form action = "/monkeys.php?page=buy&item=cage" method = "post"
<input type = hidden name = buying>
<input type = "submit" value = "Buy Cage">
';
if(isset($_POST['buying']))
{
$monkeys = mysql_query("SELECT `cage` FROM `monkeys` WHERE (ID = $userid) ");
$row = mysql_fetch_array($monkeys);
if($row['cage'] == 1)
{
die("<span class = 'yellow'>You already have a cage, why do you want another one?</span>");
}
mysql_query("UPDATE `users` SET `money` = `money` - 10000 WHERE (userid = $userid) ") or die(mysql_error());
mysql_query("UPDATE `monkeys` SET `cage` = 1 WHERE (ID = $userid) ") or die(mysql_error());
echo '<span class = "yellow">Congratulations, youve bought a cage for your monkeys!</span>
';
}
}
if(isset($_POST['amount'] ))
{
if(empty($_POST['amount']))
{
die("<span class = 'yellow'>You have not filled in the form.</span>");
}
if(!is_numeric($_POST['amount']))
{
die("<span class='yellow'>The amount you entered was not numeric</span>");
}
$monkey = $_POST['amount'] * 200; //Change the cost of the monkeys to your liking
if($ir['money'] < $monkey)
{
die("<span class='yellow'>You don't have enough money to buy these monkeys.</span>");
}
else
{
mysql_query("UPDATE `users` SET `monkeys` = `monkeys` + {$_POST['amount']} , `money` = `money` - $monkey WHERE (userid = $userid) ") or die(mysql_error());
echo '<span class = "yellow"> Success, you have bought '.$_POST['amount'].' Monkeys!</span>';
}
}
}
function train()
{
global $ir , $userid;
$monkeybuisness = mysql_query("SELECT `energy` , `cage` FROM `monkeys` WHERE (ID = $userid) ");
$row = mysql_fetch_array($monkeybuisness);
echo '
<span class = "grey">Welcome to the training area, here you can train your monkeys
You currently have '.$ir['monkeys'].' Monkeys to train.
It costs 10 energy to train, you currently have '.$row['energy'].' Energy</span>
';
echo '
<table border = 1 width = 75% cellspacing = 1>
<tr>
<td>Train Speed</td>
<td><a href = "/monkeys.php?page=train&stat=speed">Go</a></td>
</tr>
<tr>
<td>Train Intelligence</td>
<td><a href = "/monkeys.php?page=train&stat=intel">Go</a></td>
</tr>
<tr>
<td>Train Power</td>
<td><a href = "/monkeys.php?page=train&stat=power">Go</a></td>
</tr>
</table> ';
if($_GET['stat'] == 'speed')
{
if($row['energy'] < 10)
{
die("Sorry you do not have the required energy to train your monkeys");
}
if($row['cage'] == 1)
{
$gain = $ir['monkeys'] * $ir['level'] / 4 ; //this is the formula, change to your liking
$gain = abs(@intval($gain));
}
else
{
$gain = $ir['monkeys'] * $ir['level'] / 5 ; //this is the formula, change to your liking
$gain = abs(@intval($gain));
}
mysql_query("UPDATE `monkeys` SET `speed` = `speed` + $gain , `energy` = `energy` - 10 WHERE (ID = $userid) ") or die(mysql_error());
echo '<span class = "yellow">Success, you have gained '.number_format($gain).' Speed on your monkeys!</span>';
}
if($_GET['stat'] == 'intel')
{
if($row['energy'] < 10)
{
die("Sorry you do not have the required energy to train your monkeys");
}
if($row['cage'] == 1)
{
$gain = $ir['monkeys'] * $ir['level'] / 5 ; //this is the formula, change to your liking
$gain = abs(@intval($gain));
}
else
{
$gain = $ir['monkeys'] * $ir['level'] / 10 ; //this is the formula, change to your liking
$gain = abs(@intval($gain));
}
mysql_query("UPDATE `monkeys` SET `intel` = `intel` + $gain , `energy` = `energy` - 10 WHERE (ID = $userid) ") or die(mysql_error());
echo '<span class = "yellow">Success, you have gained '.number_format($gain).' Intelligence on your monkeys!</span>';
}
if($_GET['stat'] == 'power')
{
if($row['energy'] < 10)
{
die("Sorry you do not have the required energy to train your monkeys");
}
if($row['cage'] == 1)
{
$gain = $ir['monkeys'] * $ir['level'] / 4 ; //this is the formula, change to your liking
$gain = abs(@intval($gain));
}
else
{
$gain = $ir['monkeys'] * $ir['level'] / 5 ; //this is the formula, change to your liking
$gain = abs(@intval($gain));
}
mysql_query("UPDATE `monkeys` SET `power` = `power` + $gain , `energy` = `energy` - 10 WHERE (ID = $userid) ") or die(mysql_error());
echo '<span class = "yellow">Success, you have gained '.number_format($gain).' Power on your monkeys!</span>';
}
}
function work()
{
global $ir , $userid;
$monkeybuisness = mysql_query("SELECT `energy` FROM `monkeys` WHERE (ID = $userid) ");
$row = mysql_fetch_array($monkeybuisness);
echo '<span class = "grey">You can send you monkeys out to work here, might get some nice stuff!
It costs 2 energy every time you send them to work, you currently have '.$row['energy'].' Energy</span>
';
echo '
<table border = 1 width = 75% cellspacing = 1>
<td>Start Scavenging</td>
<td><a href = "/monkeys.php?page=work&send=scavenge">Go</td>
</table>';
}
if($_GET['send'] == 'scavenge')
{
$monkeybuisness = mysql_query("SELECT `energy` FROM `monkeys` WHERE (ID = $userid) ");
$row = mysql_fetch_array($monkeybuisness);
if($row['energy'] < 2)
{
die("You dont have enough energy");
}
$number = mt_rand(1, 7);
mysql_query("UPDATE `monkeys` SET `energy` = `energy` - 2 WHERE (ID = $userid) ");
switch($number)
{
case 1:
$crystals = mt_rand(1,5); //Change the amount of crystals here
echo '<span class = "yellow">Your monkeys find '.$crystals.' Crystals laying about in the mud!</span>';
mysql_query("UPDATE `users` SET `crystals` = `crystals` + {$crystals} WHERE (userid = $userid) ");
break;
case 2:
$money = mt_rand(30, 350); // change money here
echo '<span class = "yellow">While performing for the circus, your monkeys find '.$money.'!</span>';
mysql_query("UPDATE `users` SET `money` = `money` + {$money} WHERE (userid = $userid) ");
break;
case 3:
//No event here, can be added if wanted.
echo '<span class = "grey">After searching for 5 hours, your monkeys give up</span>';
break;
case 4:
$attacked = mt_rand(4, 7);
$reason = 'Beaten up, while monkeys watched ';
echo '<span class = "grey">Your monkeys become involved in a fight, you jump in but get beaten up!</span>';
mysql_query("UPDATE `users` SET `hospital` = `hospital` + {$attacked} , hospreason = {$reason} WHERE (userid = $userid) ");
break;
case 5:
echo '<span class = "yellow">The monkeys bring back a drink, once you drink it you feel a lot braver</span>';
mysql_query("UPDATE `users` SET `brave` = `maxbrave` WHERE (userid = $userid) ");
break;
case 6:
$brick = mt_rand(2, 5);
echo '<span class = "grey">Your monkeys were feeling cheeky today, they threw a brick at your head...OOPS</span>';
mysql_query("UPDATE `users` SET `hospital` = $brick , `hospreason` = 'Monkeys threw brick at your head' WHERE (userid = $userid) ");
break;
case 7:
echo '<span class = "yellow">You see your monkeys playing and it makes you feel alot happier!</span>';
mysql_query("UPDATE `users` SET `will` = `maxwill` WHERE (userid = $userid) ");
break;
}
}
function battle()
{
global $ir , $userid;
if($ir['hospital'] > 1)
{
die("How can you battle while in hospital?");
}
if($ir['jail'] >1)
{
die("How can you battle while in jail?");
}
$monkey = mysql_query("SELECT `energy` , `power` , `speed` , `intel` FROM `monkeys` WHERE (ID = $userid) ");
$row = mysql_fetch_array($monkey);
echo '
<span class ="grey">You look in the newspaper and find some local bare knuckle monkey fighters
It costs 10 energy to battle , Pick the monkeys you would like to battle
</span>';
echo '<table border = 1 width = 75% cellspacing = 1>
<tr>
<th>Fighter</th>
<th>Reward</th>
</tr>
<tr>
<td>M.Monkey (Easy)</td>
<td>$250</td>
<td><a href = "/monkeys.php?page=battle&ID=1">Fight Now</a></td>
</tr>
<tr>
<td>Jammy (Hard)</td>
<td>$5,000</td>
<td><a href = "/monkeys.php?page=battle&ID=2">Fight Now</a></td>
</tr>
</table>';
if($_GET['ID'] == '1')
{
if($row['energy'] < 10)
{
die("<span class ='yellow'>You do not have enough energy</span>");
}
$formula = $row['power'] + $row['intel'] + $row['speed'] * $ir['monkeys'];
$npcformula = 3000 * 50 ;
if($formula > $npcformula)
{
mysql_query("UPDATE `monkeys` SET `energy` = `energy` - 10 WHERE (ID = $userid) ");
mysql_query("UPDATE `users` SET `money` = `money` + 250 WHERE (userid = $userid) ");
echo '<span class = "yellow">Congratulations, youve won the battle earning yourself $250!</span>';
}
else
{
mysql_query("UPDATE `monkeys` SET `energy` = `energy` - 10 WHERE (ID = $userid) ");
mysql_query("UPDATE `users` SET `hospital` = `hospital` + 5 , hospreason = 'Monkeys beaten up' WHERE (userid = $userid) ") or die(mysql_error());
echo '<span class = "yellow">The fighter beat you up, youll now spend some time in hospital</span>';
}
}
//FIGHTER 2
if($_GET['ID'] == '2')
{
if($row['energy'] < 10)
{
die("<span class ='yellow'>You do not have enough energy</span>");
}
$formula = $row['power'] + $row['intel'] + $row['speed'] * $ir['monkeys'];
$npcformula = 10000 * 500 ;
if($formula > $npcformula)
{
mysql_query("UPDATE `monkeys` SET `energy` = `energy` - 10 WHERE (ID = $userid) ");
mysql_query("UPDATE `users` SET `money` = `money` + 5000 WHERE (userid = $userid) ");
echo '<span class = "yellow">Congratulations, youve won the battle earning yourself $5,000!</span>';
}
else
{
mysql_query("UPDATE `monkeys` SET `energy` = `energy` - 10 WHERE (ID = $userid) ");
mysql_query("UPDATE `users` SET `hospital` = `hospital` + 15 , hospreason = 'Monkeys beaten up' WHERE (userid = $userid) ") or die(mysql_error());
echo '<span class = "yellow">The fighter beat you up, youll now spend some time in hospital</span>';
}
}
}
?>
Also in register.php you'll have to add this query after the user insert:
mysql_query("INSERT INTO `monkeys` VALUES ('' , $i , 10 , 10 ,10 ,10,0) ");
NOT TESTED
CSS:
span.yellow {color:yellow;font-weight:bold}
span.grey {color:lightgrey;font-weight:bold}
EDIT: Just seen there is something similiar to this 'Monkey Slaves', I did not copy it, i simply was thinking of monkeys ...lol, there will be many more add-ons, there has already been a few on another forum.