-
Posts
277 -
Joined
-
Last visited
-
Days Won
2
Content Type
Profiles
Forums
Events
Everything posted by Richard
-
Re: [Mccodes Lite] Jobs Update: Added Job specials mod. In work.php find: echo '<tr> <td colspan="2" align="center">> [url="work.php?page=promote"]Attempt promotion[/url]</td> <td colspan="3" align="center">> [url="work.php?page=leave"]Leave work[/url]</td> </tr> </table>'; Replace with: echo '<tr> <td colspan="2" align="center">> [url="work.php?page=promote"]Attempt promotion[/url]</td> <td colspan="3" align="center">> [url="work.php?page=leave"]Leave work[/url]</td> </tr> </table> [b]Specials unlocked:[/b] <form action="work_specials.php" method="post" name="specials"> <table width="600" class="table"> <tr> <th colspan="2">Specials</th> </tr>'; $specs = sprintf("SELECT * FROM `work_specials` WHERE `specialJob` = '%u'", $r['workId']); $specs = mysql_query($specs); while($sp = mysql_fetch_array($specs)) { echo '<tr> <td width="95%">[size="1"]'.$sp['specialName'].': <font color="#aa0000"> - '.number_format($sp['specialCost']).' Job points</font>[/size]</td> <td width="5%"><input type="radio" name="id" value="'.$sp['specialId'].'" onclick="document.specials.submit();" /></td> </tr>'; } echo '<tr> <th colspan="2">Note: To attempt to redeem a reward, click on the radio button next to the reward name.</th> </tr> </table> </form>'; Run SQL Data: CREATE TABLE IF NOT EXISTS `work_specials` ( `specialId` int(11) NOT NULL AUTO_INCREMENT, `specialName` varchar(255) NOT NULL DEFAULT '', `specialJob` int(11) NOT NULL DEFAULT '0', `specialCost` int(11) NOT NULL DEFAULT '0', `specialCash` int(11) NOT NULL DEFAULT '0', `specialPoints` int(11) NOT NULL DEFAULT '0', `specialItem` int(11) NOT NULL DEFAULT '0', `specialIAmount` int(11) NOT NULL DEFAULT '0', `specialStrength` decimal(11,4) NOT NULL DEFAULT '0.0000', `specialAgility` decimal(11,4) NOT NULL DEFAULT '0.0000', `specialGuard` decimal(11,4) NOT NULL DEFAULT '0.0000', `specialLabour` decimal(11,4) NOT NULL DEFAULT '0.0000', `specialIntel` decimal(11,6) NOT NULL DEFAULT '0.000000', PRIMARY KEY (`specialId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; Create work_specials.php <?php session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm); $h->menuarea(); echo '<h2>Work Specials</h2>'; if(!isset($_POST['id'])) { echo 'You did not select a Work special to redeem.'; } else { $sql = mysql_query(sprintf("SELECT * FROM `work_specials` WHERE `specialId` = '%u'", abs((int) $_POST['id']))); if(!mysql_num_rows($sql)) { echo 'You cannot redeem a non-existant Work special, do not attempt to abuse the game.'; } else { $r = mysql_fetch_assoc($sql); if($ir['work_points'] < $r['specialCost']) { echo 'You cannot afford this reward right now, come back later.'; } else if($r['specialJob'] != $ir['work']) { echo 'You are not in the correct Job to purchase this reward.'; } else { if($r['specialItem']) { mysql_query(sprintf("INSERT INTO `inventory` (`inv_id`, `inv_itemid`, `inv_userid`, `inv_qty`) VALUES ('NULL', '%d', '%u', '%d')", $r['specialItem'], $ir['memberId'], $ir['specialIAmount'])); } mysql_query(sprintf("UPDATE `users` SET `money` = `money` + '%d', `crystals` = `crystals` + '%d', `work_points` = `work_points` - '%d' WHERE `userid` = '%u'", $r['specialCash'], $r['specialPoints'], $r['specialCost'], $ir['userid'])); mysql_query(sprintf("UPDATE `userstats` SET `strength` = `strength` + '%.6f', `guard` = `guard` + '%.6f', `agility` = `agility` + '%.6f', `IQ` = `IQ` + '%.6f' WHERE `userid` = '%u'", $r['specialCash'], $r['specialStrength'], $r['specialAgility'], $r['specialGuard'], $r['specialIntel'], $ir['userid'])); echo 'You have purchased the '.$r['specialName'].' reward for '.number_format($r['specialCost']).' Job points.'; } } echo ' [url="work.php"]Back to work[/url]'; } $h->endpage(); ?>
-
Re: [Mccodes Lite] Jobs Ok, thanks for testing :) Might need a bit of updating with the look of it, Doesnt look how I hoped it would on lite version. Nevermind though
-
Re: [Mccodes Lite] Jobs Thanks Miniman :) Quick update: Just tested, fixed a couple of small things. Should work now.
-
Re: [Mccodes Lite] Jobs Not sure about that then, I'll just give it a quick test on wamp server, See what happens. Might need to re-run sql, I had to change it a second ago, So re-run work ranks sql
-
Re: [Mccodes Lite] Jobs ...Edited post
-
Re: [Mccodes Lite] Jobs I cant imagine many people using this to be honest, But heres a screenshot:
-
Haven't had a chance to test this, But should be fine. Ok, that should be all of it now, If there are issues with this, Just let me know and I'll fix them. Can be modified to work with Job Specials modification, Screenshot is in below post, This is my first mod in quite a while, should be better than old rubbish ones Run SQL Data: CREATE TABLE IF NOT EXISTS `work` ( `workId` int(11) NOT NULL AUTO_INCREMENT, `workName` varchar(255) NOT NULL DEFAULT '', `workFirst` int(11) NOT NULL DEFAULT '0', `workManager` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (`workId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `work_ranks` ( `rankId` int(11) NOT NULL AUTO_INCREMENT, `rankName` varchar(255) NOT NULL DEFAULT '', `rankJob` int(11) NOT NULL DEFAULT '0', `rankCash` int(11) NOT NULL DEFAULT '0', `rankPoints` int(11) NOT NULL DEFAULT '0', `rankIntel` int(11) NOT NULL DEFAULT '0', `rankLabour` int(11) NOT NULL DEFAULT '0', `rankStrength` int(11) NOT NULL DEFAULT '0', `rankRIntel` int(11) NOT NULL DEFAULT '0', `rankRLabour` int(11) NOT NULL DEFAULT '0', `rankRStrength` int(11) NOT NULL DEFAULT '0', `rankRPoints` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`rankId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; ALTER TABLE `users` ADD `work` int(11) NOT NULL DEFAULT '0'; ALTER TABLE `users` ADD `work_rank` int(11) NOT NULL DEFAULT '0'; ALTER TABLE `users` ADD `work_points` int(11) NOT NULL DEFAULT '0'; Create work.php <?php session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm); $h->menuarea(); echo '<h2>Work</h2>'; switch($_GET['page']) { case 'interview': start_interview(); break; case 'promote': work_promote(); break; case 'leave': leave_work(); break; default: index(); break; } function index() { global $ir; if($ir['work']) { $sql = sprintf("SELECT * FROM `work_ranks` LEFT JOIN `work` ON (`workId` = `rankJob`) WHERE `rankId` = '%u'", abs((int) $ir['work_rank'])); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); echo '[b]Information:[/b] You are now working in the '.$r['workName'].', You will receive $'.number_format($r['rankCash']).' at midnight. You also gain '.number_format($r['rankLabour']).' Labour, '.number_format($r['rankStrength']).' Strength, '.number_format($r['rankIntel']).' Intelligence and '.number_format($r['rankPoints']).' Job points! <table width="600" class="table"> <tr> <td>Rank: <font color="#006600">'.$r['rankName'].'</td> <td>Income: <font color="#006600"> + $'.number_format($r['rankCash']).'</td> <td>Job points: <font color="#006600">'.number_format($ir['work_points']).'</td> </tr> <tr> <td>Manual labour: <font color="#006600">'.number_format($ir['labour']).'</td> <td>Intelligence: <font color="#006600">'.number_format($ir['IQ']).'</td> <td>Strength: <font color="#006600">'.number_format($ir['strength']).'</td> </tr> </table> [b]Ranks:[/b] <table width="600" class="table"> <tr> <th colspan="2">Job</th> <th colspan="3">Stats needed</th> </tr>'; $sql = sprintf("SELECT * FROM `work_ranks` WHERE `rankJob` = '%u'", abs((int) $r['workId'])); $sql = mysql_query($sql); while($in = mysql_fetch_array($sql)) { echo '<tr> <td width="12%">[size="1"][b]Rank: [/b]'.$in['rankName'].'[/size]</td> <td width="12%">[size="1"][b]Income: [/b]$'.number_format($in['rankCash']).' each night[/size]</td> <td width="6%">[size="1"][b]Manual: [/b]'.number_format($in['rankRLabour']).'[/size]</td> <td width="6%">[size="1"][b]Intelligence: [/b]'.number_format($in['rankRIntel']).'[/size]</td> <td width="6%">[size="1"][b]Strength: [/b]'.number_format($in['rankRStrength']).'[/size]</td> </tr>'; } echo '<tr> <td colspan="2" align="center">> [url="work.php?page=promote"]Attempt promotion[/url]</td> <td colspan="3" align="center">> [url="work.php?page=leave"]Leave work[/url]</td> </tr> </table>'; } else { echo '[b]Available Jobs:[/b] <table width="300">'; $sql = mysql_query("SELECT * FROM `work` ORDER BY `workId` DESC"); while($r = mysql_fetch_array($sql)) { echo '<tr> <td width="50%" align="left">'.$r['workName'].'</td> <td width="50%" align="left">> [url="work.php?page=interview&id='.$r['workId'].'"]Start Interview[/url]</td> </tr>'; } echo '</table> </form>'; } } function start_interview() { global $ir; if(!$ir['work']) { $sql = sprintf("SELECT * FROM `work_ranks` LEFT JOIN `work` ON (`workId` = `rankJob`) WHERE `workId` = `workFirst` AND `rankId` = '%u'", abs((int) $_GET['id'])); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); echo '<table width="500"> <tr> <td align="left"> [b]'.$r['workManager'].': [/b][i]Hi there, '.$ir['username'].' is it?[/i] [b]'.$ir['username'].': [/b][i]Yes, I\'m here about a job.[/i] [b]'.$r['workManager'].': [/b][i]*shuffles through papers*[/i] [b]'.$ir['username'].': [/b][i]So, how is it looking so far?[/i] '; if($ir['labour'] >= $r['rankRLabour'] AND $ir['strength'] >= $r['rankRStrength'] AND $ir['IQ'] >= $r['rankRIntel']) { echo '[b]'.$r['workManager'].': [/b][i]You seem qualified enough, Congratulations.[/i] '; mysql_query(sprintf("UPDATE `users` SET `work` = '%u', `work_rank` = '%u' WHERE `userid` = '%u'", $r['workId'], $r['workFirst'], $ir['userid'])); } else { echo '[b]'.$r['workManager'].': [/b][i]You do not meet our requirements for this job, Come back another time.[/i] '; } echo '</td> </tr> </table>'; } else { echo 'You are working at this time, leave before starting a new Job!'; } echo ' [url="work.php"]Work center[/url]'; } function leave_work() { global $ir; if(!$ir['work']) { echo 'You are not working right now, go and find a job before attempting to leave one.'; } else if(!isset($_GET['confirm'])) { echo 'You are about to leave the current job, click to continue. [url="work.php?page=leave&confirm=1"]Leave work[/url]'; } else { echo 'You decided to leave the current job, The manager doesn\'t seem too bothered.'; mysql_query(sprintf("UPDATE `users` SET `work` = '0', `work_rank` = '0' WHERE `userid` = '%u'", $ir['userid'])); } echo ' [url="town.php"]Head to town[/url]'; } function work_promote() { global $ir; $sql = sprintf("SELECT * FROM `work_ranks` WHERE `rankId` > '%u' AND `rankRIntel` <= '%u' AND `rankRLabour` <= '%u' AND `rankRStrength` <= '%u' AND `rankRPoints` <= '%u' ORDER BY `rankCash` DESC LIMIT 1", $ir['work_rank'], $ir['IQ'], $ir['labour'], $ir['strength'], $ir['work_points']); $sql = mysql_query($sql); if(!mysql_num_rows($sql)) { echo 'You cannot be promoted at this time.'; } else { $r = mysql_fetch_array($sql); mysql_query(sprintf("UPDATE `users` SET `work_rank` = '%u', `work_points` = `work_points` - '%u' WHERE `userid` = '%u'", $r['rankId'], $r['rankRPoints'], $ir['userid'])); echo 'You have been promoted to the rank of '.$r['rankName'].'!'; } echo ' [url="work.php"]Back to work[/url]'; } $h->endpage(); ?> Cron: mysql_query("UPDATE users u LEFT JOIN userstats us ON us.userid = u.userid LEFT JOIN work w ON w.workId = u.work LEFT JOIN work_ranks wr ON u.work_rank = wr.rankId SET u.money = u.money + wr.rankCash, u.work_points = u.work_points + wr.rankPoints, us.strength = us.strength + wr.rankStrength, us.labour = us.labour + wr.rankLabour, us.IQ = us.IQ + wr.rankIntel WHERE u.work > 0 AND u.work_rank > 0"); . Warning: The above code had to be modifed to work with Mccodes, so a few bugs might come up. Just let me know if there are problems :)
-
Re: [mccodes] Hospital Time Ok, since I cant change my last post, I'll add a new one. New function: function time_format($time) { $days = floor($time / 60 / 24); $hours = floor($time / 60) % 24; $mins = $time % 60; if($mins < 10) { $mins = "0".$mins; } else { $mins = $mins; } if($days) { $days = "$days days, "; } else { $days = ""; } if($hours) { $hours = "$hours hours, "; } else { $hours = ""; } if($mins == 1) { $mins = "< 1 min"; } else { $mins = "$mins mins"; } return $days.$hours.$mins; } Might be a bit easier to work with now, To display hospital time would be: echo time_format($r['hospital']).' Just a simple function which should make the time display look a bit tidier. Hope it helps
-
Re: [mccodes] Hospital Time Just thought I'd make this a bit easier, function time_format($time) { $t4 = floor($time/60/24); $t1 = floor($time/60) % 24; $t2 = $time % 60; if($t2 < 10) { $t3 = "0".$t2; } else { $t3 = $t2; } if($t4) { $t5 = "$t4 days, "; } else { $t5 = ""; } if($t1) { $t1 = "$t1 hours, "; } else { $t1 = ""; } if($t2 == 1) { $t2 = "< 1 min"; } else { $t2 = "$t2 mins"; } return $t5.$t1.$t2; } Put that into global_func.php Then, to display a time as mins, hours and days, Just put: '.time_format(INSERT VARIABLE HERE).' An example of the variable could be $r['memberHospital'] or $r['memberJail'] etc. Hope this helps a bit
-
Re: [mccode] Gangs Nice job PsyChoTic. Thanks for contributing to this mod :)
-
Re: [mccode] Gangs I'll post some a little later, and yes it was. It took me just under 3 days :P
-
Re: [mccodes v2] Gang Pictures I've never heard of him stealing anything. I can't be certain though.
-
Re: [mccodes v2] Gang Pictures It's nice to see that you have put the effort into making this mod, although by now I'm sure most people already have it. As jamboy said, it could just be taken from my gangs mod. Maybe you could expand upon this idea and make it unique though? :)
-
Re: [mccode] Advanced Properties It sounds like you are doing a great job of fixing the little bugs in this mod, well done :) Feel free to expand upon it as much as you like, its always good to try out new and interesting ideas. Unfortunately I can't offer much support right now as I have quite a bit of coursework to get done, good luck anyway :)
-
Re: [mccode] Gangs V2 already comes with gangs, I would suggest that you keep that one, its a little better
-
Re: [mccode] Gangs Update: Armory Run SQL: CREATE TABLE `faction_armoury` ( `fiID` int(11) NOT NULL auto_increment, `fiFACTION` int(11) NOT NULL default '0', `fiUSER` int(11) NOT NULL, `fiITEM` int(11) NOT NULL default '0', `fiAMOUNT` bigint(20) NOT NULL default '0', PRIMARY KEY (`fiID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; Add cases in manage_faction.php: case 'armory': donate_armory(); break; case 'agive': give_armory(); break; Add functions in manage_faction.php: function donate_armory() { global $ir,$c,$userid,$h; if ($_POST['amount'] AND $_POST['item']) { $_POST['amount'] = abs((int) $_POST['amount']); $_POST['item'] = abs((int) $_POST['item']); $sql = sprintf("SELECT * FROM `inventory` inv LEFT JOIN `items` i ON (i.itmid = inv.inv_itemid) WHERE inv_userid = %d AND (inv.inv_id = %u)", $ir['userid'], mysql_real_escape_string($_POST['item'])); $q = mysql_query($sql); $ir['itmHAVE'] = mysql_num_rows($q); $r = mysql_fetch_array($q); if(!$ir['itmHAVE']) { print " You do not own that item. <hr width='90%'>> [url='manage_faction.php?step=armory']Back[/url]<hr width='90%'>"; } else if($r['inv_qty'] < $_POST['amount']) { print " You dont have enough of this item. <hr width='90%'>> [url='manage_faction.php?step=armory']Back[/url]<hr width='90%'>"; } else { $ins = sprintf("INSERT INTO `faction_armoury` (`fiID`, `fiFACTION`, `fiUSER`, `fiITEM`, `fiAMOUNT`) VALUES ('NULL','%d', '%d', '%d', '%d')", $ir['faction'], $ir['userid'], $r['itmid'], $_POST['amount']); if ($r['inv_qty'] > $_POST['amount']) { $use = sprintf("UPDATE `inventory` SET inv_qty = inv_qty - %d WHERE inv_userid = %d AND (inv_id = %u)", mysql_real_escape_string($_POST['amount']), mysql_real_escape_string($ir['userid']), mysql_real_escape_string($_POST['item'])); } else { $use = sprintf("DELETE FROM `inventory` WHERE (inv_id = %u)", mysql_real_escape_string($_POST['item'])); } mysql_query($ins); mysql_query($use); print " You donated ".number_format($_POST['amount'])." {$r['itmname']}'s to the faction. <hr width='90%'>> [url='manage_faction.php?step=armory']Back[/url]<hr width='90%'>"; } } else { $sql = sprintf("SELECT * FROM `faction_armoury` fi LEFT JOIN `items` i ON (i.itmid = fi.fiITEM) LEFT JOIN `users` u ON (u.userid = fi.fiUSER) WHERE (fi.fiFACTION = %u)", $ir['faction']); $q = mysql_query($sql); print "<table width='90%' cellspacing='1'><tr bgcolor='#AAAAAA'> <th width='40%'>Item</th><th width='40%'>Donator</th><th width='20%'>Amount</th></tr>"; while ($r = mysql_fetch_array($q)) { print "<tr><td>{$r['itmname']}</td><td>[url='viewuser.php?u={$r[']{$r['username']}[/url]</td><td>{$r['fiAMOUNT']}</td></tr>"; } print "</table> [b]Donate:[/b] <form action='manage_faction.php?step=armory' method='post'> <select name='item' type='dropdown'> <option value='0'>None</option>"; $itm = sprintf("SELECT * FROM `inventory` inv LEFT JOIN `items` i ON (i.itmid = inv.inv_itemid) WHERE (inv.inv_userid = %u)", $ir['userid']); $itm = mysql_query($itm); while($it = mysql_fetch_array($itm)) { print "<option value='{$it['inv_id']}'>{$it['itmname']}</option>"; } print "</select> <input type='text' name='amount' size='5' maxlength='3'> <input type='submit' value='Submit'></form>"; print "<hr width='90%'>> [url='manage_faction.php?step=armory']Back[/url]<hr width='90%'>"; } } function give_armory() { global $ir,$c,$userid,$h; $sql2 = sprintf("SELECT * FROM `factions` fa WHERE (faID = %u)", mysql_real_escape_string($ir['faction'])); $q2 = mysql_query($sql2); $r2 = mysql_fetch_array($q2); if ($r2['faLEADER'] != $userid) { print " You are not authorised to access this page. <hr width='90%'>> [url='factions.php']Back[/url]<hr width='90%'>"; } else if ($_POST['amount'] AND $_POST['item'] AND $_POST['user']) { $_POST['amount'] = abs((int) $_POST['amount']); $_POST['item'] = abs((int) $_POST['item']); $_POST['user'] = abs((int) $_POST['user']); $sql = sprintf("SELECT * FROM `faction_armoury` fi LEFT JOIN `items` i ON (i.itmid = fi.fiITEM) LEFT JOIN `users` u ON (u.userid = %d) WHERE fiFACTION = %d AND (fi.fiID = %u)", $_POST['user'], $ir['faction'], mysql_real_escape_string($_POST['item'])); $q = mysql_query($sql); $ir['itmHAVE'] = mysql_num_rows($q); $r = mysql_fetch_array($q); if(!$ir['itmHAVE']) { print " Your faction does not own that item. <hr width='90%'>> [url='manage_faction.php?step=armory']Back[/url]<hr width='90%'>"; } else if($r['fiAMOUNT'] < $_POST['amount']) { print " Your faction does not have enough of this item. <hr width='90%'>> [url='manage_faction.php?step=armory']Back[/url]<hr width='90%'>"; } else { $ins = sprintf("INSERT INTO `inventory` (`inv_id`, `inv_itemid`, `inv_userid`, `inv_qty`) VALUES ('NULL','%d', '%d', '%d')", $_POST['item'], $_POST['user'], $_POST['amount']); if ($r['fiAMOUNT'] > $_POST['amount']) { $use = sprintf("UPDATE `faction_armoury` SET fiAMOUNT = fiAMOUNT - %d WHERE fiFACTION = %d AND (fiID = %u)", mysql_real_escape_string($_POST['amount']), mysql_real_escape_string($ir['faction']), mysql_real_escape_string($_POST['item'])); } else { $use = sprintf("DELETE FROM `faction_armoury` WHERE (fiID = %u)", mysql_real_escape_string($_POST['item'])); } mysql_query($ins); mysql_query($use); print " You gave ".number_format($_POST['amount'])." {$r['itmname']}'s to {$r['username']}. <hr width='90%'>> [url='manage_faction.php?step=armory']Back[/url]<hr width='90%'>"; } } else { $sql = sprintf("SELECT * FROM `faction_armoury` fi LEFT JOIN `items` i ON (i.itmid = fi.fiITEM) LEFT JOIN `users` u ON (u.userid = fi.fiUSER) WHERE (fi.fiFACTION = %u)", $ir['faction']); $q = mysql_query($sql); print "<table width='90%' cellspacing='1'><tr bgcolor='#AAAAAA'> <th width='40%'>Item</th><th width='40%'>Donator</th><th width='20%'>Amount</th></tr>"; while ($r = mysql_fetch_array($q)) { print "<tr><td>{$r['itmname']}</td><td>[url='viewuser.php?u={$r[']{$r['username']}[/url]</td><td>{$r['fiAMOUNT']}</td></tr>"; } print "</table> [b]Give:[/b] <form action='manage_faction.php?step=agive' method='post'> <select name='item' type='dropdown'> <option value='0'>None</option>"; $itm = sprintf("SELECT * FROM `faction_armoury` fi LEFT JOIN `items` i ON (i.itmid = fi.fiITEM) WHERE (fi.fiFACTION = %u)", $ir['faction']); $itm = mysql_query($itm); while($it = mysql_fetch_array($itm)) { print "<option value='{$it['fiID']}'>{$it['itmname']}</option>"; } print "</select> <select name='user' type='dropdown'> <option value='0'>None</option>"; $usr = sprintf("SELECT * FROM `users` WHERE (faction = %u)", $ir['faction']); $usr = mysql_query($usr); while($us = mysql_fetch_array($usr)) { print "<option value='{$us['userid']}'>{$us['username']}</option>"; } print "</select> <input type='text' name='amount' size='5' maxlength='3'> <input type='submit' value='Submit'></form>"; print "<hr width='90%'>> [url='manage_faction.php']Back[/url]<hr width='90%'>"; } } Add links: [url='manage_faction.php?step=armory']Faction Armory[/url] < [url='manage_faction.php?step=agive']Give Items[/url] < Enjoy!
-
Re: [mccode] Advanced Properties Are you using the second cron I posted? That works for me, I'll work on it a little later.
-
Re: [mccode] Advanced Properties Use the one from the second time I posted it, should fix your problems
-
Re: [mccodes lite] Advanced Properties I have this mod currently running on my wamp server, so far I have had no problems with it. Everything shows as it should, so maybe you have done something wrong with the start of the file. Sorry about that.
-
Re: [mccodes lite] Advanced Properties Sorry, replace: <?php session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.*,jb.*,jr.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN jobs jb ON jb.jbID=u.job LEFT JOIN jobranks jr ON jr.jrID=u.jobrank WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm); $h->menuarea(); with: <?php /* MCCodes Lite criminal.php Rev 1.0.0 Copyright (C) 2006 Dabomstew This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm); $h->menuarea(); Ignore the jobs thing for now, I havent finished work on that mod yet :)
-
Re: [mccodes lite] Advanced Properties I haven't had chance to test the cron properly, but I ran it manually a couple of times and it seemed to work fine :) Thanks for commenting and if you find any errors just let me know
-
Re: [mccodes lite] Advanced Properties I think I've finished the mod now, enjoy! Add into cron_day.php $sql = sprintf("SELECT * FROM userhouses uh LEFT JOIN users u ON u.userid = uh.uhRENTER LEFT JOIN houses h ON h.hID = uh.uhHOUSE WHERE uh.uhRENTER > 0"); $sql = mysql_query($sql); while ($r = mysql_fetch_array($sql)) { mysql_query("UPDATE userhouses SET uhRDAYS = uhRDAYS - 1 WHERE uhRDAYS > 0",$c); mysql_query("UPDATE users SET money = money - {$r['uhRENT']} WHERE userid = {$r['uhRENTER']}",$c); mysql_query("UPDATE users SET money = money + {$r['uhRENT']} WHERE userid = {$r['uhUSER']}",$c); if ($r['uhRDAYS'] == 0) { $sql2 = sprintf("INSERT INTO `events` (`evID`, `evUSER`, `evTIME`, `evREAD`, `evTEXT`) VALUES ('NULL','%d', '%d', '%d', 'Your period of renting the {$r['hNAME']} is over.')", $r['uhRENTER'], time(), 0); mysql_query($sql2); mysql_query("UPDATE userhouses SET uhRENTER = 0, uhRENT = 0, uhRDAYS = 0",$c); mysql_query("UPDATE users SET maxwill = 100, house = 0, WHERE house = {$r['uhID']}",$c); } } Run SQL: ALTER TABLE users ADD house INT (11) NOT NULL DEFAULT 0; ALTER TABLE houses ADD hUPKEEP INT (11) NOT NULL DEFAULT 0; ALTER TABLE houses ADD hIMAGE VARCHAR (255) NOT NULL DEFAULT 0; CREATE TABLE `userhouses` ( `uhID` int(11) NOT NULL auto_increment, `uhUSER` int(11) NOT NULL, `uhHOUSE` int(11) NOT NULL, `uhWILL` int(11) NOT NULL, `uhRENT` int(11) NOT NULL, `uhRDAYS` int(11) NOT NULL, `uhRENTER` int(11) NOT NULL, `uhUPGRADES` int(11) NOT NULL, PRIMARY KEY (`uhID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; Create properties.php <?php /* MCCodes Lite criminal.php Rev 1.0.0 Copyright (C) 2006 Dabomstew This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm); $h->menuarea(); print "<font face='Arial' size='4'>Properties</font><hr width='90%'>"; switch ($_GET['step']) { case 'move': move_in(); break; case 'info': house_info(); break; case 'estate': estate_agent(); break; case 'sell': sell_house(); break; case 'rent': rent_house(); break; case 'give': give_house(); break; case 'market': rental_market(); break; case 'remove': market_remove(); break; default: user_houses(); break; } function user_houses() { global $ir,$c,$userid,$h; $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE uh.uhRENT = 0 AND u.house != uh.uhID AND (uh.uhUSER = %u)", $ir['userid']); $sql = mysql_query($sql); print "<table width='90%'><tr><td width='50%' align='center'> > [url='properties.php?step=estate']Estate Agent[/url]</td> <td width='50%' align='center'> > [url='properties.php?step=market']Rental Market[/url]</td></tr> </table><hr width='90%'>"; print "<table width='75%' cellspacing='1'>"; while($r = mysql_fetch_array($sql)) { print "<tr><td>[img={$r[]</td> <td> [b]Property: [/b]{$r['hNAME']} [b]Owner: [/b][url='viewuser.php?u={$r[']{$r['username']}[/url] [b]Upkeep: [/b]".money_formatter($r['hUPKEEP'])." per day [b]Will: [/b]".number_format($r['uhWILL'])." [[url='properties.php?step=move&XID={$r[']Move in[/url]] [[url='properties.php?step=info&XID={$r[']Info[/url]] [[url='properties.php?step=sell&XID={$r[']Sell[/url]] [[url='properties.php?step=rent&XID={$r[']Lease[/url]] [[url='properties.php?step=give&XID={$r[']Give[/url]] [[url='properties.php?step=upgrade&XID={$r[']Upgrade[/url]] </td></tr>"; } if ($ir['house'] || $ir['maxwill'] == 100) { print "<tr><td>[img=images/houses/house_1.png]</td> <td> [b]Property: [/b]Shack [b]Owner: [/b][url='viewuser.php?u={$ir[']{$ir['username']}[/url] [b]Will: [/b]100 "; if ($ir['maxwill'] != 100) { print "[[url='properties.php?step=move&XID=0']Move in[/url]] "; } print "</td></tr>"; } print "</table><hr width='90%'>"; $rent = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE {$ir['house']} != uh.uhID AND (uh.uhRENTER = %u)", $ir['userid']); $rent = mysql_query($rent); print "[b]Rented Houses:[/b] <table width='75%' cellspacing='1'>"; while($rn = mysql_fetch_array($rent)) { print "<tr><td>[img={$rn[]</td> <td> [b]Property: [/b]{$rn['hNAME']} [b]Owner: [/b][url='viewuser.php?u={$rn[']{$rn['username']}[/url] [b]Upkeep: [/b]".money_formatter($rn['hUPKEEP'])." per day [b]Will: [/b]".number_format($rn['uhWILL'])." [[url='properties.php?step=move&XID={$rn[']Move in[/url]] [[url='properties.php?step=info&XID={$rn[']Info[/url]] </td></tr>"; } print "</table><hr width='90%'>"; } function move_in() { global $ir,$c,$userid,$h; $_GET['XID'] = abs((int) $_GET['XID']); $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE (uh.uhUSER = %d OR uh.uhRENTER = %d) AND (uh.uhID = %u)", $ir['userid'], $ir['userid'], $_GET['XID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if ($_GET['XID'] == '0') { $move = sprintf("UPDATE `users` SET house = %d, maxwill = %d WHERE (`userid` = %u)", 0, 100, $ir['userid']); mysql_query($move); print " You moved into the [b]Shack[/b]. You now have a maximum will of [b]100[/b]. <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else if(!mysql_num_rows($sql)) { print " You cannot move into a non-existant house! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else { $move = sprintf("UPDATE `users` SET house = %d, maxwill = %d WHERE (`userid` = %u)", $_GET['XID'], $r['uhWILL'], $ir['userid']); mysql_query($move); print " You moved into the [b]{$r['hNAME']}[/b]. You now have a maximum will of [b]".number_format($r['uhWILL'])."[/b]. <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } function house_info() { global $ir,$c,$userid,$h; $_GET['XID'] = abs((int) $_GET['XID']); $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE uh.uhUSER = %d AND (uh.uhID = %u)", $ir['userid'], $_GET['XID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if(!mysql_num_rows($sql)) { print " This house does not belong to you! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else { print " [b]Property: [/b]{$r['hNAME']} [b]Owner: [/b][url='viewuser.php?u={$r[']{$r['username']}[/url] [b]Market Price: [/b]".money_formatter($r['hPRICE'])." [b]Upkeep: [/b]".money_formatter($r['hUPKEEP'])." per day [b]Will: [/b]".number_format($r['uhWILL'])." <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } function sell_house() { global $ir,$c,$userid,$h; $_GET['XID'] = abs((int) $_GET['XID']); $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE uh.uhUSER = %d AND (uh.uhID = %u)", $ir['userid'], $_GET['XID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if(!mysql_num_rows($sql)) { print " This house does not belong to you! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else if ($r['uhRENTER'] > 0) { print " This house is being rented at this time! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else { $sell = sprintf("UPDATE `users` SET money = money + %d WHERE (`userid` = %u)", $r['hPRICE'], $ir['userid']); $del = sprintf("DELETE FROM `userhouses` WHERE (`uhID` = %u)", $_GET['XID']); mysql_query($sell); mysql_query($del); print " You sold the [b]{$r['hNAME']}[/b] for [b]".money_formatter($r['hPRICE'])."[/b]! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } function estate_agent() { global $ir,$c,$userid,$h; $_GET['XID'] = abs((int) $_GET['XID']); if ($_GET['XID']) { $sql = sprintf("SELECT * FROM `houses` WHERE (hID = %u)", $_GET['XID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if(!mysql_num_rows($sql)) { print " This house does not exist! <hr width='90%'>> [url='properties.php?step=estate']Estate Agent[/url]<hr width='90%'>"; } else if($ir['money'] < $r['hPRICE']) { print " You cannot afford to buy this house! <hr width='90%'>> [url='properties.php?step=estate']Estate Agent[/url]<hr width='90%'>"; } else if($_GET['XID'] == '1') { print " You cannot buy another Shack! <hr width='90%'>> [url='properties.php?step=estate']Estate Agent[/url]<hr width='90%'>"; } else { $buy = sprintf("UPDATE `users` SET money = money - %d WHERE (`userid` = %u)", $r['hPRICE'], $ir['userid']); $ins = sprintf("INSERT INTO `userhouses` (`uhID`, `uhUSER`, `uhHOUSE`, `uhWILL`) VALUES ('NULL','%d', '%d', '%d')", $ir['userid'], $r['hID'], $r['hWILL']); mysql_query($buy); mysql_query($ins); print " You bought the [b]{$r['hNAME']}[/b] for [b]".money_formatter($r['hPRICE'])."[/b]! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } else { $sql = sprintf("SELECT * FROM houses WHERE hID > 1 ORDER BY hWILL ASC"); $sql = mysql_query($sql); print "<table width='90%' cellspacing='1'> <tr bgcolor='#AAAAAA'><th>Name</th><th>Will</th><th>Price</th></tr>"; while($r = mysql_fetch_array($sql)) { print "<tr><td>[url='properties.php?step=estate&XID={$r[']{$r['hNAME']}[/url]</td><td>".number_format($r['hWILL'])."</td><td>".money_formatter($r['hPRICE'])."</td></tr>"; } print "</table><hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } function rental_market() { global $ir,$c,$userid,$h; $_GET['XID'] = abs((int) $_GET['XID']); if ($_GET['XID']) { $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE (uh.uhID = %u)", $_GET['XID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if(!mysql_num_rows($sql)) { print " This house does not exist! <hr width='90%'>> [url='properties.php?step=market']Market[/url]<hr width='90%'>"; } else if($r['uhUSER'] == $ir['userid']) { print " This house already belongs to you! <hr width='90%'>> [url='properties.php?step=market']Market[/url]<hr width='90%'>"; } else if($ir['money'] < $r['uhRENT']) { print " You cannot afford to rent this house! <hr width='90%'>> [url='properties.php?step=market']Market[/url]<hr width='90%'>"; } else { $sel = sprintf("UPDATE `users` SET money = money - %d WHERE (`userid` = %u)", $r['uhRENT'], $ir['userid']); $rent = sprintf("UPDATE `userhouses` SET uhRENTER = %d WHERE (`uhID` = %u)", $ir['userid'], $_GET['XID']); mysql_query($sel); mysql_query($rent); print " You are now renting the [b]{$r['hNAME']}[/b] for [b]".money_formatter($r['uhRENT'])."[/b] per day! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } else { $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE uh.uhRENTER = 0 AND uh.uhRENT > 0"); $sql = mysql_query($sql); print "<table width='90%' cellspacing='1'> <tr bgcolor='#AAAAAA'><th>Property</th><th>Owner</th><th>Will</th><th>Cost</th><th>Daily Cost</th><th>Rental Period</th><th>Rent</th></tr>"; while($r = mysql_fetch_array($sql)) { print "<tr><td>{$r['hNAME']}</td><td>[url='viewuser.php?u={$r[']{$r['username']}[/url]</td><td>".number_format($r['uhWILL'])."</td><td>".money_formatter($r['uhRENT']*$r['uhRDAYS'])."</td><td>".money_formatter($r['uhRENT'])."</td><td>".number_format($r['uhRDAYS'])." days</td><td>[url='properties.php?step=market&XID={$r[']Rent[/url]"; if ($r['uhUSER'] == $ir['userid']) { print " | [url='properties.php?step=remove&XID={$r[']Remove[/url]"; } print "</td></tr>"; } print "</table><hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } function rent_house() { global $ir,$c,$userid,$h; $_GET['XID'] = abs((int) $_GET['XID']); $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE uh.uhUSER = %d AND (uh.uhID = %u)", $ir['userid'], $_GET['XID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if (!$_GET['XID']) { print " You must select a house to add to the rental market! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else if ($r['uhUSER'] != $ir['userid']) { print " This house does not belong to you! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else if ($r['uhRENT'] > 0) { print " This house is already on the market! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else if ($_POST['cost'] AND $_POST['amount']) { $_POST['house'] = abs((int) $_POST['house']); $_POST['cost'] = abs((int) $_POST['cost']); $_POST['amount'] = abs((int) $_POST['amount']); $sub = sprintf("UPDATE `userhouses` SET uhRDAYS = %d, uhRENT = %d WHERE (uhID = %u)", $_POST['amount'], $_POST['cost'], $_POST['house']); mysql_query($sub); print " The [b]{$r['hNAME']}[/b] was added to the rental market! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else { print " <form action='properties.php?step=rent&XID={$_GET['XID']}' method='post'> <input type='hidden' name='house' value='{$_GET['XID']}' /> <table width='50% cellspacing='1'> <tr><td width='50%'>Daily Cost:</td><td width='50%'><input type='text' name='cost' maxlength='10' /></td></tr> <tr><td width='50%'>Rental Period:</td><td width='50%'><input type='text' name='amount' maxlength='3' /></td></tr> <tr><td colspan='2'><input type='submit' value='Submit' /></td></tr></table></form> <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } function market_remove() { global $ir,$c,$userid,$h; $_GET['XID'] = abs((int) $_GET['XID']); if ($_GET['XID']) { $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE (uh.uhID = %u)", $_GET['XID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if(!mysql_num_rows($sql)) { print " This house does not exist! <hr width='90%'>> [url='properties.php?step=market']Market[/url]<hr width='90%'>"; } else if($r['uhUSER'] != $ir['userid']) { print " This house does not belong to you! <hr width='90%'>> [url='properties.php?step=market']Market[/url]<hr width='90%'>"; } else if(!$r['uhRENT']) { print " This house is not on the rental market! <hr width='90%'>> [url='properties.php?step=market']Market[/url]<hr width='90%'>"; } else { $rem = sprintf("UPDATE `userhouses` SET uhRENT = %d, uhRDAYS = %d WHERE (`uhID` = %u)", 0, 0, $_GET['XID']); mysql_query($rem); print " You removed the [b]{$r['hNAME']}[/b] from the rental market! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } else { print " You did not select a house to remove. <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } function give_house() { global $ir,$c,$userid,$h; $_GET['XID'] = abs((int) $_GET['XID']); $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE uh.uhUSER = %d AND (uh.uhID = %u)", $ir['userid'], $_GET['XID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if (!$_GET['XID']) { print " You must select a house to give away! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else if ($r['uhUSER'] != $ir['userid']) { print " This house does not belong to you! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else if ($r['uhRENTER'] > 0) { print " This house is being rented at this time! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else if ($_POST['user'] AND $_GET['XID']) { $_POST['house'] = abs((int) $_POST['house']); $_POST['user'] = abs((int) $_POST['user']); $sub = sprintf("UPDATE `userhouses` SET uhUSER = %d WHERE (uhID = %u)", $_POST['user'], $_POST['house']); mysql_query($sub); print " You have given the [b]{$r['hNAME']}[/b] to {$r['username']}! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else { print " <form action='properties.php?step=give&XID={$_GET['XID']}' method='post'> <input type='hidden' name='house' value='{$_GET['XID']}' /> <table width='50% cellspacing='1'> <tr><td width='50%'>User's ID:</td><td width='50%'><input type='text' name='user' maxlength='5' /></td></tr> <tr><td colspan='2'><input type='submit' value='Submit' /></td></tr></table></form> <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } $h->endpage(); ?>
-
Re: [mccodes lite] Advanced Properties The rentals on this mod aren't quite finished yet, I'll get to that a little later and update first post. Multiple housing should work perfectly until then. Thanks for commenting radio_active, I only started working with LITE a couple of weeks ago but I prefer it over V2 :)
-
This is more secure than the last one, I have spent much more time getting it right. I'll be adding more to this in the future. Enjoy! Add into cron_day.php $sql = sprintf("SELECT * FROM userhouses uh LEFT JOIN users u ON u.userid = uh.uhRENTER WHERE uh.uhRENTER > 0"); $sql = mysql_query($sql); while ($r = mysql_fetch_array($sql)) { mysql_query("UPDATE userhouses SET uhRDAYS = uhRDAYS - 1 WHERE uhRDAYS > 0",$c); mysql_query("UPDATE users SET money = money - {$r['uhRENT']} WHERE userid = {$r['uhRENTER']}",$c); mysql_query("UPDATE userhouses SET uhRENTER = uhUSER WHERE uhRDAYS == 0",$c); } Run SQL: ALTER TABLE users ADD house INT (11) NOT NULL DEFAULT 0; ALTER TABLE houses ADD hUPKEEP INT (11) NOT NULL DEFAULT 0; ALTER TABLE houses ADD hIMAGE VARCHAR (255) NOT NULL DEFAULT 0; CREATE TABLE `userhouses` ( `uhID` int(11) NOT NULL auto_increment, `uhUSER` int(11) NOT NULL, `uhHOUSE` int(11) NOT NULL, `uhWILL` int(11) NOT NULL, `uhRENT` int(11) NOT NULL, `uhRDAYS` int(11) NOT NULL, `uhRENTER` int(11) NOT NULL, `uhUPGRADES` int(11) NOT NULL, PRIMARY KEY (`uhID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; Create properties.php <?php /* MCCodes Lite criminal.php Rev 1.0.0 Copyright (C) 2006 Dabomstew This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm); $h->menuarea(); print "<font face='Arial' size='4'>Properties</font><hr width='90%'>"; switch ($_GET['step']) { case 'move': move_in(); break; case 'info': house_info(); break; case 'estate': estate_agent(); break; case 'sell': sell_house(); break; case 'market': rental_market(); break; default: user_houses(); break; } function user_houses() { global $ir,$c,$userid,$h; $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE uh.uhRENT = 0 AND u.house != uh.uhID AND (uh.uhUSER = %u)", $ir['userid']); $sql = mysql_query($sql); print "<table width='90%'><tr><td width='50%' align='center'> > [url='properties.php?step=estate']Estate Agent[/url]</td> <td width='50%' align='center'> > [url='properties.php?step=market']Rental Market[/url]</td></tr> </table><hr width='90%'>"; print "<table width='75%' cellspacing='1'>"; while($r = mysql_fetch_array($sql)) { print "<tr><td>[img={$r[]</td> <td> [b]Property: [/b]{$r['hNAME']} [b]Owner: [/b][url='viewuser.php?u={$r[']{$r['username']}[/url] [b]Upkeep: [/b]".money_formatter($r['hUPKEEP'])." per day [b]Will: [/b]".number_format($r['uhWILL'])." [[url='properties.php?step=move&XID={$r[']Move in[/url]] [[url='properties.php?step=info&XID={$r[']Info[/url]] [[url='properties.php?step=sell&XID={$r[']Sell[/url]] [[url='properties.php?step=upgrade&XID={$r[']Upgrade[/url]] </td></tr>"; } if ($ir['house'] || $ir['maxwill'] == 100) { print "<tr><td>[img=images/houses/house_1.png]</td> <td> [b]Property: [/b]Shack [b]Owner: [/b][url='viewuser.php?u={$ir[']{$ir['username']}[/url] [b]Will: [/b]100 "; if ($ir['maxwill'] != 100) { print "[[url='properties.php?step=move&XID=0']Move in[/url]] "; } print "</td></tr>"; } print "</table><hr width='90%'>"; } function move_in() { global $ir,$c,$userid,$h; $_GET['XID'] = abs((int) $_GET['XID']); $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE (uh.uhUSER = %d OR uh.uhRENTER = %d) AND (uh.uhID = %u)", $ir['userid'], $ir['userid'], $_GET['XID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if ($_GET['XID'] == '0') { $move = sprintf("UPDATE `users` SET house = %d, maxwill = %d WHERE (`userid` = %u)", 0, 100, $ir['userid']); mysql_query($move); print " You moved into the [b]Shack[/b]. You now have a maximum will of [b]100[/b]. <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else if(!mysql_num_rows($sql)) { print " You cannot move into a non-existant house! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else { $move = sprintf("UPDATE `users` SET house = %d, maxwill = %d WHERE (`userid` = %u)", $_GET['XID'], $r['uhWILL'], $ir['userid']); mysql_query($move); print " You moved into the [b]{$r['hNAME']}[/b]. You now have a maximum will of [b]{$r['uhWILL']}[/b]. <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } function house_info() { global $ir,$c,$userid,$h; $_GET['XID'] = abs((int) $_GET['XID']); $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE uh.uhUSER = %d AND (uh.uhID = %u)", $ir['userid'], $_GET['XID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if(!mysql_num_rows($sql)) { print " This house does not belong to you! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else { print " [b]Property: [/b]{$r['hNAME']} [b]Owner: [/b][url='viewuser.php?u={$r[']{$r['username']}[/url] [b]Market Price: [/b]".money_formatter($r['hPRICE'])." [b]Upkeep: [/b]".money_formatter($r['hUPKEEP'])." per day [b]Will: [/b]".number_format($r['uhWILL'])." <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } function sell_house() { global $ir,$c,$userid,$h; $_GET['XID'] = abs((int) $_GET['XID']); $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE uh.uhUSER = %d AND (uh.uhID = %u)", $ir['userid'], $_GET['XID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if(!mysql_num_rows($sql)) { print " This house does not belong to you! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } else { $sell = sprintf("UPDATE `users` SET money = money + %d WHERE (`userid` = %u)", $r['hPRICE'], $ir['userid']); $del = sprintf("DELETE FROM `userhouses` WHERE (`uhID` = %u)", $_GET['XID']); mysql_query($sell); mysql_query($del); print " You sold the [b]{$r['hNAME']}[/b] for [b]".money_formatter($r['hPRICE'])."[/b]! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } function estate_agent() { global $ir,$c,$userid,$h; $_GET['XID'] = abs((int) $_GET['XID']); if ($_GET['XID']) { $sql = sprintf("SELECT * FROM `houses` WHERE (hID = %u)", $_GET['XID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if(!mysql_num_rows($sql)) { print " This house does not exist! <hr width='90%'>> [url='properties.php?step=estate']Estate Agent[/url]<hr width='90%'>"; } else if($ir['money'] < $r['hPRICE']) { print " You cannot afford to buy this house! <hr width='90%'>> [url='properties.php?step=estate']Estate Agent[/url]<hr width='90%'>"; } else if($_GET['XID'] == '1') { print " You cannot buy another Shack! <hr width='90%'>> [url='properties.php?step=estate']Estate Agent[/url]<hr width='90%'>"; } else { $buy = sprintf("UPDATE `users` SET money = money - %d WHERE (`userid` = %u)", $r['hPRICE'], $ir['userid']); $ins = sprintf("INSERT INTO `userhouses` (`uhID`, `uhUSER`, `uhHOUSE`, `uhWILL`) VALUES ('NULL','%d', '%d', '%d')", $ir['userid'], $r['hID'], $r['hWILL']); mysql_query($buy); mysql_query($ins); print " You bought the [b]{$r['hNAME']}[/b] for [b]".money_formatter($r['hPRICE'])."[/b]! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } else { $sql = sprintf("SELECT * FROM houses WHERE hID > 1 ORDER BY hWILL ASC"); $sql = mysql_query($sql); print "<table width='90%' cellspacing='1'> <tr bgcolor='#AAAAAA'><th>Name</th><th>Will</th><th>Price</th></tr>"; while($r = mysql_fetch_array($sql)) { print "<tr><td>[url='properties.php?step=estate&XID={$r[']{$r['hNAME']}[/url]</td><td>".number_format($r['hWILL'])."</td><td>".money_formatter($r['hPRICE'])."</td></tr>"; } print "</table><hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } function rental_market() { global $ir,$c,$userid,$h; $_GET['XID'] = abs((int) $_GET['XID']); if ($_GET['XID']) { $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE (uh.uhID = %u)", $_GET['XID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if(!mysql_num_rows($sql)) { print " This house does not exist! <hr width='90%'>> [url='properties.php?step=market']Market[/url]<hr width='90%'>"; } else if($r['uhUSER'] == $ir['userid']) { print " This house already belongs to you! <hr width='90%'>> [url='properties.php?step=market']Market[/url]<hr width='90%'>"; } else if($ir['money'] < $r['uhRENT']) { print " You cannot afford to rent this house! <hr width='90%'>> [url='properties.php?step=market']Market[/url]<hr width='90%'>"; } else { $sel = sprintf("UPDATE `users` SET money = money - %d WHERE (`userid` = %u)", $r['uhRENT'], $ir['userid']); $rent = sprintf("UPDATE `userhouses` SET uhRENTER = %d WHERE (`uhID` = %u)", $ir['userid'], $_GET['XID']); mysql_query($sel); mysql_query($rent); print " You are now renting the [b]{$r['hNAME']}[/b] for [b]".money_formatter($r['uhRENT'])."[/b] per day! <hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } else { $sql = sprintf("SELECT * FROM `userhouses` uh LEFT JOIN `houses` h ON (h.hID = uh.uhHOUSE) LEFT JOIN `users` u ON (u.userid = uh.uhUSER) WHERE uh.uhRENTER = 0 AND uh.uhRENT > 0"); $sql = mysql_query($sql); print "<table width='90%' cellspacing='1'> <tr bgcolor='#AAAAAA'><th>Property</th><th>Owner</th><th>Will</th><th>Cost</th><th>Daily Cost</th><th>Rental Period</th><th>Rent</th></tr>"; while($r = mysql_fetch_array($sql)) { print "<tr><td>{$r['hNAME']}</td><td>[url='viewuser.php?u={$r[']{$r['username']}[/url]</td><td>".number_format($r['uhWILL'])."</td><td>".number_format($r['uhRENT']*$r['uhRDAYS'])."</td><td>".number_format($r['uhWILL'])."</td><td>".number_format($r['uhRDAYS'])." days</td><td>[url='properties.php?step=market&XID={$r[']Rent[/url]</td></tr>"; } print "</table><hr width='90%'>> [url='properties.php']Properties[/url]<hr width='90%'>"; } } $h->endpage(); ?> Any problems let me know, I've spent all day fixing the bugs in this :) Remove your estate.php too
-
This didn't take too long to make. I haven't really tested it too much but it should work. I'm sure all queries are secured. Doesn't revolve too much around crons, only to set the days left to go down. Enjoy! Working on Jobs Modification next. Run SQL: CREATE TABLE `school_complete` ( `cmID` int(11) NOT NULL auto_increment, `cmCOURSE` int(11) NOT NULL, `cmUSER` int(11) NOT NULL, PRIMARY KEY (`cmID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE `school_courses` ( `scID` int(11) NOT NULL auto_increment, `scNAME` varchar(255) NOT NULL default '', `scDESC` text NOT NULL, `scPRICE` int(11) NOT NULL default '0', `scENERGY` int(11) NOT NULL default '0', `scDAYS` int(11) NOT NULL default '0', `scPRIMARY` enum('strength','agility','guard','labour','IQ') NOT NULL, `scSECONDARY` enum('strength','agility','guard','labour','IQ') NOT NULL, `scPGAIN` int(11) NOT NULL, `scSGAIN` int(11) NOT NULL, PRIMARY KEY (`scID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; ALTER TABLE users ADD school_course INT(11) NOT NULL DEFAULT 0; ALTER TABLE users ADD school_days INT(11) NOT NULL DEFAULT 0; create school.php <?php session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm); $h->menuarea(); print "<font face='Arial' size='4'>School</font><hr width='90%'>"; switch ($_GET['action']) { case 'info': course_info(); break; case 'start': course_start(); break; case 'quit': end_course(); break; case 'complete': complete_course(); break; default: courses_index(); break; } function courses_index() { global $ir,$c,$userid,$h; if ($ir['school_course'] AND !$ir['school_days']) { print " You have completed the {$r['scNAME']} course. [url='school.php?action=complete']Click here[/url] to claim the rewards. <hr width='90%'>> [url='index.php']Back[/url]<hr width='90%'>"; } else if ($ir['school_course']) { $sql = sprintf("SELECT * FROM `school_courses` WHERE (scID = %u)", $ir['school_course']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); print " You are currently taking the {$r['scNAME']} course. You have {$ir['school_days']} days remaining. [url='school.php?action=quit']Click here[/url] to quit. <hr width='90%'>> [url='index.php']Back[/url]<hr width='90%'>"; } else { $sql = sprintf("SELECT * FROM `school_courses` ORDER BY scPRICE DESC"); $sql = mysql_query($sql); print "<table width='90%' cellspacing='1'> <tr bgcolor='#AAAAAA'><th width='50%'>Name</th><th width='50%'>Information</th></tr>"; while($r = mysql_fetch_array($sql)) { print "<tr><td>{$r['scNAME']}</td> <td>[[url='school.php?action=info&ID={$r[']More Info[/url]]</td></tr>"; } print "<tr bgcolor='#AAAAAA'><th colspan='2' height='18'></th></tr> </table><hr width='90%'>"; } } function course_info() { global $ir,$c,$userid,$h; if ($ir['school_course']) { $sql = sprintf("SELECT * FROM `school_courses` WHERE (scID = %u)", $ir['school_course']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); print " You are currently taking the {$r['scNAME']} course. You have {$ir['school_days']} days remaining. [url='school.php?action=quit']Click here[/url] to quit. <hr width='90%'>> [url='index.php']Back[/url]<hr width='90%'>"; } else { $_GET['ID'] = abs((int) $_GET['ID']); $sql = sprintf("SELECT * FROM `school_courses` WHERE (scID = %u)", $_GET['ID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); print "<table width='400' cellspacing='1'> <tr><th colspan='2'>Details: </th></tr> <tr><td colspan='2' align='center'> [b]{$r['scNAME']}[/b] {$r['scDESC']} </td> </tr> <tr><th>Requirements: </th><th>Gains: </th></tr> <tr><td align='left' valign='top' width='50%'> • [b]Cost: [/b]".money_formatter($r['scPRICE'])." • [b]Days: [/b]".number_format($r['scDAYS'])." • [b]Energy: [/b]".number_format($r['scENERGY'])." </td> <td align='left' colspan='2' valign='top'> • [b]Primary: [/b]".number_format($r['scPGAIN'])." {$r['scPRIMARY']} • [b]Secondary: [/b]".number_format($r['scSGAIN'])." {$r['scSECONDARY']} • [b]Start: [/b][[url='school.php?action=start&ID={$r[']Begin[/url]] </td> </tr></table><hr width='90%'>"; } } function course_start() { global $ir,$c,$userid,$h; if($_GET['ID']) { $_GET['ID'] = abs((int) $_GET['ID']); $sql = sprintf("SELECT * FROM `school_courses` WHERE (scID = %u)", $_GET['ID']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); if(!mysql_num_rows($sql)) { print " There are no courses with that ID. <hr width='90%'>> [url='index.php']Back[/url]<hr width='90%'>"; } else { $q = sprintf("SELECT * FROM `school_complete` WHERE cmCOURSE = %d AND (cmUSER = %u)", $_GET['ID'], $userid); $q = mysql_query($q); if($ir['money'] < $r['scPRICE']) { print " You cannot afford to take this course. <hr width='90%'>> [url='school.php']Back[/url]<hr width='90%'>"; } else if($ir['energy'] < $r['scENERGY']) { print " You don't have enough energy to begin this course. <hr width='90%'>> [url='school.php']Back[/url]<hr width='90%'>"; } else if(mysql_num_rows($q)) { print " You have already completed this course. <hr width='90%'>> [url='school.php']Back[/url]<hr width='90%'>"; } else { $st = sprintf("UPDATE `users` SET school_course = %d, school_days = %d, money=money-%d, energy=energy-%d WHERE (userid = %u)", $_GET['ID'], $r['scDAYS'], $r['scPRICE'], $r['scENERGY'], $userid); mysql_query($st); print " You have started the {$r['scNAME']} course. You have {$r['scDAYS']} days remaining. <hr width='90%'>> [url='explore.php']Back[/url]<hr width='90%'>"; } } } } function end_course() { global $ir,$c,$userid,$h; if (!$ir['school_course']) { print " You are not taking a course right now. <hr width='90%'>> [url='index.php']Back[/url]<hr width='90%'>"; } else { $sql = sprintf("SELECT * FROM `school_courses` WHERE (scID = %u)", $ir['school_course']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); $up = sprintf("UPDATE `users` SET school_course = 0, school_days = 0 WHERE (`userid` = %u)", $ir['userid']); mysql_query($up); print " You have quit the {$r['scNAME']} course. <hr width='90%'>> [url='index.php']Back[/url]<hr width='90%'>"; } } function complete_course() { global $ir,$c,$userid,$h; if (!$ir['school_course']) { print " You are not taking a course. <hr width='90%'>> [url='school.php']Back[/url]<hr width='90%'>"; } else if ($ir['school_days'] > 0) { print " You still have {$ir['school_days']} left on the course. <hr width='90%'>> [url='index.php']Back[/url]<hr width='90%'>"; } else { $sql = sprintf("SELECT * FROM `school_courses` WHERE (scID = %u)", $ir['school_course']); $sql = mysql_query($sql); $r = mysql_fetch_array($sql); $up = sprintf("UPDATE `users` SET school_course = 0, school_days = 0 WHERE (`userid` = %u)", $ir['userid']); $st = sprintf("UPDATE `userstats` SET {$r['scPRIMARY']} = {$r['scPRIMARY']} + {$r['scPGAIN']}, {$r['scSECONDARY']} = {$r['scSECONDARY']} + {$r['scSGAIN']} WHERE (`userid` = %u)", $ir['userid']); $ins = sprintf("INSERT INTO `school_complete` (`cmID`, `cmCOURSE`, `cmUSER`) VALUES ('NULL','%d', '%d')", $r['scID'], $userid); print " You have finished the {$r['scNAME']} course. <hr width='90%'>> [url='index.php']Back[/url]<hr width='90%'>"; mysql_query($ins); mysql_query($up); mysql_query($st); } } $h->endpage(); ?> Add into cron_day.php mysql_query("UPDATE `users` SET school_days=school_days-1 WHERE school_days>0 AND school_course>0"); Any problems just let me know :)