-
Posts
277 -
Joined
-
Last visited
-
Days Won
2
Content Type
Profiles
Forums
Events
Everything posted by Richard
-
Re: Simple Trades [V2] I think the cancel trade issue is fixed now
-
Run SQL: ALTER TABLE users ADD trade INT(11) NOT NULL DEFAULT 0; CREATE TABLE `trades` ( `trID` int(11) NOT NULL auto_increment, `trFROM` int(11) NOT NULL default '0', `trUSER` int(11) NOT NULL default '0', `trCRYS` int(11) NOT NULL default '0', `trCASH` int(11) NOT NULL default '0', `trITEM` int(11) NOT NULL default '0', `trRCRYS` int(11) NOT NULL default '0', `trRCASH` int(11) NOT NULL default '0', `trRITEM` int(11) NOT NULL default '0', PRIMARY KEY (`trID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE `usertrades` ( `trID` int(11) NOT NULL auto_increment, `trFROM` int(11) NOT NULL default '0', `trUSER` int(11) NOT NULL default '0', PRIMARY KEY (`trID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; Fixed by jay-dogg2006 Thanks :) Create trade.php <?php include "globals.php"; print "<center><font size='4' face='Arial, Helvetica, sans-serif'>Trading</font><hr width=75%>"; switch($_GET['action']) { default: start_trade(); break; case 'accept': accept_request(); break; case 'decline': decline_request(); break; case 'acctrade': accept_trade(); break; case 'dectrade': decline_trade(); break; case 'view': view_trade(); break; case 'begin': begin_trade(); break; case 'cancel': cancel_trade(); break; } function start_trade() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); if(!$_POST['user']) { print " <form action='trade.php' method='post'> Please type the ID# of the user you wish to trade with below. ID: <input type='text' name='user' value='{$_GET['ID']}' maxlength='10' length='10' size='10' width='10' /> <input type='submit' value='Send Request' /> </form> <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if($ir['trade']) { print " You already have a trade pending completion. Please wait until it is over. <hr width=75%>> [url='trade.php']Back[/url]<hr width=75%>"; } else if($_POST['user'] == $userid) { print " You cannot trade with yourself! <hr width=75%>> [url='trade.php']Back[/url]<hr width=75%>"; } else { mysql_query("INSERT INTO usertrades VALUES ('', '$userid', '{$_POST['user']}')", $c); $q=$db->query("SELECT * FROM usertrades WHERE trFROM=$userid"); $r=$db->fetch_row($q); event_add($_POST['user'], "{$ir['username']} would like to trade with you: • [url='trade.php?action=accept&ID={$r[']Accept Offer[/url] • [url='trade.php?action=decline&ID={$r[']Decline Offer[/url]", $c,'general'); print " Trade request sent! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } } function accept_request() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $q=$db->query("SELECT * FROM usertrades WHERE trID={$_GET['ID']}"); $r=$db->fetch_row($q); if(!$_GET['ID']) { print " Invalid trade ID! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if($r['trUSER'] != $userid) { print " You cannot accept this trade! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else { $q=$db->query("SELECT * FROM usertrades WHERE trUSER=$userid"); $r=$db->fetch_row($q); event_add($r['trFROM'], "{$ir['username']} has accepted your trade offer: • [url='trade.php?action=cancel&ID={$r[']Cancel Trade[/url] • [url='trade.php?action=begin']Begin Trade[/url] ", $c); mysql_query("UPDATE users SET trade={$r['trFROM']} WHERE userid=$userid"); mysql_query("UPDATE users SET trade=$userid WHERE userid={$r['trFROM']}"); mysql_query("DELETE FROM usertrades WHERE trID={$_GET['ID']}"); print " Trade request accepted! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } } function decline_request() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $q=$db->query("SELECT * FROM usertrades WHERE trID={$_GET['ID']}"); $r=$db->fetch_row($q); if(!$_GET['ID']) { print " Invalid trade ID! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if($r['trUSER'] != $userid) { print " You cannot decline this trade! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else { $q=$db->query("SELECT * FROM usertrades WHERE trID={$_GET['ID']}"); $r=$db->fetch_row($q); event_add($r['trFROM'], "{$ir['username']} has declined your trade offer.", $c); mysql_query("DELETE FROM usertrades WHERE trID={$_GET['ID']}"); print " Trade request declined! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } } function cancel_trade() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT * FROM users WHERE trade=$userid"); $r=$db->fetch_row($q); if(!$ir['trade']) { print " You are not in a trade! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if($r['trade'] != $userid) { print " This user is not in a trade with you! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else { $q=$db->query("SELECT * FROM users WHERE trade=$userid"); $r=$db->fetch_row($q); event_add($r['userid'], "{$ir['username']} has cancelled the trade.", $c); mysql_query("UPDATE users SET trade=0 WHERE userid=$userid"); mysql_query("UPDATE users SET trade=0 WHERE userid={$r['userid']}"); print " Trade cancelled! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } } function view_trade() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT * FROM trades WHERE trUSER=$userid"); $r=$db->fetch_row($q); $rs=$db->num_rows($q); if($r['trUSER'] != $userid) { print " This is not your trade! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if(!$rs) { print " This trade has not yet been started! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else { $q=$db->query("SELECT * FROM trades WHERE trUSER=$userid"); $r=$db->fetch_row($q); print " [b]<u>Trade Details[/b]</u> [b]Offer[/b] Money: \${$r['trCASH']} Crystals: {$r['trCRYS']} "; $x=$db->query("SELECT * FROM items WHERE itmid={$r['trITEM']}"); $i=$db->fetch_row($x); if ($r['trITEM']) { print "Item: {$i['itmname']} "; } else { print "Item: <font color=red>None</font> "; } print " [b]Request[/b] Money: \${$r['trRCASH']} Crystals: {$r['trRCRYS']} "; $x2=$db->query("SELECT * FROM items WHERE itmid={$r['trRITEM']}"); $i2=$db->fetch_row($x2); if ($r['trRITEM']) { print "Item: {$i2['itmname']} "; } else { print "Item: <font color=red>None</font> "; } if ($userid == $r['trUSER']) { print " [b]Options[/b] • [url='trade.php?action=acctrade&ID={$r[']Accept Trade[/url] • [url='trade.php?action=dectrade&ID={$r[']Decline Trade[/url] "; } print " <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } } function begin_trade() { global $db,$ir,$c,$userid,$h; if($_POST['crys'] || $_POST['cash'] || $_POST['item'] || $_POST['rcrys'] || $_POST['rcash'] || $_POST['ritem']) { $q=$db->query("SELECT * FROM users WHERE userid=$userid"); $r=mysql_fetch_array($q); if (!$ir['trade']) { print " You are not in a trade. <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; $h->endpage(); exit; } $db->query("INSERT INTO trades VALUES(NULL, '{$ir['userid']}', '{$ir['trade']}', '{$_POST['crys']}', '{$_POST['cash']}', '{$_POST['item']}', '{$_POST['rcrys']}', '{$_POST['rcash']}', '{$_POST['ritem']}')"); event_add($ir['trade'], "Your trade offer has been sent: • [url='trade.php?action=view']View Trade[/url] • [url='trade.php?action=cancel&ID={$r[']Cancel Trade[/url] ", $c); print " Your trade was submitted. <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else { print "<form action='trade.php?action=begin' method='post'> [b]Offer[/b] Crystals: <input type='text' name='crys' /> Cash: <input type='text' name='cash' /> Item: <select name='item' type=dropdown> <option value=0 selected>None</option>"; $q=$db->query("SELECT inv.*,i.* FROM inventory inv LEFT JOIN items i ON inv.inv_itemid=i.itmid WHERE inv.inv_userid={$userid} ORDER BY i.itmname ASC",$c); while($r=mysql_fetch_array($q)) { print "\n<option value='{$r['itmid']}'>{$r['itmname']}</option>"; } print "</select> "; print " [b]Request[/b] Crystals: <input type='text' name='rcrys' /> Cash: <input type='text' name='rcash' /> Item: <select name='ritem' type=dropdown> <option value=0 selected>None</option>"; $q=$db->query("SELECT inv.*,i.* FROM inventory inv LEFT JOIN items i ON inv.inv_itemid=i.itmid WHERE inv.inv_userid={$ir['trade']} ORDER BY i.itmname ASC",$c); while($r=mysql_fetch_array($q)) { print "\n<option value='{$r['itmid']}'>{$r['itmname']}</option>"; } print "</select> "; print "<input type='submit' value='Submit' /></form> <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } } function accept_trade() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $q=$db->query("SELECT * FROM trades WHERE trID={$_GET['ID']}"); $r=$db->fetch_row($q); $x=$db->query("SELECT * FROM users WHERE userid={$ir['trade']}"); $y=$db->fetch_row($x); $m=$db->query("SELECT * FROM inventory WHERE inv_itemid={$r['trITEM']} AND inv_userid={$r['trFROM']}"); $n=$db->num_rows($m); $o=$db->query("SELECT * FROM inventory WHERE inv_itemid={$r['trRITEM']} AND inv_userid={$r['trUSER']}"); $p=$db->num_rows($o); if(!$_GET['ID']) { print " Invalid trade ID! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if($r['trUSER'] != $userid) { print " You cannot accept this trade! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if($r['trRCASH'] > $ir['money'] || $r['trRCRYS'] > $ir['crystals']) { print " You do not meet one or more of the requirements! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if($y['money'] < $r['trCASH'] || $y['crystals'] < $r['trCRYS'] ) { print " Your friend does not meet one or more of the requirements! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if(!$n < 0) { print " Your friend does not meet one or more of the requirements! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if(!$p < 0) { print " You do not meet one or more of the requirements! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else { $q=$db->query("SELECT * FROM trades WHERE trUSER=$userid"); $r=$db->fetch_row($q); event_add($r['trFROM'], "{$ir['username']} has accepted your trade.", $c); if ($r['trITEM'] > 0) { mysql_query("UPDATE inventory SET inv_qty=inv_qty-1 WHERE inv_itemid={$r['trITEM']} AND inv_userid={$r['trFROM']}",$c); mysql_query("DELETE FROM inventory WHERE inv_qty=0",$c); mysql_query("INSERT INTO inventory VALUES('',{$r['trITEM']},$userid,'1');",$c); } if ($r['trRITEM'] > 0) { mysql_query("UPDATE inventory SET inv_qty=inv_qty-1 WHERE inv_itemid={$r['trRITEM']} AND inv_userid=$userid",$c); mysql_query("DELETE FROM inventory WHERE inv_qty=0",$c); mysql_query("INSERT INTO inventory VALUES('',{$r['trRITEM']},{$r['trFROM']},'1');",$c); } mysql_query("UPDATE users SET trade=0, money=money+{$r['trCASH']}, crystals=crystals+{$r['trCRYS']}, money=money-{$r['trRCASH']}, crystals=crystals-{$r['trRCRYS']} WHERE userid=$userid"); mysql_query("UPDATE users SET trade=0, money=money+{$r['trRCASH']}, crystals=crystals+{$r['trRCRYS']}, money=money-{$r['trCASH']}, crystals=crystals-{$r['trCRYS']} WHERE userid={$r['trFROM']}"); mysql_query("DELETE FROM trades WHERE trUSER=$userid"); print " Trade request accepted! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } } function decline_trade() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $q=$db->query("SELECT * FROM trades WHERE trID={$_GET['ID']}"); $r=$db->fetch_row($q); if(!$_GET['ID']) { print " Invalid trade ID! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if($r['trUSER'] != $userid) { print " You cannot decline this trade! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else { $q=$db->query("SELECT * FROM trades WHERE trID={$_GET['ID']}"); $r=$db->fetch_row($q); event_add($r['trFROM'], "{$ir['username']} has declined your trade offer.", $c); mysql_query("DELETE FROM trades WHERE trID={$_GET['ID']}"); mysql_query("UPDATE users SET trade=0 WHERE userid={$ir['trade']}"); mysql_query("UPDATE users SET trade=0 WHERE userid=$userid"); print " Trade declined! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } } $h->endpage(); ?> Enjoy :)
-
Re: Multiple Houses [V2] Yeah, sorry about that, it was requested by a friend. Just remove if you don't want it.
-
Re: House Rentals [V2] One way to fix would be to add before the 'else' in sell_house function. else if ($r['hWILL'] == '100') { die ("You cannot sell your starting house"); }
-
This is an add-on to Multiple Houses Mod Run SQL: CREATE TABLE `rentalmarket` ( `rentID` int(11) NOT NULL auto_increment, `rentPROP` int(11) NOT NULL, `rentCOST` int(11) NOT NULL, `rentDAYS` int(11) NOT NULL, `rentOWNER` int(11) NOT NULL, `rentHOUSE` int(11) NOT NULL, PRIMARY KEY (`rentID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE `rentals` ( `reID` int(11) NOT NULL auto_increment, `reOWNER` int(11) NOT NULL, `rePID` int(11) NOT NULL, `reRENTER` int(11) NOT NULL, `reDAYS` int(11) NOT NULL, `reCOST` int(11) NOT NULL, PRIMARY KEY (`reID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; Alter table users add rent int (11) not null default 0; Replace properties.php with: <?php include "globals.php"; print "<center><font size='4' face='Arial, Helvetica, sans-serif'>Your Properties</font><hr width=75%>"; switch($_GET['action']) { case 'sell': sell_house(); break; case 'market': market_house(); break; case 'rent': rent_house(); break; case 'give': send_house(); break; case 'move': move_house(); break; case 'return': return_house(); break; default: your_houses(); break; } function your_houses() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE pr.prOWNER={$userid} ORDER BY h.hPRICE ASC",$c); if ($db->num_rows($q) == 0) { print "You have no houses."; } else { print "<table width=60% cellspacing=1>"; while($r=$db->fetch_row($q)) { print "<tr>"; $dfi=$db->query("SELECT * FROM users WHERE userid={$r['prOWNER']}",$c); $tb=$db->fetch_row($dfi); print "<td valign='center'> [b]Property: [/b]{$r['hNAME']} [b]Owner: [/b][url='viewuser.php?u={$tb[']{$tb['username']}[/url] [b]Upkeep: [/b]\${$r['hTAX']} [b]Will: [/b]{$r['hWILL']}</td> <td align='center'> [[url='properties.php?action=move&ID={$r[']Move In[/url]] "; $yd=$db->query("SELECT * FROM rentals WHERE reRENTER=$userid AND rePID={$r['prID']}",$c); $zf=$db->fetch_row($yd); $tr=$db->num_rows($yd); if ($r['hWILL'] != '100' && $tr == '0') { print " [[url='properties.php?action=sell&ID={$r[']Sell[/url]] [[url='properties.php?action=market&ID={$r[']Market[/url]] [[url='properties.php?action=rent&ID={$r[']Rent[/url]] [[url='properties.php?action=give&ID={$r[']Give[/url]] "; } $yd=$db->query("SELECT * FROM rentals WHERE reRENTER=$userid AND rePID={$r['prID']}",$c); $zf=$db->fetch_row($yd); $tr=$db->num_rows($yd); if ($tr) { print "[[url='properties.php?action=return&ID={$r[']Return[/url]] "; } $hprice=money_formatter($r['hPRICE']); print "</tr><tr><td height='10'></td></tr>"; } print "</table> "; } } function sell_house() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $yd=$db->query("SELECT * FROM rentals WHERE reRENTER=$userid AND rePID={$_GET['ID']}",$c); $zf=$db->fetch_row($yd); $tr=$db->num_rows($yd); if ($tr) { die (" This house has been rented! <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%> "); } $q=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE pr.prID={$_GET['ID']} AND pr.prOWNER=$userid LIMIT 1",$c); $r=$db->fetch_row($q); if ($r['prOWNER'] != $ir['userid']) { print " This house does not belong to you. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $db->query("UPDATE users SET money=money+{$r['hPRICE']} WHERE userid=$userid",$c); print " You sold your {$r['hNAME']} for \${$r['hPRICE']}! <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; $db->query("DELETE FROM properties WHERE prID={$_GET['ID']}",$c); } } function send_house() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $yd=$db->query("SELECT * FROM rentals WHERE reRENTER=$userid AND rePID={$_GET['ID']}",$c); $zf=$db->fetch_row($yd); $tr=$db->num_rows($yd); if ($tr) { die (" This house has been rented! <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%> "); } if($_POST['user']) { $q=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE pr.prID={$_GET['ID']} AND pr.prOWNER=$userid LIMIT 1",$c); if($db->num_rows($q)==0) { print " Invalid house ID <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $r=$db->fetch_row($q); $m=$db->query("SELECT * FROM users WHERE userid={$_POST['user']} LIMIT 1",$c); if($db->num_rows($m) == 0) { print " You are trying to send to an invalid user! <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else if (!$_GET['ID']) { print " This user does not exist. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $rm=$db->fetch_row($m); $db->query("UPDATE properties SET prOWNER={$_POST['user']} WHERE prID={$_GET['ID']}",$c); } print " You sent the {$r['hNAME']} to {$rm['username']}. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; event_add($_POST['user'],"You received the {$r['hNAME']} from [url='viewuser.php?u=$userid']{$ir['username']}[/url]",$c,'transfer'); } } else if($_GET['ID']) { $id=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE pr.prID={$_GET['ID']} AND pr.prOWNER=$userid LIMIT 1",$c); if($db->num_rows($id)==0) { print " Invalid house ID. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else if ($_GET['ID']==0) { print " This user does not exist. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $r=$db->fetch_row($id); print " [b]Enter the ID of the user you want to give the {$r['hNAME']} to.[/b] <form action='properties.php?action=give&ID={$_GET['ID']}' method='post'> <input type='hidden' name='ID' value='{$_GET['ID']}' />User ID: <input type='text' name='user' value='' /> <input type='submit' value='Give House' /></form> <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } } else { print " Invalid use of file. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } } function market_house() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $yd=$db->query("SELECT * FROM rentals WHERE reRENTER=$userid AND rePID={$_GET['ID']}",$c); $zf=$db->fetch_row($yd); $tr=$db->num_rows($yd); if ($tr) { die (" This house has been rented! <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%> "); } $_POST['price'] = abs((int) $_POST['price']); if($_POST['price']) { $q=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE prID={$_GET['ID']} and prOWNER=$userid",$c); if($db->num_rows($q)==0) { print " Invalid House ID <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $r=$db->fetch_row($q); $db->query("INSERT INTO propertymarket VALUES ('','$userid',{$_POST['price']},'{$r['hID']}')", $c); $db->query("DELETE FROM properties WHERE prID={$_GET['ID']}",$c); print " House added to market. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } } else { $q=$db->query("SELECT * FROM properties WHERE prID={$_GET['ID']} and prOWNER=$userid",$c); if($db->num_rows($q)==0) { print " Invalid House ID <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $r=$db->fetch_row($q); print " Adding a house to the property market... <form action='properties.php?action=market&ID={$_GET['ID']}' method='post'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> Price: <input type='text' name='price' value='0' /> <input type='submit' value='Add' /></form> <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } } } function return_house() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $q=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE pr.prID={$_GET['ID']} AND pr.prOWNER=$userid LIMIT 1",$c); $r=$db->fetch_row($q); if ($r['prOWNER'] != $ir['userid']) { print " This house does not belong to you. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $yd=$db->query("SELECT * FROM rentals WHERE reRENTER=$userid AND rePID={$_GET['ID']}",$c); $zf=$db->fetch_row($yd); event_add($zf['reOWNER'],"You received the {$r['hNAME']} back from [url='viewuser.php?u=$userid']{$ir['username']}[/url]",$c,'transfer'); print " You returned the {$r['hNAME']}! <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; $db->query("DELETE FROM properties WHERE prID={$_GET['ID']}",$c); $db->query("INSERT INTO `properties` (`prID`, `prOWNER`, `prHOUSE`) VALUES ('{$zf['rePID']}', '{$zf['reOWNER']}', '{$r['hID']}');",$c); $db->query("DELETE FROM rentals WHERE rePID={$_GET['ID']}",$c); } } function rent_house() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $yd=$db->query("SELECT * FROM rentals WHERE reRENTER=$userid AND rePID={$_GET['ID']}",$c); $zf=$db->fetch_row($yd); $tr=$db->num_rows($yd); if ($tr) { die (" This house has been rented! <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%> "); } $_POST['price'] = abs((int) $_POST['price']); $_POST['days'] = abs((int) $_POST['days']); if($_POST['price'] || $_POST['days']) { $q=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE prID={$_GET['ID']} and prOWNER=$userid",$c); if($db->num_rows($q)==0) { print " Invalid House ID <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $r=$db->fetch_row($q); $db->query("INSERT INTO rentalmarket VALUES ('','{$_GET['ID']}',{$_POST['price']},'{$_POST['days']}','$userid','{$r['hID']}')", $c); $db->query("DELETE FROM properties WHERE prID={$_GET['ID']}",$c); print " House added to market. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } } else { $q=$db->query("SELECT * FROM properties WHERE prID={$_GET['ID']} and prOWNER=$userid",$c); if($db->num_rows($q)==0) { print " Invalid House ID <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $r=$db->fetch_row($q); print " Adding a house to the rental market... <form action='properties.php?action=rent&ID={$_GET['ID']}' method='post'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> Price (Daily): <input type='text' name='price' value='0' /> Days: <input type='text' name='days' value='0' /> <input type='submit' value='Add' /></form> <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } } } function move_house() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $q=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE pr.prID={$_GET['ID']} AND pr.prOWNER=$userid LIMIT 1",$c); $r=$db->fetch_row($q); if ($r['prOWNER'] != $ir['userid']) { print " This house does not belong to you. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $mpq=$db->query("SELECT * FROM houses WHERE hWILL={$ir['maxwill']}",$c); $mp=$db->fetch_row($mpq); print " You moved into your {$r['hNAME']}! <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; $db->query("INSERT INTO `properties` (`prID`, `prOWNER`, `prHOUSE`) VALUES ('', '$userid', '{$mp['hID']}');",$c); $db->query("UPDATE users SET maxwill={$r['hWILL']},will=0 WHERE userid=$userid",$c); $db->query("DELETE FROM properties WHERE prID={$_GET['ID']}",$c); } } $h->endpage(); ?> create rentals.php <?php include "globals.php"; print "<center><font size='4' face='Arial, Helvetica, sans-serif'>Rental Market</font> "; switch($_GET['action']) { case "buy": buy_house(); break; case "remove": remove_house(); break; default: market_index(); break; } function market_index() { global $db,$ir,$c,$userid; print "<table width=90% cellspacing=1 class='table'> <tr> <th>Owner</th> <th>House</th> <th>Days</th> <th>Daily Price</th> <th>Links</th> </tr>"; $q=$db->query("SELECT rent.*, h.*, u.* FROM rentalmarket rent LEFT JOIN houses h ON rentHOUSE=h.hID LEFT JOIN users u ON u.userid=rent.rentOWNER ORDER BY rent.rentCOST, rent.rentDAYS ASC",$c); $lt=""; while($r=$db->fetch_row($q)) { if($r['rentOWNER'] == $userid) { $link = "[[url='rentals.php?action=remove&ID={$r[']Remove[/url]]"; } else { $link = "[[url='rentals.php?action=buy&ID={$r[']Rent[/url]]"; } $cost=money_formatter($r['rentCOST']); print "<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>{$r['hNAME']}</td> <td>{$r['rentDAYS']}</td> <td>$cost</td> <td>$link</td> </tr>"; } print "</table>"; } function remove_house() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT rent.*, h.*, u.* FROM rentalmarket rent LEFT JOIN houses h ON rentHOUSE=h.hID LEFT JOIN users u ON u.userid=rent.rentOWNER ORDER BY rent.rentCOST, rent.rentDAYS ASC",$c); if(!$db->num_rows($q)) { print "Error, either this house does not exist, or you are not the owner. [url='rentals.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); $f=$db->query("SELECT FROM rentalmarket WHERE rentID={$_GET['ID']}"); $dg=$db->fetch_row($f); $db->query("INSERT INTO `properties` (`prID`, `prOWNER`, `prHOUSE`) VALUES ('NULL', '$userid', '{$dg['rentHOUSE']}');",$c); $db->query("DELETE FROM rentalmarket WHERE rentID={$_GET['ID']}",$c); print "House removed from market! [url='rentals.php']> Back[/url]"; } function buy_house() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT rent.*, h.*, u.* FROM rentalmarket rent LEFT JOIN houses h ON rentHOUSE=h.hID LEFT JOIN users u ON u.userid=rent.rentOWNER ORDER BY rent.rentCOST, rent.rentDAYS ASC",$c); if(!$db->num_rows($q)) { print "This house is already occupied. [url='rentals.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); if($r['reCOST'] > $ir['money']) { print "Error, you do not have the funds to start renting this house. [url='rentals.php']> Back[/url]"; $h->endpage(); exit; } event_add($r['rentOWNER'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] is now renting your {$r['hNAME']} for {$r['rentCOST']} per day.",$c); $db->query("INSERT INTO `properties` (`prID`, `prOWNER`, `prHOUSE`) VALUES ('{$r['rentPROP']}', '{$r['rentOWNER']}', '{$r['hID']}');",$c); $db->query("INSERT INTO `rentals` (`reID`, `reOWNER`, `rePID`, `reRENTER`, `reDAYS`, `reCOST`) VALUES ('NULL', '$userid', '{$r['rentPROP']}', '$userid', '{$r['rentDAYS']}', '{$r['rentCOST']}');",$c); $db->query("DELETE FROM rentalmarket WHERE rentID={$_GET['ID']}",$c); $db->query("UPDATE users SET rent={$r['rentCOST']} WHERE userid=$userid",$c); print "You are now renting the {$r['hNAME']} for \$".number_format($r['rentCOST'])." per day."; } $h->endpage(); ?> Add into cron_day.php $db->query("UPDATE rentals set reDAYS=reDAYS-1"); $io=$db->query("SELECT * FROM users where rent>0"); $hu=$db->fetch_row($io); $gd=$db->query("SELECT * FROM rentals WHERE reRENTER={$hu['userid']}"); $hd=$db->fetch_row($gd); $db->query("UPDATE users set money=money-{$hd['reCOST']} WHERE userid={$hd['reRENTER']}"); $q=$db->query("SELECT * FROM rentals WHERE reDAYS=0"); $ids=array(); while($r=$db->fetch_row($q)) { if (!$r['reDAYS']) { $rf=$db->query("SELECT * FROM properties WHERE prID={$r['rePID']}"); $gf=$db->fetch_row($rf); $db->query("DELETE FROM properties WHERE prID={$r['rePID']}"); $db->query("UPDATE users SET rent=0 WHERE userid={$r['reRENTER']}"); $db->query("INSERT INTO `properties` (`prID`, `prOWNER`, `prHOUSE`) VALUES ('{$r['rePID']}', '{$r['reOWNER']}', '{$gf['prHOUSE']}');",$c); $db->query("DELETE FROM rentals WHERE reDAYS=0"); } } I haven't had much time to test this but i've tested it a couple of times and it worked perfectly, also a couple of bugs have been fixed from the previous version.
-
This requires the House tax mod, If you do not have it, remove the Upkeep line from properties.php. Run Sql: CREATE TABLE `propertymarket` ( `prID` int(11) NOT NULL auto_increment, `prOWNER` int(11) NOT NULL, `prCOST` int(11) NOT NULL, `prHOUSE` int(11) NOT NULL, PRIMARY KEY (`prID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE `properties` ( `prID` int(11) NOT NULL auto_increment, `prOWNER` int(11) NOT NULL, `prHOUSE` int(11) NOT NULL, PRIMARY KEY (`prID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; Create properties.php <?php include "globals.php"; print "<center><font size='4' face='Arial, Helvetica, sans-serif'>Your Properties</font><hr width=75%>"; switch($_GET['action']) { case 'sell': sell_house(); break; case 'market': market_house(); break; case 'give': send_house(); break; case 'move': move_house(); break; default: your_houses(); break; } function your_houses() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE pr.prOWNER={$userid} AND h.hWILL>100 ORDER BY h.hPRICE ASC",$c); if ($db->num_rows($q) == 0) { print "You have no houses."; } else { print "<table width=60% cellspacing=1>"; while($r=$db->fetch_row($q)) { print "<tr>"; $dfi=$db->query("SELECT * FROM users WHERE userid={$r['prOWNER']}",$c); $tb=$db->fetch_row($dfi); print "<td valign='center'> [b]Property: [/b]{$r['hNAME']} [b]Owner: [/b][url='viewuser.php?u={$tb[']{$tb['username']}[/url] [b]Upkeep: [/b]\${$r['hTAX']} [b]Will: [/b]{$r['hWILL']}</td> <td align='center'> [[url='properties.php?action=move&ID={$r[']Move In[/url]] "; if ($r['hWILL'] != '100') { print " [[url='properties.php?action=sell&ID={$r[']Sell[/url]] [[url='properties.php?action=market&ID={$r[']Market[/url]] [[url='properties.php?action=give&ID={$r[']Give[/url]] "; } $hprice=money_formatter($r['hPRICE']); print "</tr><tr><td height='10'></td></tr>"; } print "</table> "; } } function sell_house() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $q=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE pr.prID={$_GET['ID']} AND pr.prOWNER=$userid LIMIT 1",$c); $r=$db->fetch_row($q); if ($r['prOWNER'] != $ir['userid']) { print " This house does not belong to you. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $db->query("UPDATE users SET money=money+{$r['hPRICE']} WHERE userid=$userid",$c); print " You sold your {$r['hNAME']} for \${$r['hPRICE']}! <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; $db->query("DELETE FROM properties WHERE prID={$_GET['ID']}",$c); } } function send_house() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); if($_POST['user']) { $q=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE pr.prID={$_GET['ID']} AND pr.prOWNER=$userid LIMIT 1",$c); if($db->num_rows($q)==0) { print " Invalid house ID <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $r=$db->fetch_row($q); $m=$db->query("SELECT * FROM users WHERE userid={$_POST['user']} LIMIT 1",$c); if($db->num_rows($m) == 0) { print " You are trying to send to an invalid user! <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else if (!$_GET['ID']) { print " This user does not exist. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $rm=$db->fetch_row($m); $db->query("UPDATE properties SET prOWNER={$_POST['user']} WHERE prID={$_GET['ID']}",$c); } print " You sent the {$r['hNAME']} to {$rm['username']}. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; event_add($_POST['user'],"You received the {$r['hNAME']} from [url='viewuser.php?u=$userid']{$ir['username']}[/url]",$c,'transfer'); } } else if($_GET['ID']) { $id=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE pr.prID={$_GET['ID']} AND pr.prOWNER=$userid LIMIT 1",$c); if($db->num_rows($id)==0) { print " Invalid house ID. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else if ($_GET['ID']==0) { print " This user does not exist. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $r=$db->fetch_row($id); print " [b]Enter the ID of the user you want to give the {$r['hNAME']} to.[/b] <form action='properties.php?action=give&ID={$_GET['ID']}' method='post'> <input type='hidden' name='ID' value='{$_GET['ID']}' />User ID: <input type='text' name='user' value='' /> <input type='submit' value='Give House' /></form> <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } } else { print " Invalid use of file. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } } function market_house() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $_POST['price'] = abs((int) $_POST['price']); if($_POST['price']) { $q=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE prID={$_GET['ID']} and prOWNER=$userid",$c); if($db->num_rows($q)==0) { print " Invalid House ID <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $r=$db->fetch_row($q); $db->query("INSERT INTO propertymarket VALUES ('','$userid',{$_POST['price']},'{$r['hID']}')", $c); $db->query("DELETE FROM properties WHERE prID={$_GET['ID']}",$c); print " House added to market. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } } else { $q=$db->query("SELECT * FROM properties WHERE prID={$_GET['ID']} and prOWNER=$userid",$c); if($db->num_rows($q)==0) { print " Invalid House ID <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $r=$db->fetch_row($q); print " Adding a house to the property market... <form action='properties.php?action=market&ID={$_GET['ID']}' method='post'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> Price: <input type='text' name='price' value='0' /> <input type='submit' value='Add' /></form> <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } } } function move_house() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $q=$db->query("SELECT pr.*,h.* FROM properties pr LEFT JOIN houses h ON pr.prHOUSE=h.hID WHERE pr.prID={$_GET['ID']} AND pr.prOWNER=$userid LIMIT 1",$c); $r=$db->fetch_row($q); if ($r['prOWNER'] != $ir['userid']) { print " This house does not belong to you. <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; } else { $mpq=$db->query("SELECT * FROM houses WHERE hWILL={$ir['maxwill']}",$c); $mp=$db->fetch_row($mpq); print " You moved into your {$r['hNAME']}! <hr width=75%>> [url='properties.php']Back[/url]<hr width=75%>"; $db->query("INSERT INTO `properties` (`prID`, `prOWNER`, `prHOUSE`) VALUES ('', '$userid', '{$mp['hID']}');",$c); $db->query("UPDATE users SET maxwill={$r['hWILL']},will=0 WHERE userid=$userid",$c); $db->query("DELETE FROM properties WHERE prID={$_GET['ID']}",$c); } } $h->endpage(); ?> Create propertymarket.php <?php include "globals.php"; print "<center><font size='4' face='Arial, Helvetica, sans-serif'>Property Market</font> "; switch($_GET['action']) { case "buy": buy_house(); break; case "remove": remove_house(); break; default: market_index(); break; } function market_index() { global $db,$ir,$c,$userid; print "<table width=90% cellspacing=1 class='table'> <tr> <th>Owner</th> <th>House</th> <th>Price</th> <th>Links</th> </tr>"; $q=$db->query("SELECT pr.*, h.*, u.* FROM propertymarket pr LEFT JOIN houses h ON prHOUSE=h.hID LEFT JOIN users u ON u.userid=pr.prOWNER ORDER BY pr.prCOST ASC",$c); $lt=""; while($r=$db->fetch_row($q)) { if($r['prOWNER'] == $userid) { $link = "[[url='propertymarket.php?action=remove&ID={$r[']Remove[/url]]"; } else { $link = "[[url='propertymarket.php?action=buy&ID={$r[']Buy[/url]]"; } $cost=money_formatter($r['prCOST']); print "<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>{$r['hNAME']}</td> <td>$cost</td> <td>$link</td> </tr>"; } print "</table>"; } function remove_house() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT pr.*, h.*, u.* FROM propertymarket pr LEFT JOIN houses h ON prHOUSE=h.hID LEFT JOIN users u ON u.userid=pr.prOWNER ORDER BY pr.prCOST ASC",$c); if(!$db->num_rows($q)) { print "Error, either this house does not exist, or you are not the owner. [url='propertymarket.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); $db->query("INSERT INTO `properties` (`prID`, `prOWNER`, `prHOUSE`) VALUES ('NULL', '$userid', '{$r['hID']}');",$c); $db->query("DELETE FROM propertymarket WHERE prID={$_GET['ID']}",$c); print "House removed from market! [url='propertymarket.php']> Back[/url]"; } function buy_house() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT pr.*, h.*, u.* FROM propertymarket pr LEFT JOIN houses h ON prHOUSE=h.hID LEFT JOIN users u ON u.userid=pr.prOWNER ORDER BY pr.prCOST ASC",$c); if(!$db->num_rows($q)) { print "Error, either this house does not exist, or it has already been sold. [url='propertymarket.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); if($r['prCOST'] > $ir['money']) { print "Error, you do not have the funds to buy this house. [url='propertymarket.php']> Back[/url]"; $h->endpage(); exit; } $db->query("INSERT INTO `properties` (`prID`, `prOWNER`, `prHOUSE`) VALUES ('NULL', '$userid', '{$r['hID']}');",$c); event_add($r['prOWNER'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought your {$r['hNAME']} from the property market for {$r['prCOST']}.",$c); $db->query("DELETE FROM propertymarket WHERE prID={$_GET['ID']}",$c); print "You bought the {$r['hNAME']} from the market for \$".number_format($r['prCOST'])."."; } $h->endpage(); ?> Replace estate.php with: <?php include "globals.php"; print "<center><font size='4' face='Arial, Helvetica, sans-serif'>Properties</font><hr width=75%>"; $pr=$db->num_rows($db->query("SELECT * FROM properties WHERE prOWNER=$userid",$c)); $mpq=$db->query("SELECT * FROM houses WHERE hWILL={$ir['maxwill']}",$c); $mp=$db->fetch_row($mpq); $_GET['ID']=abs((int) $_GET['ID']); if($_GET['ID']) { $npq=$db->query("SELECT * FROM houses WHERE hID={$_GET['ID']}",$c); $np=$db->fetch_row($npq); if($np['hWILL'] < $mp['hWILL']) { print " You cannot go backwards in houses! <hr width=75%>> [url='estate.php']Back[/url]<hr width=75%>"; } else if ($np['hPRICE'] > $ir['money']) { print " You do not have enough money to buy the {$np['hNAME']}. <hr width=75%>> [url='estate.php']Back[/url]<hr width=75%>"; } else { if ($np['hWILL']>100) { $db->query("INSERT INTO `properties` (`prID`, `prOWNER`, `prHOUSE`) VALUES ('NULL', '$userid', '{$np['hID']}');",$c); $db->query("UPDATE users SET money=money-{$np['hPRICE']} WHERE userid=$userid",$c); $hcost=money_formatter($np['hPRICE']); print " Congrats, you bought the {$np['hNAME']} for $hcost! <hr width=75%>> [url='estate.php']Back[/url]<hr width=75%>"; } } } else if (isset($_GET['sellhouse'])) { $npq=$db->query("SELECT * FROM houses WHERE hWILL={$ir['maxwill']}",$c); $np=$db->fetch_row($npq); if($ir['maxwill'] == 100) { print " You already live in the lowest property! <hr width=75%>> [url='estate.php']Back[/url]<hr width=75%>"; } else { $db->query("UPDATE users SET money=money+{$np['hPRICE']},maxwill=100 WHERE userid=$userid",$c); print "You sold your {$np['hNAME']} and went back to your Shack. <hr width=75%>> [url='estate.php']Back[/url]<hr width=75%>"; } } else { print "Your current property: [b]<font color=#00066>{$mp['hNAME']}</font>[/b] The houses you can buy are listed below. Click a house to buy it.<hr width=75%>"; if($ir['maxwill'] > 100) { print "[url='estate.php?sellhouse']Sell Your House[/url]<hr width=75%>"; } $hq=$db->query("SELECT * FROM houses WHERE hWILL>{$ir['maxwill']} ORDER BY hWILL ASC",$c); while($r=$db->fetch_row($hq)) { if($r['hID'] != 0 && $r['hID'] != 0) { $housecost=money_formatter($r['hPRICE']); print "[url='estate.php?ID={$r[']{$r['hNAME']}[/url]   - Cost: $housecost   - Will Bar: {$r['hWILL']} "; } } print "<hr width=75%>> [url='index.php'] Back[/url] <hr width=75%>"; } $h->endpage(); ?> Add a link to properties.php in main menu and link to propertymarket.php in explore Enjoy :)
-
Re: Updated Display Pic System [V2] Thanks for all of the comments :)
-
Re: Updated Display Pic System [V2] Screenshots
-
Works just like TC, except doesn't require uploading images. Instructions Run SQL: CREATE TABLE `userimages` ( `imgID` int(11) NOT NULL auto_increment, `imgUSER` int(11) NOT NULL, `imgURL` varchar(255) NOT NULL, PRIMARY KEY (`imgID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 create userimages.php <?php include "globals.php"; print "<center><font size='4' face='Arial, Helvetica, sans-serif'>User images</font> <hr width=90%>"; switch($_GET['action']) { case 'view': view_image(); break; default: user_images(); break; } function user_images() { global $db,$ir,$c,$userid,$h; $_GET['delete'] = abs((int) $_GET['delete']); if($_GET['delete']) { $db->query("DELETE FROM userimages WHERE imgID={$_GET['delete']} AND imgUSER=$userid"); print " Image deleted from gallery. <hr width=90%>"; } $_GET['set'] = abs((int) $_GET['set']); if($_GET['set']) { $image=$db->query("SELECT * FROM userimages WHERE imgID={$_GET['set']}",$c); $imgs=$db->fetch_row($image); $db->query("UPDATE users SET display_pic='{$imgs['imgURL']}' WHERE userid=$userid"); print " New display image set. <hr width=90%>"; } $_GET['XID'] = abs((int) $_GET['XID']); if(!$_GET['XID']) { print "No userID submitted<hr width=90%>> [url='explore.php']Back to city[/url]<hr width=90%>"; } else { $q=$db->query("SELECT * FROM userimages WHERE imgUSER={$_GET['XID']}",$c); $x=$db->query("SELECT * FROM users WHERE userid={$_GET['XID']}",$c); $y=$db->fetch_row($x); if($db->num_rows($x) == 0) { die (" There is no user with this ID. <hr width=90%>> [url='explore.php']Back to city[/url]<hr width=90%>"); } print "[b]{$y['username']}'s uploaded images[/b] "; if($db->num_rows($q) == 0) { print "<table width=90% bgcolor=#DFDFDF><tr><td><center>This user has no uploaded images</center></td></tr></table><hr width=90%>> [url='viewuser.php?u={$y[']Back to profile[/url]<hr width=90%>"; } else { print "<table width=90% bgcolor=#DFDFDF cellpadding='3'><tr>"; while($r=$db->fetch_row($q)) { $br++; if ($br == 3) { $div="</tr><tr>"; $br=0; } else { $div=""; } $cn++; print "<td align='center'>[b]#$cn Profile image[/b] [url='userimages.php?action=view&ID={$r['][img={$r[][/url]"; if($_GET['XID'] == $userid) { print " [[url='userimages.php?XID={$r[']Delete[/url]] [[url='userimages.php?XID={$r[']Set Image[/url]]"; } print " </td>"; print "$div"; } print "</tr></table> <hr width=90%>> [url='viewuser.php?u={$y[']Back to profile[/url]<hr width=90%>"; } } } function view_image() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $e=$db->query("SELECT * FROM userimages WHERE imgID={$_GET['ID']}",$c); $gh=$db->fetch_row($e); print "[img={$gh[] <hr width=90%>> [url='userimages.php?XID={$gh[']Back to images[/url]<hr width=90%>"; } $h->endpage(); ?> In preferences.php change pic_change and do_pic_change functions to: function pic_change() { global $db,$ir,$c,$userid,$h; print "<center>[b]Upload your images here[/b] <font color='red'>[b]Do not upload any offensive material, please keep it PG13 or your user may be at risk. Uploaded images are only to be used for {$set['game_name']} material.[/b]</font> 150x200 Maximum image width and height, any images exceeding this will be resized. Try to use only GIF, JPG and PNG formats.<form action='preferences.php?action=picchange2' method='post'> New Pic: <input type='text' name='newpic' /> <input type='submit' value='Upload Image' /></form><hr width=75%>> [url='preferences.php']Back[/url]<hr width=75%>"; } function do_pic_change() { global $db,$ir,$c,$userid,$h; print "<center>"; if($_POST['newpic'] == "") { print " You did not type a new image location. <hr width=75%>> [url='preferences.php?action=picchange']Back[/url]<hr width=75%>"; } else { $_POST['newpic']=str_replace('\\\'',''', $_POST['newpic']); $db->query("UPDATE users SET display_pic='{$_POST['newpic']}' WHERE userid=$userid",$c); $db->query("INSERT INTO userimages VALUES('',$userid,'{$_POST['newpic']}');",$c); print " Image Changed. <hr width=75%>> [url='preferences.php?action=picchange']Back[/url]<hr width=75%>"; } } In viewuser.php, add below display pic: $pics=$db->query("SELECT * FROM userimages WHERE imgUSER={$r['userid']}", $c); $pc=$db->num_rows($pics); print " [[url='userimages.php?XID={$r[']$pc uploaded images[/url]] "; Enjoy! :) Updated - Added remove and set links - Fixed 3 Images per row bug
-
Re: Simple Job Specials [V2] That piece of code goes into staff_jobs.php
-
Re: Favorite TV shows At the moment: - South Park - That 70s Show - The Simpsons - Top Gear
-
Re: Simple Job Specials [V2] Screenshots: http://i263.photobucket.com/albums/ii133/Convict-Nation/screen1.png http://i263.photobucket.com/albums/ii133/Convict-Nation/screen2.png http://i263.photobucket.com/albums/ii133/Convict-Nation/screen3.png http://i263.photobucket.com/albums/ii133/Convict-Nation/screen4.png http://i263.photobucket.com/albums/ii133/Convict-Nation/screen5.png
-
This is a pretty long modification, but a nice simple add-on to jobs. Run SQL: Alter table users add jobpoints int (11) not null default '0' CREATE TABLE `jobspecials` ( `jsID` int(11) NOT NULL auto_increment, `jsNAME` varchar(255) NOT NULL default '', `jsJOB` int(11) NOT NULL default '0', `jsCOST` int(11) NOT NULL default '0', `jsMONEY` int(11) NOT NULL default '0', `jsCRYSTALS` int(11) NOT NULL default '0', `jsITEM` int(11) NOT NULL default '0', `jsSTR` int(11) NOT NULL default '0', `jsIQ` int(11) NOT NULL default '0', `jsLABOUR` int(11) NOT NULL default '0', `jsAGILITY` int(11) NOT NULL default '0', PRIMARY KEY (`jsID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; In job.php (add below job table): $js=$db->query("SELECT * FROM jobspecials WHERE jsJOB={$ir['job']} ORDER BY jsID ASC;",$c); print "[b]Specials unlocked:[/b] <form action='specials.php' method='post'> <table width=80% cellspacing=1 class='table'> <tr> <th><font color=white>Reward</font></th> <th><font color=white>Cost</font></th> <th><font color=white>Take</font></th></tr>"; if($db->num_rows($js) == 0) { print "<tr class='row$current_row'><td colspan=3>This Job has no Speacials</td></tr>"; $current_row = 1 - $current_row; } while($sp=$db->fetch_row($js)) { print "<tr class='row$current_row'><td><font color=black>{$sp['jsNAME']}</td><td><font color=#FF0000>-{$sp['jsCOST']} Job Points</font></td><td><center><input type='radio' name='ID' value='{$sp['jsID']}' /></td></tr>"; $current_row = 1 - $current_row; } print "<tr> <td colspan=3><div align=center><input type='submit' value='Purchase'></div></td> </tr></table></form>"; Create specials.php: <?php include "globals.php"; $_PST['ID']= abs((int) $_POST['ID']); if(!$_POST['ID']) { print "Invalid use of file"; } else { $q=$db->query("SELECT * FROM jobspecials WHERE jsID={$_POST['ID']}"); if($db->num_rows($q) == 0) { print "There is no Job Special with this ID!"; } else { $r=$db->fetch_row($q); if($ir['jobpoints'] < $r['jsCOST']) { print "You don't have enough job points to get this reward!"; $h->endpage(); exit; } if($r['jsJOB'] != $ir['job']) { print "You are not in this Job!"; $h->endpage(); exit; } if($r['jsITEM']) { item_add($userid, $r['jsITEM'], '1'); } $money=($r['jsMONEY']); $crys=($r['jsCRYSTALS']); $cost=($r['jsCOST']); $str=($r['jsSTR']); $iq=($r['jsIQ']); $agi=($r['jsAGILITY']); $lab=($r['jsLABOUR']); $db->query("UPDATE users SET money=money+$money,crystals=crystals+$crys,jobpoints=jobpoints-$cost WHERE userid=$userid"); $db->query("UPDATE userstats SET strength=strength+$str,iq=iq+$iq,agility=agility+$agi,labour=labour+$lab WHERE userid=$userid"); print "You successfully redeemed the {$r['jsNAME']} Special for {$r['jsCOST']} Job Points."; } } $h->endpage(); ?> Add into staff_jobs.php function newjobspec() { global $db,$ir,$userid; if ($_POST['jsNAME']) { $db->query("INSERT INTO jobspecials VALUES('', '{$_POST['jsNAME']}', {$_POST['jsJOB']}, {$_POST['jsCOST']}, {$_POST['jsMONEY']}, {$_POST['jsCRYSTALS']}, {$_POST['jsITEM']}, {$_POST['jsSTR']}, {$_POST['jsIQ']}, {$_POST['jsAGILITY']}, {$_POST['jsLABOUR']})"); print "Job special created! "; } else { print <<<EOF <form action='staff_jobs.php?action=newjobspec' method='post'> [b]Special Name:[/b] <input type='text' name='jsNAME' /> [b]Cost:[/b] <input type='text' name='jsCOST' /> [b]Job:[/b] EOF; print job_dropdown($c,"jsJOB", -1); print <<<EOF [b]Money Gain:[/b] <input type='text' name='jsMONEY' /> [b]Crystal Gain:[/b] <input type='text' name='jsCRYSTALS' /> [b]Item:[/b] EOF; print item_dropdown($c,"jsITEM", -1); print <<<EOF [b]Strength Gain:[/b] <input type='text' name='jsSTR' /> [b]IQ Gain:[/b] <input type='text' name='jsIQ' /> [b]Agility Gain:[/b] <input type='text' name='jsAGILITY' /> [b]Labour Gain:[/b] <input type='text' name='jsLABOUR' /> <input type='submit' value='Create Special' /></form> EOF; } } function jobspecedit() { global $db,$ir,$userid; if ( $_POST['stage2']) { $db->query("UPDATE jobspecials SET jsNAME='{$_POST['jsNAME']}', jsJOB = {$_POST['jsJOB']}, jsCOST= {$_POST['jsCOST']}, jsMONEY={$_POST['jsMONEY']}, jsCRYSTALS={$_POST['jsCRYSTALS']}, jsITEM={$_POST['jsITEM']}, jsSTR={$_POST['jsSTR']}, jsIQ={$_POST['jsIQ']}, jsAGILITY={$_POST['jsAGILITY']}, jsLABOUR={$_POST['jsLABOUR']} WHERE jsID={$_POST['jsID']}"); print "Job special updated! "; } else if ( $_POST['stage1']) { $q=$db->query("SELECT * FROM jobspecials WHERE jsID={$_POST['jsID']}"); $r=$db->fetch_row($q); print <<<EOF <form action='staff_jobs.php?action=jobspecedit' method='post'> <input type='hidden' name='stage2' value='1'> <input type='hidden' name='jsID' value='{$_POST['jsID']}'> [b]Job Special Name:[/b] <input type='text' name='jsNAME' value='{$r['jsNAME']}'> [b]Cost:[/b] <input type='text' name='jsCOST' value='{$r['jsCOST']}' /> [b]Job:[/b] EOF; print job_dropdown($c,'jsJOB',$r['jsJOB']); print <<<EOF [b]Money Gain:[/b] <input type='text' name='jsMONEY' value='{$r['jsMONEY']}' /> [b]Crystal Gain:[/b] <input type='text' name='jsCRYSTALS' value='{$r['jsCRYSTALS']}' /> [b]Item:[/b] EOF; print item_dropdown($c,'jsITEM',$r['jsITEM']); print <<<EOF [b]Strength Gain:[/b] <input type='text' name='jsSTR' value='{$r['jsSTR']}' /> [b]IQ Gain:[/b] <input type='text' name='jsIQ' value='{$r['jsIQ']}' /> [b]Agility Gain:[/b] <input type='text' name='jsAGILITY' value='{$r['jsAGILITY']}' /> [b]Labour Gain:[/b] <input type='text' name='jsLABOUR' value='{$r['jsLABOUR']}' /> <input type='submit' value='Edit Special' /> </form> EOF; } else { print <<<EOF <form action='staff_jobs.php?action=jobspecedit' method='post'> <input type='hidden' name='stage1' value='1'> Select a job special to edit. EOF; print jobspec_dropdown($c, 'jsID', -1); print <<<EOF <input type='submit' value='Edit Job Special' /> </form> EOF; } } function jobspecdele() { global $db,$ir,$userid; if ( $_POST['stage1']) { $q=$db->query("SELECT * FROM jobspecials WHERE jsID={$_POST['jsID']}"); $jr=$db->fetch_row($q); $_POST['jID']=$jr['jsJOB']; $db->query("DELETE FROM jobspecials WHERE jsID={$_POST['jsID']}"); print "Job special successfully deleted! "; } else { print <<<EOF <form action='staff_jobs.php?action=jobspecdele' method='post'> <input type='hidden' name='stage1' value='1'> Select a job special to delete. EOF; print jobspec_dropdown($c, 'jsID', -1); print <<<EOF <input type='submit' value='Delete Job Special' /> </form> EOF; } } case 'newjobspec': newjobspec(); break; case 'jobspecedit': jobspecedit(); break; case 'jobspecdele': jobspecdele(); break; Add into global_func.php function jobspec_dropdown($connection,$ddname="jobspec",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT js.*,j.* FROM jobspecials js LEFT JOIN jobs j ON js.jsJOB=j.jID ORDER BY j.jNAME ASC, js.jsNAME ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['jsID']}'"; if ($selected == $r['jsID'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['jNAME']} - {$r['jsNAME']}</option>"; } $ret.="\n</select>"; return $ret; } Find in cron_hour.php $db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN jobs j ON j.jID=u.job LEFT JOIN jobranks jr ON u.jobrank=jr.jrID SET u.money=u.money+jr.jrPAY, u.exp=u.exp+(jr.jrPAY/20) WHERE u.job > 0 AND u.jobrank > 0"); Replace with: $db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN jobs j ON j.jID=u.job LEFT JOIN jobranks jr ON u.jobrank=jr.jrID SET u.money=u.money+jr.jrPAY, u.jobpoints=u.jobpoints+jr.jrPOINTS, u.exp=u.exp+(jr.jrPAY/20) WHERE u.job > 0 AND u.jobrank > 0"); Run SQL: alter table jobranks add jrPOINTS int (11) not null default 0 In staff_jobs.php Replace: function newjobrank() { global $db,$ir,$userid; if ( $_POST['jrNAME']) { $db->query("INSERT INTO jobranks VALUES('', '{$_POST['jrNAME']}', {$_POST['jrJOB']}, {$_POST['jrPAY']}, {$_POST['jrIQG']}, {$_POST['jrLABOURG']}, {$_POST['jrSTRG']}, {$_POST['jrIQN']}, {$_POST['jrLABOURN']}, {$_POST['jrSTRN']})"); print "Job rank created! "; } else { print <<<EOF <form action='staff_jobs.php?action=newjobrank' method='post'> [b]Rank Name:[/b] <input type='text' name='jrNAME' /> [b]Pays:[/b] <input type='text' name='jrPAY' /> [b]Job:[/b] EOF; print job_dropdown($c,"jrJOB", -1); print <<<EOF [b]Gains:[/b] Str: <input type='text' name='jrSTRG' size=3 maxlength=3> Lab: <input type='text' name='jrLABOURG' size=3 maxlength=3> IQ: <input type='text' name='jrIQG' size=3 maxlength=3> [b]Reqs:[/b] Str: <input type='text' name='jrSTRN' size=5 maxlength=5> Lab: <input type='text' name='jrLABOURN' size=5 maxlength=5> IQ: <input type='text' name='jrIQN' size=5 maxlength=5> <input type='submit' value='Create Job Rank' /></form> EOF; } } function jobrankedit() { global $db,$ir,$userid; if ( $_POST['stage2']) { $db->query("UPDATE jobranks SET jrNAME='{$_POST['jrNAME']}', jrJOB = {$_POST['jrJOB']}, jrPAY= {$_POST['jrPAY']}, jrIQG={$_POST['jrIQG']}, jrLABOURG={$_POST['jrLABOURG']}, jrSTRG={$_POST['jrSTRG']}, jrIQN={$_POST['jrIQN']}, jrLABOURN={$_POST['jrLABOURN']}, jrSTRN={$_POST['jrSTRN']}WHERE jrID={$_POST['jrID']}"); print "Job rank updated! "; } else if ( $_POST['stage1']) { $q=$db->query("SELECT * FROM jobranks WHERE jrID={$_POST['jrID']}"); $r=$db->fetch_row($q); print <<<EOF <form action='staff_jobs.php?action=jobrankedit' method='post'> <input type='hidden' name='stage2' value='1'> <input type='hidden' name='jrID' value='{$_POST['jrID']}'> [b]Job Rank Name:[/b] <input type='text' name='jrNAME' value='{$r['jrNAME']}'> [b]Job:[/b] EOF; print job_dropdown($c,'jrJOB',$r['jrJOB']); print <<<EOF [b]Pays:[/b] <input type='text' name='jrPAY' value='{$r['jrPAY']}' /> [b]Gains:[/b] Str: <input type='text' name='jrSTRG' size=3 maxlength=3 value='{$r['jrSTRG']}'> Lab: <input type='text' name='jrLABOURG' size=3 maxlength=3 value='{$r['jrLABOURG']}'> IQ: <input type='text' name='jrIQG' size=3 maxlength=3 value='{$r['jrIQG']}'> [b]Reqs:[/b] Str: <input type='text' name='jrSTRN' size=5 maxlength=5 value='{$r['jrSTRN']}'> Lab: <input type='text' name='jrLABOURN' size=5 maxlength=5 value='{$r['jrLABOURN']}'> IQ: <input type='text' name='jrIQN' size=5 maxlength=5 value='{$r['jrIQN']}'> [b]Job:[/b] <input type='submit' value='Edit' /> </form> EOF; } else { print <<<EOF <form action='staff_jobs.php?action=jobrankedit' method='post'> <input type='hidden' name='stage1' value='1'> Select a job rank to edit. EOF; print jobrank_dropdown($c, 'jrID', -1); print <<<EOF <input type='submit' value='Edit Job Rank' /> </form> EOF; } } function jobrankdele() { global $db,$ir,$userid; if ( $_POST['stage1']) { $q=$db->query("SELECT * FROM jobranks WHERE jrID={$_POST['jrID']}"); $jr=$db->fetch_row($q); $_POST['jID']=$jr['jrJOB']; $db->query("DELETE FROM jobranks WHERE jrID={$_POST['jrID']}"); print "Job rank successfully deleted! "; $db->query("UPDATE users u LEFT JOIN jobs j ON u.job=j.jID SET u.jobrank=j.jFIRST WHERE u.job={$_POST['jID']} and u.jobrank={$_POST['jrID']}"); $q=$db->query("SELECT * FROM jobs WHERE jFIRST={$_POST['jrID']}"); if($db->num_rows($q)) { $r=$db->fetch_row($q); print "[b]Warning![/b] The Job {$r['jNAME']} now has no first rank! Please go edit it and include a first rank. "; } } else { print <<<EOF <form action='staff_jobs.php?action=jobrankdele' method='post'> <input type='hidden' name='stage1' value='1'> Select a job rank to delete. EOF; print jobrank_dropdown($c, 'jrID', -1); print <<<EOF <input type='submit' value='Delete Job Rank' /> </form> EOF; } } with: function newjobrank() { global $db,$ir,$userid; if ( $_POST['jrNAME']) { $db->query("INSERT INTO jobranks VALUES('', '{$_POST['jrNAME']}', {$_POST['jrJOB']}, {$_POST['jrPAY']}, {$_POST['jrIQG']}, {$_POST['jrLABOURG']}, {$_POST['jrSTRG']}, {$_POST['jrIQN']}, {$_POST['jrLABOURN']}, {$_POST['jrSTRN']}, {$_POST['jrPOINTS']})"); print "Job rank created! "; } else { print <<<EOF <form action='staff_jobs.php?action=newjobrank' method='post'> [b]Rank Name:[/b] <input type='text' name='jrNAME' /> [b]Pays:[/b] <input type='text' name='jrPAY' /> [b]Points:[/b] <input type='text' name='jrPOINTS' /> [b]Job:[/b] EOF; print job_dropdown($c,"jrJOB", -1); print <<<EOF [b]Gains:[/b] Str: <input type='text' name='jrSTRG' size=3 maxlength=3> Lab: <input type='text' name='jrLABOURG' size=3 maxlength=3> IQ: <input type='text' name='jrIQG' size=3 maxlength=3> [b]Reqs:[/b] Str: <input type='text' name='jrSTRN' size=5 maxlength=5> Lab: <input type='text' name='jrLABOURN' size=5 maxlength=5> IQ: <input type='text' name='jrIQN' size=5 maxlength=5> <input type='submit' value='Create Job Rank' /></form> EOF; } } function jobrankedit() { global $db,$ir,$userid; if ( $_POST['stage2']) { $db->query("UPDATE jobranks SET jrNAME='{$_POST['jrNAME']}', jrJOB = {$_POST['jrJOB']}, jrPAY= {$_POST['jrPAY']}, jrIQG={$_POST['jrIQG']}, jrLABOURG={$_POST['jrLABOURG']}, jrSTRG={$_POST['jrSTRG']}, jrIQN={$_POST['jrIQN']}, jrLABOURN={$_POST['jrLABOURN']}, jrSTRN={$_POST['jrSTRN']}, jrPOINTS={$_POST['jrPOINTS']} WHERE jrID={$_POST['jrID']}"); print "Job rank updated! "; } else if ( $_POST['stage1']) { $q=$db->query("SELECT * FROM jobranks WHERE jrID={$_POST['jrID']}"); $r=$db->fetch_row($q); print <<<EOF <form action='staff_jobs.php?action=jobrankedit' method='post'> <input type='hidden' name='stage2' value='1'> <input type='hidden' name='jrID' value='{$_POST['jrID']}'> [b]Job Rank Name:[/b] <input type='text' name='jrNAME' value='{$r['jrNAME']}'> [b]Job:[/b] EOF; print job_dropdown($c,'jrJOB',$r['jrJOB']); print <<<EOF [b]Pays:[/b] <input type='text' name='jrPAY' value='{$r['jrPAY']}' /> [b]Points:[/b] <input type='text' name='jrPOINTS' value='{$r['jrPOINTS']}' /> [b]Gains:[/b] Str: <input type='text' name='jrSTRG' size=3 maxlength=3 value='{$r['jrSTRG']}'> Lab: <input type='text' name='jrLABOURG' size=3 maxlength=3 value='{$r['jrLABOURG']}'> IQ: <input type='text' name='jrIQG' size=3 maxlength=3 value='{$r['jrIQG']}'> [b]Reqs:[/b] Str: <input type='text' name='jrSTRN' size=5 maxlength=5 value='{$r['jrSTRN']}'> Lab: <input type='text' name='jrLABOURN' size=5 maxlength=5 value='{$r['jrLABOURN']}'> IQ: <input type='text' name='jrIQN' size=5 maxlength=5 value='{$r['jrIQN']}'> [b]Job:[/b] <input type='submit' value='Edit' /> </form> EOF; } else { print <<<EOF <form action='staff_jobs.php?action=jobrankedit' method='post'> <input type='hidden' name='stage1' value='1'> Select a job rank to edit. EOF; print jobrank_dropdown($c, 'jrID', -1); print <<<EOF <input type='submit' value='Edit Job Rank' /> </form> EOF; } } function jobrankdele() { global $db,$ir,$userid; if ( $_POST['stage1']) { $q=$db->query("SELECT * FROM jobranks WHERE jrID={$_POST['jrID']}"); $jr=$db->fetch_row($q); $_POST['jID']=$jr['jrJOB']; $db->query("DELETE FROM jobranks WHERE jrID={$_POST['jrID']}"); print "Job rank successfully deleted! "; $db->query("UPDATE users u LEFT JOIN jobs j ON u.job=j.jID SET u.jobrank=j.jFIRST WHERE u.job={$_POST['jID']} and u.jobrank={$_POST['jrID']}"); $q=$db->query("SELECT * FROM jobs WHERE jFIRST={$_POST['jrID']}"); if($db->num_rows($q)) { $r=$db->fetch_row($q); print "[b]Warning![/b] The Job {$r['jNAME']} now has no first rank! Please go edit it and include a first rank. "; } } else { print <<<EOF <form action='staff_jobs.php?action=jobrankdele' method='post'> <input type='hidden' name='stage1' value='1'> Select a job rank to delete. EOF; print jobrank_dropdown($c, 'jrID', -1); print <<<EOF <input type='submit' value='Delete Job Rank' /> </form> EOF; } } In smenu.php add: > [url='staff_jobs.php?action=newjobspec']Make a new Job Special[/url] > [url='staff_jobs.php?action=jobspecedit']Edit a Job Special[/url] > [url='staff_jobs.php?action=jobspecdele']Delete a Job Special[/url] Finally, in job.php find: You receive \${$ir['jrPAY']} replace with: You receive \${$ir['jrPAY']} and {$ir['jrPOINTS']} Job Points That should be all :) Last Tested: 21st June 2008 13:26pm
-
Re: New Crime Page [V2] Sorry, Ill edit that now :P
-
Re: [V2] Numbers Game I think this will work for staff to view winners Run this SQL Data: -- -- Table structure for table `staff_numbers` -- CREATE TABLE `staff_numbers` ( `user` int(11) NOT NULL default '0', `number` int(11) NOT NULL default '0', `time` int(11) NOT NULL default '0', PRIMARY KEY (`number`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `staff_numbers` -- Add below the previous cron_hour queries: $db->query("INSERT INTO staff_numbers VALUES($user,$randno,UNIX_TIMESTAMP())",$c); Add into staff_users.php case "numbergame": numbersgame(); break; function numbersgame() { global $db,$ir,$c,$h,$userid; print "<center><font size='4' face='Arial, Helvetica, sans-serif'>Number's Game</font><hr width=90%> <center><table width='90%' cellspacing=1><tr bgcolor=#500001><th><font color=white>ID</th><th><font color=white>Number</th> <th>Time</th></tr>"; $q=$db->query("SELECT * FROM staff_numbers ORDER BY time DESC LIMIT 24",$c); while($r=$db->fetch_row($q)) { $x=$db->query("SELECT * FROM users WHERE userid='{$r['user']}'"); $n=$db->fetch_row($x); print "<tr><td>[url='viewuser.php?u={$n[']{$n['username']}[/url]</td><td>{$r['number']}</td><td>".date('F j Y g:i:s a',$r['time']); print "</td></tr>"; } print "</table>"; } Add above Mini Competition in numbersgame.php if($ir['user_level'] == 2) { print "[url='staff_users.php?action=numbergame']View Winners[/url] "; } Someone with mccodes v2 may need to test this code first
-
Re: [V2] Numbers Game Ive edited this, you can now type the number you want to select instead of seeing the word 'Take' 50 times <?php /*----------------------------------------------------- -- Numbers Game -- Created by Richard -- For Mccodes V2 -- numbergame.php -----------------------------------------------------*/ include "globals.php"; print "<center><font size='4' face='Arial, Helvetica, sans-serif'>Number's Game</font><hr width=80%>"; if($ir['jailtime'] or $ir['hospital']) { die(" This page is unavailable while in Hospital or Jail. <hr width=80%>> [url='index.php']Home[/url]<hr width=80%>"); } $_POST['take'] = abs((int) $_POST['take']); $getid=$_POST['take']; if(!$getid) { $no=$db->query("SELECT * FROM numbergame WHERE userid=$userid",$c); $n=$db->num_rows($no); if(!$n) { print "<form action='numbergame.php' method='post'>[b]Choose a Number[/b] <input type='text' name='take' size='5' maxlegth='3'> <input type='submit' value='Go'></form> "; } print "[b]Mini Competition! Current Prize: 5 Points Guess a number from 1 to 50 If you see <span style='color:red'>(new)</span> next to the numbers game link in town this means you haven't guessed in the current game.[/b] <table width='30%' cellspacing=1><tr bgcolor=#500001><th width=20%><font color=white>Number</th><th><font color=white>Player</th> </tr>"; $q=$db->query("SELECT * FROM numbergame ORDER BY number ASC",$c); while($r=$db->fetch_row($q)) { $usersid=($r['userid']); $user=$db->query("SELECT * FROM users WHERE userid=$usersid",$c); $u=$db->fetch_row($user); print "\n<tr class='row$current_row' bgcolor=#EFEFEF><td align='center'>{$r['number']}</td><td align='center'>[url='viewuser.php?u={$u[']{$u['username']}[/url]</td></tr>"; $current_row = 1 - $current_row; } print "</table><hr width=80%>> [url='index.php']Home[/url]<hr width=80%>"; } else { $nogame=$db->query("SELECT * FROM numbergame WHERE number=$getid",$c); $no=$db->fetch_row($nogame); if($no['userid'] > 0) { die(" This number is already Taken. <hr width=80%>> [url='numbergame.php']Number Game[/url]<hr width=80%>"); } $nogame2=$db->query("SELECT * FROM numbergame WHERE userid=$userid",$c); $no2=$db->num_rows($nogame2); if($no2 > 0) { die(" You have already chosen a number. <hr width=80%>> [url='numbergame.php']Number Game[/url]<hr width=80%>"); } $db->query("UPDATE numbergame SET userid=$userid WHERE number=$getid",$c); print " You have taken the number $getid <hr width=80%>> [url='numbergame.php']Number Game[/url]<hr width=80%>"; } $h->endpage(); ?>
-
Re: [V2] Numbers Game Well basically, you choose a number between 1 and 50. Every hour a cron runs to randomly select a winner. If the cron picks the number you have chosen, you win 5 crystals.
-
Follow the instructions in the attachment below. Tested and works perfectly for me :)
-
Re: Multiple Item Use Mod {v1} Maybe this would work? if($r['itmname'] == 'Jail Key' && $ir['jailtime'] == 0) { die ("You are not in Jail!"); } if($r['itmtypename'] == 'Medical' && $ir['hospital'] == 0) { die ("You are not in Hospital!"); } Place this in the code, I havent tested it though
-
Re: Multiple Item Use Mod {v1} Im sure this mod was made by oxi
-
Re: Free 2 - Slots Thanks for this mod Nyna, it works perfectly
-
Re: Free 2 - Gym Ive updated the previous post, Thanks for that AlabamaHit
-
Re: Tutorial: v2 - v1 Conversion also, $db->fetch_single goes to mysql_fetch_object
-
Re: Free 2 - Gym Converted to v1...Ive renamed to advgym.php <?php /* ** Thanks Nyna We love it. ** Glad you made it. ** Cause we could not :) ** FULL CREDIT TO NYNA */ 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']); $cm=money_formatter($ir['crystals'],''); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm,$cm); $h->menuarea(); global $db, $h, $ir, $userid; if ($ir['hospital']) { echo " You cannot access the gym whilst in hospital</p>"; $h->endpage(); exit; } $prefs = isset($_SESSION['gymprefs']) ? $_SESSION['gymprefs'] : array('what' => "all", 'expend' => "100%"); $what = $prefs['what']; $expend = $prefs['expend']; $message = false; $sql = sprintf("SELECT us.strength, us.agility, us.guard, us.labour, u.energy, u.will, u.jail FROM users u LEFT JOIN userstats us ON (u.userid = us.userid) WHERE (u.userid = %u)", $userid); $row = mysql_fetch_array(mysql_query($sql)); $formID = preg_replace("`^([0-9A-F]{8})([0-9A-F]{4})([0-9A-F]{4})([0-9A-F]{4})([0-9A-F]{12})$`ms", "{\\1-\\2-\\3-\\4-\\5}", strtoupper(md5(serialize(array(session_id(), "Gym", null))))); if (isset($_POST['formID']) && is_string($_POST['formID']) && ($_POST['formID'] === $formID)) { $what = isset($_POST['what']) && is_string($_POST['what']) && preg_match("`^((all)|(strength)|(agility)|(guard)|(labour))$`ims", $_POST['what']) ? strtolower($_POST['what']) : $what; $expend = isset($_POST['expend']) && is_string($_POST['expend']) && preg_match("`^((100%)|(75%)|(50%)|(25%)|(value))$`ims", $_POST['expend']) ? strtolower($_POST['expend']) : $expend; $value = isset($_POST['value']) && is_string($_POST['value']) && preg_match("`^\d+$`ims", $_POST['value']) ? @intval($_POST['value']) : 0; $sql = sprintf("SELECT energy, will FROM users WHERE (userid = %u)", $userid); $rs = mysql_query($sql); $info = mysql_fetch_array($rs); $energy = $row['energy']; $will = $row['will']; switch ($expend) { case "100%": $value = $row['energy']; break; case "75%": $value = $row['energy'] * 0.75; break; case "50%": $value = $row['energy'] * 0.50; break; case "25%": $value = $row['energy'] * 0.25; break; default: break; } $value = floor($value); if ($value > $row['energy']) $message = "<span style='color:#C00;'>You don't have enough energy</span>"; else { $prefs = array('what' => $what, 'expend' => $expend); $gain = 0; $will = $row['will']; for ($i = 0; $i < $value; $i++) { $gain += mt_rand(1, 3) / mt_rand(500, 900) * mt_rand(500, 900) * (($will + 20) / 150); $will = max(0, $will - mt_rand(1, 3)); } if ($row['jail']) $gain *= 0.5; $row['will'] = floor($will); $row['energy'] -= $value; switch ($what) { case "all": $message = sprintf("<span style='color:#070;'>You gain %s in each stat</span>", number_format($gain * 0.25, 2)); $row['strength'] += $gain * 0.25; $row['agility'] += $gain * 0.25; $row['guard'] += $gain * 0.25; $row['labour'] += $gain * 0.25; break; case "strength": $message = sprintf("<span style='color:#070;'>You gain %s in strength</span>", number_format($gain, 2)); $row['strength'] += $gain; break; case "agility": $message = sprintf("<span style='color:#070;'>You gain %s in agility</span>", number_format($gain, 2)); $row['agility'] += $gain; break; case "guard": $message = sprintf("<span style='color:#070;'>You gain %s in guard</span>", number_format($gain, 2)); $row['guard'] += $gain; break; case "labour": $message = sprintf("<span style='color:#070;'>You gain %s in labour</span>", number_format($gain, 2)); $row['labour'] += $gain; break; } $sql1 = sprintf("UPDATE userstats SET strength = %.6f, agility = %.6f, guard = %.6f, labour = %.6f WHERE (userid = %u)", $row['strength'], $row['agility'], $row['guard'], $row['labour'], $userid); $sql2 = sprintf("UPDATE users SET will = %u, energy = %d WHERE (userid = %u)", $row['will'], $row['energy'], $userid); mysql_query($sql1); mysql_query($sql2); } $_SESSION['gymprefs'] = $prefs; } $row['ranks'] = array ( 'strength' => mysql_fetch_object(mysql_query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (strength > %.6f)", $row['strength']))) + 1, 'agility' => mysql_fetch_object(mysql_query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (agility > %.6f)", $row['agility']))) + 1, 'guard' => mysql_fetch_object(mysql_query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (guard > %.6f)", $row['guard']))) + 1, 'labour' => mysql_fetch_object(mysql_query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (labour > %.6f)", $row['labour']))) + 1, 'total' => mysql_fetch_object(mysql_query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (strength + agility + guard + labour > %.6f)", $row['strength'] + $row['agility'] + $row['guard'] + $row['labour']))) + 1, ); echo "<style type='text/css'>"; echo "#gym { }"; echo "#gym h3, #gym p { }"; echo "#gym table { width:90%;border-collapse:collapse; }"; echo "#gym th { border:solid 1px #333;background:#F6F6F6 url(titlebg.gif);padding:3px;color:#333; }"; echo "#gym td { border:solid 1px #333;padding:3px;color:#333; }"; echo "#gym { }"; echo "</style>"; echo "<div id='gym'>"; echo sprintf("<h3>%sGym</h3>", $ir['jail'] ? "Jail " : ""); if ($message) echo sprintf(" %s</p>", $message); echo "<form name='train' id='train' action='advgym.php' method='post' style='padding:0;margin:0;'>"; echo sprintf("<input type='hidden' name='formID' value='%s' />", $formID); echo "<table cellpadding='0' cellspacing='0'>"; echo "<tr>"; echo "<th class='sub' style='width:50%;'>Train</th>"; echo "<th class='sub' style='width:50%;'>Expend</th>"; echo "</tr>"; echo "<tr>"; echo "<td style='line-height:200%;'>"; echo sprintf("<input type='radio' name='what' id='what0' value='all' %sstyle='vertical-align:middle;' /><label for='what0' style='cursor:pointer;'>All (25%% energy in each) [Rank #%s]</label> ", $what === "all" ? "checked='checked' " : "", number_format($row['ranks']['total'])); echo sprintf("<input type='radio' name='what' id='what1' value='strength' %sstyle='vertical-align:middle;' /><label for='what1' style='cursor:pointer;'>Strength (%s) [Rank #%s]</label> ", $what === "strength" ? "checked='checked' " : "", number_format($row['strength']), number_format($row['ranks']['strength'])); echo sprintf("<input type='radio' name='what' id='what2' value='agility' %sstyle='vertical-align:middle;' /><label for='what2' style='cursor:pointer;'>Agility (%s) [Rank #%s]</label> ", $what === "agility" ? "checked='checked' " : "", number_format($row['agility']), number_format($row['ranks']['agility'])); echo sprintf("<input type='radio' name='what' id='what3' value='guard' %sstyle='vertical-align:middle;' /><label for='what3' style='cursor:pointer;'>Guard (%s) [Rank #%s]</label> ", $what === "guard" ? "checked='checked' " : "", number_format($row['guard']), number_format($row['ranks']['guard'])); echo sprintf("<input type='radio' name='what' id='what4' value='labour' %sstyle='vertical-align:middle;' /><label for='what4' style='cursor:pointer;'>Labour (%s) [Rank #%s]</label> ", $what === "labour" ? "checked='checked' " : "", number_format($row['labour']), number_format($row['ranks']['labour'])); echo "</td>"; echo "<td style='line-height:200%;'>"; echo sprintf("<input type='radio' name='expend' id='expend0' value='100%%' %sstyle='vertical-align:middle;' /><label for='expend0' style='cursor:pointer;'>100%% Energy</label> ", $expend === "100%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend1' value='75%%' %sstyle='vertical-align:middle;' /><label for='expend1' style='cursor:pointer;'>75%% Energy</label> ", $expend === "75%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend2' value='50%%' %sstyle='vertical-align:middle;' /><label for='expend2' style='cursor:pointer;'>50%% Energy</label> ", $expend === "50%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend3' value='25%%' %sstyle='vertical-align:middle;' /><label for='expend3' style='cursor:pointer;'>25%% Energy</label> ", $expend === "25%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend4' value='value' %sstyle='vertical-align:middle;' onclick='document.train.value.focus();' /><label for='expend4' style='cursor:pointer;'><input type='text' id='value' name='value' value='{$row['energy']}' size='8' onfocus='this.select();' /> Energy</label> ", $expend === "value" ? "checked='checked' " : "");//(C)2008,Nyna echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2' style='text-align:center;padding:6px;'>"; echo "<input type='submit' name='submit' value='Train' />"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</form>"; echo "</div>"; echo "<p style='color:#CCC;'>An open-source extension from [url='http://nyna.co.uk/']Nyna[/url]</p>"; $h->endpage(); ?> Tested and works Thanks for this Nyna!
-
Re: Warning when mailing a admin Thanks Silver