First, I did not write this mod, although I enhanced it quite a bit, this was a mod called Ians Investment Mod I got here at the free mods section on MWG found here:
http://makewebgames.io/showthread.php/30432-mccode-v2-Ian-s-Investments?highlight=ians
It was originally made with 2 levels of upgrading, i changed it to 10 levels, the way interest is made has been changed drastically, its now based upon interest level and length of investment and does not gain daily but at the end of the investment.
I added an early withdrawal system that will charge 15% of the investment to pull out early.
I secured it in several places, you can only upgrade each level when you have invested a certain total amount, each time you invest it is added to the total.
The price goes up considerably each time you upgrade as well, taking money and points/crystals to do so.
I eliminated the use for crons except for the user contract you must buy every 3 months.
I eliminated alot of code though more could be eliminated with a few variables.
It is based on timestamps instead of crons and counts down the days, hours minutes and seconds (not live) for the investment time, the only cron is a single day cron for the contract time.
There is a cap of 2.5b which can be changed easily as can most other things.
Investment lengths were 7 and 14 days. 30, 60 and 90 days I added.
Here is a list of investments percentages per level per length. I wrote this up as a guide so i figured someone may want it to go along with the mod.
If anyone uses this mod i would appreciate some feedback :)
(* amount gained from a capped investment of 2.5b)
Level 1:
7 Days - 0.21% *5.25m
14 Days - 0.42% *10.5m
30 Days - 0.91% *22.75m
60 Days - 1.82% *45.5m
90 Days - 2.73% *68.25m
Level 2:
7 Days - 0.42% *10.5m
14 Days - 0.85% *21.25m
30 Days - 1.82% *45.5m
60 Days - 3.64% *91m
90 Days - 5.45% *136.25m
Level 3:
7 Days - 0.64% *16m
14 Days - 1.27% *31.75m
30 Days - 2.73% *68.25m
60 Days - 5.45% *136.25m
90 Days - 8.18% *204.5m
Level 4:
7 Days - 0.85% *21.25m
14 Days - 1.70% *42.5m
30 Days - 3.64% *91m
60 Days - 7.27% *181.75m
90 Days - 10.91% *272.75m
Level 5:
7 Days - 1.06% *26.5m
14 Days - 2.12% *53.m
30 Days - 4.55% *113.75m
60 Days - 9.09% *227.25m
90 Days - 13.64% *341m
Level 6:
7 Days - 1.27% *31.75m
14 Days - 2.55% *63.75m
30 Days - 5.45% *136.25m
60 Days - 10.91% *272.75m
90 Days - 16.36% *409m
Level 7:
7 Days - 1.48% *37m
14 Days - 2.97% *74.25m
30 Days - 6.36% *159m
60 Days - 12.73% *318.25m
90 Days - 19.09% *477.25m
Level 8:
7 Days - 1.70% *42.5m
14 Days - 3.39% *84.75m
30 Days - 7.27% *181.75m
60 Days - 14.55% *363.75m
90 Days - 21.82% *545.5m
Level 9:
7 Days - 1.91% *47.75m
14 Days - 3.82% *95.5m
30 Days - 8.18% *204.5m
60 Days - 16.36% *409m
90 Days - 24.55% *613.75m
Level 10:
7 Days - 2.12% *53m
14 Days - 4.24% *106m
30 Days - 9.09% *227.25m
60 Days - 18.18% *454.5m
90 Days - 27.27% *681.75m
Investment Level Upgrade Cost:
Level 1 - Free
Level 2 - $10,000,000 and 50 points
Level 3 - $40,000,000 and 100 points
Level 4 - $90,000,000 and 150 points
Level 5 - $160,000,000 and 200 points
Level 6 - $250,000,000 and 250 points
Level 7 - $360,000,000 and 300 points
Level 8 - $490,000,000 and 350 points
Level 9 - $640,000,000 and 400 points
Level 10 - $810,000,000 and 450 points
Now for the mod :P
SQL's
ALTER TABLE `users` ADD `userCONTRACT` INT(11) NOT NULL DEFAULT '0',
ADD `userSTART` INT(11) NOT NULL DEFAULT '0',
ADD `userDAYS` INT(11) NOT NULL DEFAULT '0',
ADD `userLENGTH` INT(11) NOT NULL DEFAULT '0',
ADD `userBANKAMMT` BIGINT(64) NOT NULL DEFAULT '0',
ADD `userTOTALAMMT` BIGINT(64) NOT NULL DEFAULT '0',
ADD `investlevel` INT(11) NOT NULL DEFAULT '1';
investment.php
<?php
include "globals.php";
switch($_GET['action'])
{
case 'investhome': invest_home(); break;
case 'buyinvest': buy_invest(); break;
case 'buyinvestsub': buyinvest_sub(); break;
case 'invest': invest(); break;
case 'getinvest': get_invest(); break;
case 'earlyinvest': early_invest(); break;
case 'earlyinvestsub': early_invest_sub(); break;
case 'levelupgrade': level_upgrade(); break;
case 'levelupgradesub': levelupgrade_sub(); break;
default: index(); break;
}
function index()
{
global $db,$ir,$c,$h,$userid,$set;
$newlvl = ($ir['investlevel']+1);
echo "<h2 />Welcome to ".$set['game_name']." Investments.<br>How may we help you?</h2><hr>";
if($ir['userCONTRACT'] == 0)
{
echo "<h5>You may sign a contract that entitles you to our interest facilities.<br>Once under contract you may invest any amount of money for a certain period of time, you will then gain interest based on that period.<br>You may also upgrade your contract if you wish to gain additional interest.</h5>";
echo "
<form action = 'investment.php?action=buyinvest' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7;' value = 'Sign Contract' name = 'buyinvest' /> </form>
";
}
if($ir['userBANKAMMT'] > 0)
{
echo "
<form action = 'investment.php?action=investhome' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7;' value = 'View Investment' name = 'investhome' /> </form>
";
}
elseif($ir['userBANKAMMT'] == 0 AND $ir['userCONTRACT'] > 0)
{
echo "
<form action = 'investment.php?action=investhome' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7;' value = 'Start Investment' name = 'investhome' /> </form>
";
}
if($ir['userCONTRACT'] > 0 AND $ir['userBANKAMMT'] == 0 AND $ir['investlevel'] < 10)
{
echo "
<form action = 'investment.php?action=levelupgrade' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7;' value = 'Upgrade to Level $newlvl' name = '$newlvl' /> </form>";
}
else
{
echo "
";
}
}
function buy_invest()
{
global $db,$ir,$c,$h,$userid;
$contract = money_formatter($ir['level'] * 200);
if($ir['userCONTRACT'] > 0)
{
die ("You already have a contract with us. Your contract will last for {$ir['userCONTRACT']} more days.
<a href='investment.php'>Go Back</a>");
}
else
{
print "Welcome to Mayhem Investments ".$ir['username'].".<br>Would you like to sign a contract with us for ".$contract."?<hr width='60%'>
<table><tr> <td> <form action = 'investment.php?action=buyinvestsub' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7;' value = 'Yes' /> </form> </td><td>
<form action = 'investment.php' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7;' value = 'No' /> </form></td></tr></table><hr width='60%'>";
echo "<br><br><a href='index.php'>Home</a>";
$h->endpage();
exit;
}
}
function buyinvest_sub()
{
global $db,$ir,$c,$h,$userid;
$contract = ($ir['level'] * 200);
if($ir['money'] < $contract)
{
$contract = money_formatter($contract);
echo "You don't have enough money to sign a contract. You need ".$contract.".<br><br><a href='index.php'>Home</a>";
$h->endpage();
exit;
}
elseif($ir['userCONTRACT'] > 0)
{
die("You already have a contract with us. Your current contract still has {$ir['userCONTRACT']} days on it.");
}
else
{
print "Congratulations. You have signed a contract with us for 60 days. After the 60 days, you will have to sign another contract to start an investment. <br><br><a href='investment.php'>Go Back</a>";
$db->query(sprintf("UPDATE `users` SET `money` = `money` - '%d',
`userCONTRACT` = '%d'
WHERE `userid` = ('%u')",
$contract, 60, $userid));
$h->endpage();
exit;
}
}
function invest_home()
{
global $db,$ir,$c,$h,$userid,$set;
$tDiff = $ir['userDAYS'] - time();
$days = floor($tDiff / 86400);
$hours = ($tDiff / 3600) % 24;
$mins = ($tDiff / 60) % 60;
$secs = ($tDiff) % 60;
if($ir['userCONTRACT'] == 0)
{
echo "You need to sign a contract first. To sign a contract, you may do that<a href='investment.php?action=buyinvest' />Here</a>.<br><br><a href='index.php'>Home</a>";
$h->endpage();
exit;
}
elseif($tDiff > 0)
{
$invlevel = ($ir['investlevel']*3/11)*($ir['userLENGTH']/9);
$invlevel2 = number_format($invlevel, 2);
$totinvest = "".$ir['userBANKAMMT']/100*$invlevel2."";
$totalinvest = "".money_formatter($ir['userBANKAMMT']+$totinvest)."";
$total = "".$ir['userBANKAMMT']+$totinvest."";
$started = date('F j',$ir['userSTART']);
$started1 = date('g:i:s a',$ir['userSTART']);
$started3 = date('F j',$ir['userDAYS']);
$started4 = date('g:i:s a',$ir['userDAYS']);
$tDiff = $ir['userDAYS'] - time();
$days = floor($tDiff / 86400);
$hours = ($tDiff / 3600) % 24;
$mins = ($tDiff / 60) % 60;
$secs = ($tDiff) % 60;
$info = "You have ".$days." days, ".$hours." hours, ".$mins." minutes and ".$secs." seconds left on this investment.";
if($ir['investlevel'] == 10)
{
$curlevel = "<font color=darkgreen><i>You have a fully upgraded investment level of 10! </i></font><br> You have a total investment length of ".$ir['userLENGTH']." days.<br>This gives you an interest rate of <font color=darkgreen>".$invlevel2."%.</font>";
}
else
{
$curlevel = "Your investment level is ".$ir['investlevel'].".<br> You have a total investment length of ".$ir['userLENGTH']." days.<br>This gives you an interest rate of <font color=darkgreen>".$invlevel2."%</font>.";
}
print "".$curlevel."<br><br>You will receive <font color=darkgreen>".money_formatter($totinvest)."</font> interest for the <font color=darkgreen>".money_formatter($ir['userBANKAMMT'])."</font> invested in your portfolio.
<br>
You will gain a total of <font color=darkgreen>".money_formatter($total)."</font> for this investment.<br><br>
Your investment began on ".$started." at ".$started1."<br>Your investment will mature on ".$started3." at ".$started4.".<br>At this time you may withdraw your investment and start another if you wish.<br><br><font color=firebrick>".$info."</font><hr>
<br><form action = 'investment.php?action=earlyinvest' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7;' value = 'Withdraw Early' /> </form><small><i>(There is a confirmation)</i></small><br><br><a href='index.php'>Go Home</a>";
$h->endpage();
exit;
}
elseif($tDiff < 0 && $ir['userBANKAMMT'] > 0)
{
$invlevel = ($ir['investlevel']/8*3)*($ir['userLENGTH']/10+2);
$invlevel2 = number_format($invlevel, 2);
$totinvest = "".$ir['userBANKAMMT']/100*$invlevel2."";
$totalinvest = "".money_formatter($ir['userBANKAMMT']+$totinvest)."";
$total = "".$ir['userBANKAMMT']+$totinvest."";
echo "Your investment has been completed. Please collect your ".money_formatter($total).".
<form action = 'investment.php?action=getinvest' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7; value = 'Withdraw ".money_formatter($total)."' name = 'getinvest' /> </form>";
}
elseif($ir['userBANKAMMT'] == 0)
{
if($ir['money'] > 2500000000)
{
$money = "2500000000";
}
else
{
$money = $ir['money'];
}
echo "<table width='100%' style='background-color:#CCCCCC; border:2px solid #7D7764;'><th colspan='1'>Invest with ".$set['game_name']." Investments</th><tr><td align='center' style='background-color:#CCCCCC;'><br>
You can invest large amounts of cash with our investment firm. <br><img src='images/vault.png' /><br>This is a low risk investment guaranteed to earn a profit.<br>Once you invest your money it is kept here until it has matured. Early withdrawal will cause you to incurr a 15% penalty. You can upgrade your investment level which will giving you varying increases in interest.
<br>Please select how much and long you wish to invest.
<form action='investment.php?action=invest' method='post'>
<br>Amount to Invest:<br> <input type='text' STYLE='color: black; background-color: #D6D6C7;' maxlength='10' name='invest' value='$money' /><br>
Length of Investment:<br>
<select name='timetoinvest' STYLE='color: black; background-color: #D6D6C7;' type='dropdown'>
<option value='1'>7 Days</option>
<option value='2'>14 Days</option>
<option value='3'>30 Days</option>
<option value='4'>60 Days</option>
<option value='5'>90 Days</option>
</select>
<center><br>
<input type='submit' STYLE='color: black; background-color: #D6D6C7;' value='Start Investment' /></center></form></td> </tr> </table>";
}
}
function invest()
{
global $db,$ir,$c,$userid,$h;
$_POST['invest']=abs((int) $_POST['invest']);
if($ir['userDAYS'] > 0)
{
echo "You already have an investment!<hr><br><a href='investment.php'>Check Investment</a>";
$h->endpage();
exit;
}
elseif($_POST['invest'] > '2500000000')
{
echo "We're sorry, you are only allowed a maximum investment of $2,500,000,000.<hr><br><a href='investment.php'>Back</a>";
$h->endpage();
exit;
}
elseif($_POST['invest'] > $ir['money'])
{
echo "You do not have enough money to invest this ammount.<hr><br><a href='investment.php'>Back</a>.";
$h->endpage();
exit;
}
elseif($_POST['invest'] < 100)
{
echo "You must invest at least $100!<hr><br><a href='investment.php'>Back</a>.";
$h->endpage();
exit;
}
else
{
if($_POST['timetoinvest'] == 1)
{
$investtime = "7";
$timeuni = "".(time() + 604800)."";
}
if($_POST['timetoinvest'] == 2)
{
$investtime = "14";
$timeuni = "".(time() + 1209600)."";
}
if($_POST['timetoinvest'] == 3)
{
$investtime = "30";
$timeuni = "".(time() + 2592000)."";
}
if($_POST['timetoinvest'] == 4)
{
$investtime = "60";
$timeuni = "".(time() + 5184000)."";
}
if($_POST['timetoinvest'] == 5)
{
$investtime = "90";
$timeuni = "".(time() + 7776000)."";
}
$invlevel = ($ir['investlevel']/5*3)*($ir['userLENGTH']/11);
$invlevel2 = number_format($invlevel, 2);
$totinvest = "".$ir['userBANKAMMT']/100*$invlevel2."";
$total = "".$ir['userBANKAMMT']+$totinvest."";
$gain=$_POST['invest'];
$start = "86400*$investtime";
$db->query(sprintf("UPDATE `users` SET `money` = `money` - '%d',
`userBANKAMMT` = '%d',
`userTOTALAMMT` = `userTOTALAMMT` + '%d',
`userSTART` = unix_timestamp(),
`userLENGTH` = '%d',
`userDAYS` = '%d'
WHERE `userid` = ('%u')",
$_POST['invest'], $gain, $gain, $investtime,$timeuni, $userid));
echo "Thank you for your investment of ".money_formatter($_POST['invest']).". <br>After ".$investtime." days, you may collect your money.<hr><br>
<a href='investment.php'>Back</a>";
$h->endpage();
exit;
}
}
function early_invest()
{
global $db,$ir,$c,$h,$userid;
$earlybank = "".($ir['userBANKAMMT']/100*85)."";
$tDiff = $ir['userDAYS'] - time();
$days = floor($tDiff / 86400);
$hours = ($tDiff / 3600) % 24;
$mins = ($tDiff / 60) % 60;
$secs = ($tDiff) % 60;
if($ir['userCONTRACT'] == 0)
{
echo "You need to sign a contract with us before you can withdraw any money. Click <a href='investment.php?action=buyinvest'>here</a> to sign a contract.<br><br><a href='investment.php'>Back</a>";
$h->endpage();
exit;
}
elseif($tDiff < 1 AND $ir['userBANKAMMT'] > 0)
{
echo "You have an investment that has already finished but not yet claimed.<br><br><a href='investment.php'>Back</a>";
$h->endpage();
exit;
}
elseif($tDiff < 1 AND $ir['userBANKAMMT'] == 0)
{
echo "You do not have an investment, how can you finish it early?<br><br><a href='investment.php'>Back</a>";
$h->endpage();
exit;
}
else
{
print "You may withdraw your investment early. Be aware you are assessed a 15% penalty for early withdrawal. ".money_formatter($earlybank)." will be returned to you.
<hr>
<table><tr><td>
<form action = 'investment.php?action=earlyinvestsub' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7;' value = 'Withdraw' /> </form> </td><td>
<form action = 'investment.php' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7;' value = 'No Thanks' /> </form></td></tr></table>";
}
}
function early_invest_sub()
{
global $db,$ir,$c,$h,$userid;
$earlybank = "".($ir['userBANKAMMT']/100*85)."";
$tDiff = $ir['userDAYS'] - time();
$days = floor($tDiff / 86400);
$hours = ($tDiff / 3600) % 24;
$mins = ($tDiff / 60) % 60;
$secs = ($tDiff) % 60;
if($ir['userCONTRACT'] == 0)
{
echo "You need to sign a contract with us before you can withdraw any money. Click <a href='investment.php?action=buyinvest'>here</a> to sign a contract.<br><br><a href='investment.php'>Back</a>";
$h->endpage();
exit;
}
elseif($tDiff < 1 AND $ir['userBANKAMMT'] > 0)
{
echo "You have an investment that has already finished but not yet claimed.<hr><br><a href='investment.php'>Back</a>";
$h->endpage();
exit;
}
elseif($tDiff < 1 AND $ir['userBANKAMMT'] == 0)
{
echo "You do not have an investment, how can you finish it early?<hr><br><a href='investment.php'>Back</a>";
$h->endpage();
exit;
}
else
{
print "You have withdrawn your ".money_formatter($earlybank).". <hr><br><a href='investment.php'>Back</a>";
$db->query(sprintf("UPDATE `users` SET `money` = `money` + '%d',
`userTOTALAMMT` = `userTOTALAMMT` - '%d',
`userBANKAMMT` = '%d',
`userSTART` = '%d',
`userLENGTH` = '%d',
`userDAYS` = '%d'
WHERE `userid` = ('%u')",
$earlybank,$ir['userBANKAMMT'], 0, 0, 0, 0, $userid));
}
}
function get_invest()
{
global $db,$ir,$c,$h,$userid;
$tDiff = $ir['userDAYS'] - time();
$days = floor($tDiff / 86400);
$hours = ($tDiff / 3600) % 24;
$mins = ($tDiff / 60) % 60;
$secs = ($tDiff) % 60;
$invlevel = ($ir['investlevel']/5*3)*($ir['userLENGTH']/11+2);
$invlevel2 = number_format($invlevel, 2);
$totinvest = "".$ir['userBANKAMMT']/100*$invlevel2."";
$totalinvest = "".money_formatter($ir['userBANKAMMT']+$totinvest)."";
$total = "".$ir['userBANKAMMT']+$totinvest."";
if($ir['userCONTRACT'] == 0)
{
echo "You need to sign a contract before you can collect your money. Go<a href='investment.php?action=buyinvest'>HERE</a> to sign a new contract.";
$h->endpage();
exit;
}
if($ir['userBANKAMMT'] == 0)
{
echo "You do not have a current investment.<br><br><a href='investment.php'>Back</a>";
$h->endpage();
exit;
}
if($tDiff > 0)
{
echo "You invesment has not matured yet, check back later.<br><br><a href='investment.php'>Back</a>.";
$h->endpage();
exit;
}
else
{
print "Thank you for collecting your investment.
You have collected ".money_formatter($total).". Where would you like to deposit it?
<table><tr><td>
<form action = 'bank.php' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7;' value = 'The Bank' name = 'depositbank' /> </form></td><td>
<form action = 'index.php' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7;' value = 'Go Home' name = 'gohome' /> </form><td></tr>";
print "</table>";
$db->query(sprintf("UPDATE `users` SET `money` = `money` + '%d',
`userBANKAMMT` = '%d',
`userSTART` = '%d',
`userLENGTH` = '%d',
`userDAYS` = '%d'
WHERE `userid` = ('%u')",
$total, 0, 0, 0, 0, $userid));
}
}
function level_upgrade()
{
global $db,$ir,$c,$h,$userid;
$upgradepp = ($ir['investlevel'] * 50);
$upgrade2 = ($ir['investlevel'] * 20000000 * $ir['investlevel']/2);
$newlvl = ($ir['investlevel']+1);
if($ir['userCONTRACT'] == 0)
{
echo "You need to sign a contract with us before you can upgrade. Click<a href='investment.php?action=buyinvest'>HERE</a> to sign a contract.";
$h->endpage();
exit;
}
elseif($ir['userBANKAMMT'] > 0)
{
echo "You have an investment currently running, you cannot upgrade until it has matured.";
$h->endpage();
exit;
}
elseif($ir['investlevel'] == 10)
{
echo "You are already at Level 10. You can't upgrade any more.<a href='investment.php'>Back</a>";
$h->endpage();
exit;
}
else
{
print "Welcome to the Investment Upgrades.<br><br> You are currently at Level ".$ir['investlevel'].". It will cost you <font color=darkgreen>".money_formatter($upgrade2)."</font> and <font color=darkgreen>".$upgradepp."</font> points to upgrade to Level ".$newlvl.". <br>Would you like to proceed?
<table><tr><td>
<form action = 'investment.php?action=levelupgradesub' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7;' value = 'Upgrade' /> </form> </td><td>
<form action = 'investment.php' method = 'post' />
<input type = 'submit' STYLE='color: black; background-color: #D6D6C7;' value = 'No Thanks' /> </form></td></tr></table>";
}
}
function levelupgrade_sub()
{
global $db,$ir,$c,$h,$userid;
$upgradepp = ($ir['investlevel'] * 50);
$upgrade2 = ($ir['investlevel'] * 20000000 * $ir['investlevel']/2);
$newlvl = ($ir['investlevel']+1);
if($ir['investlevel'] == 1)
{
$upgrade3 = 2500000;
}
if($ir['investlevel'] == 2)
{
$upgrade3 = 25000000;
}
if($ir['investlevel'] == 3)
{
$upgrade3 = 850000000;
}
if($ir['investlevel'] == 4)
{
$upgrade3 = 3225000000;
}
if($ir['investlevel'] == 5)
{
$upgrade3 = 1300000000;
}
if($ir['investlevel'] == 6)
{
$upgrade3 = 4750000000;
}
if($ir['investlevel'] == 7)
{
$upgrade3 = 10500000000;
}
if($ir['investlevel'] == 8)
{
$upgrade3 = 25000000000;
}
if($ir['investlevel'] == 9)
{
$upgrade3 = 75000000000;
}
$upgrade4 = $upgrade3 - $ir['userTOTALAMMT'];
if($ir['userTOTALAMMT'] < $upgrade3)
{
echo "You have not invested enough with us to upgrade, you have invested a total of ".money_formatter($ir['userTOTALAMMT']).".<br>You need to invest ".money_formatter($upgrade3)." total before you can upgrade.<br>
You must invest ".money_formatter($upgrade4)." more.";
$h->endpage();
exit;
}
if($ir['userCONTRACT'] == 0)
{
echo "You need to sign a contract with us before you can upgrade. <br><br>Click<a href='investment.php?action=buyinvest'>HERE</a> to sign a contract.";
$h->endpage();
exit;
}
elseif($ir['userDAYS'] > 0)
{
echo "You have to wait for your current investment to finish before you can upgrade your investment level.<br><br><a href='investment.php'>Back</a>";
$h->endpage();
exit;
}
elseif($ir['investlevel'] == 10)
{
echo "You are already upgraded to maximum interest.<br><br><a href='investment.php'>Back</a>";
$h->endpage();
exit;
}
elseif($ir['money'] < $upgrade2)
{
echo "You don't have enough money to upgrade to Level ".$newlvl.".<br><br><a href='investment.php'>Back</a>";
$h->endpage();
exit;
}
else
{
print "Congratulations, you have upgraded to Level ".$newlvl.". <br><br>
<a href='investment.php'>Back</a>";
$sql = sprintf("UPDATE `users` SET `money` = `money` - '%d',
`crystals` = `crystals` - '%d',
`investlevel` = '%d'
WHERE `userid` = ('%u')",
$upgrade2, $upgradepp, $newlvl, $userid);
$db->query($sql);
}
}
$h->endpage();
exit;
?>
day cron for the contract
$db->query("UPDATE users SET userCONTRACT = userCONTRACT - 1 WHERE userCONTRACT > 0");
Add this link where you want it located
<a href='investment.php'>Investments</a>