TMan Posted February 27, 2009 Posted February 27, 2009 i am currently trying to make it so my players can buy more than 1 of the same house... this will increase their will(or w/e) by a set amount. the price will increase aswell. i am still new to coding and im getting some problems... <?php session_start(); require "globals.php"; $mpq=mysql_query("SELECT * FROM houses WHERE hWILL={$ir['willmax']}",$c); $mp=mysql_fetch_array($mpq); $_GET['property']=abs((int) $_GET['property']); if($_GET['property']) { $npq=mysql_query("SELECT * FROM houses WHERE hID={$_GET['property']}",$c); $np=mysql_fetch_array($npq); if ($ir['house_qty'] == 1) { if($np['hWILL'] < $mp['hWILL']) { print "You cannot go backwards in houses!"; } else if ($np['hPRICE'] > $ir['money']) { print "You do not have enough money to buy the {$np['hrNAME']}."; } mysql_query("UPDATE users SET money=money-{$np['hPRICE']},maxwill={$np['hWILL']},willmax={$np['hWILL']},house_qty=house_qty+1 WHERE userid=$userid",$c); print "Congrats, you bought the {$np['hNAME']} for \${$np['hPRICE']}!"; } $hprice=$ir['house_qty']*($np['hPRICE']*.20)+$np['hPRICE']; if ($hprice > $ir['money']) { print "You do not have enough money to buy the {$np['hrNAME']}."; } else if ($ir['house_qty'] > 1) { mysql_query("UPDATE users SET money=money-$hprice,maxwill=maxwill+{$np['hINC']},house_qty=house_qty+1 WHERE userid=$userid",$c); print "Congrats, you bought the {$np['hNAME']} for \$$hprice!"; } } else if (isset($_GET['sellhouse'])) { $npq=mysql_query("SELECT * FROM houses WHERE hWILL={$ir['willmax']}",$c); $np=mysql_fetch_array($npq); if($ir['willmax'] == 100) { print "You already live in the lowest property!"; } else { mysql_query("UPDATE users SET maxwill=100,willmax=100,house_qty=1 WHERE userid=$userid",$c); print "You sold your {$np['hNAME']} and went back to your CardBoard Box."; } } else { print "<center>Your current property: <font color=blue>[b]{$mp['hNAME']}[/b]</font> The houses you can buy are listed below. Click a house to buy it. "; if($ir['willmax'] > 100) { print "[url='estate.php?sellhouse']Sell Your Property[/url] "; } $hq=mysql_query("SELECT * FROM houses WHERE hWILL = {$ir['willmax']} ORDER BY hWILL ASC",$c); while($r=mysql_fetch_array($hq)) { $hprice=$ir['house_qty']*($np['hPRICE']*.20)+$np['hPRICE']; print "<table border=5 width=300px><tr><td width=85px> [url='estate.php?property={$r[']{$r['hNAME']}[/url]</td><td width=85px> \$$hprice </td><td width=65px> {$r['hWILL']}</td><td width=65px>{$r['hINC']}</td></tr></table>"; } } if ($ir['willmax'] == 100) { print "<table border=5 width=300px><tr><td width=85px>House Name</td><td width=85px>House Price</td><td width=65px>Base Soldiers</td><td width=65px>Soldier Increase</td></tr></table>"; } $hq=mysql_query("SELECT * FROM houses WHERE hWILL > {$ir['willmax']} ORDER BY hWILL ASC",$c); while($r=mysql_fetch_array($hq)) { $hprice=$ir['house_qty']*($np['hPRICE']*.20)+$np['hPRICE']; print "<table border=5 width=300px><tr><td width=85px> [url='estate.php?property={$r[']{$r['hNAME']}[/url]</td><td width=85px> \${$r['hPRICE']} </td><td width=65px> {$r['hWILL']}</td><td width=65px>{$r['hINC']}</td></tr></table>"; } $h->endpage(); ?> what this currently does: -lets them buy multiple of the same house. -Increases the amount of the housing cost. -and increases will by a set amount. but...my problem i want it to show only Sell House and the current house when they view estate, if they are over 100 for maxwill. this is printing the full housing table every time, and it prints both purchase complete sections. its very buggy and needs work if anyone is willing to help i would appreciate it. Quote
TMan Posted March 2, 2009 Author Posted March 2, 2009 Re: [V2]need help with Custom Mod for housing Im not sure if i wasnt specific enough so lets try it again. if($ir['willmax'] > 100) { print "[url='estate.php?sellhouse']Sell Your Property[/url] "; } $hq=mysql_query("SELECT * FROM houses WHERE hWILL = {$ir['willmax']} ORDER BY hWILL ASC",$c); while($r=mysql_fetch_array($hq)) { $hprice=$ir['house_qty']*($np['hPRICE']*.20)+$np['hPRICE']; print "<table border=5 width=300px><tr><td width=85px> [url='estate.php?property={$r[']{$r['hNAME']}[/url]</td><td width=85px> \$$hprice </td><td width=65px> {$r['hWILL']}</td><td width=65px>{$r['hINC']}</td></tr></table>"; } else if ($ir['willmax'] == 100) { print "<table border=5 width=300px><tr><td width=85px>House Name</td><td width=85px>House Price</td><td width=65px>Base Soldiers</td><td width=65px>Soldier Increase</td></tr></table>"; } $hq=mysql_query("SELECT * FROM houses WHERE hWILL > {$ir['willmax']} ORDER BY hWILL ASC",$c); while($r=mysql_fetch_array($hq)) { $hprice=$ir['house_qty']*($np['hPRICE']*.20)+$np['hPRICE']; print "<table border=5 width=300px><tr><td width=85px> [url='estate.php?property={$r[']{$r['hNAME']}[/url]</td><td width=85px> \${$r['hPRICE']} </td><td width=65px> {$r['hWILL']}</td><td width=65px>{$r['hINC']}</td></tr></table>"; } This is echoing/printing the table for houses for both willmax==100 and willmax >100 What I want: -i want the table to be displayed if willmax==100 (in lowest house) -i want only their current housing displayed if willmax>100 (not the table listing all the houses) not sure if im using if,else,else if wrong or which one to use in this part. can anyone help or am i still being too vague? Quote
TMan Posted March 2, 2009 Author Posted March 2, 2009 Re: [V2]need help with Custom Mod for housing I Just fixed this mod its working great :-D Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.