Jump to content
MakeWebGames

Recommended Posts

Posted

in my Estate.php

there seems to be an issue where i buy a house the will updates requiring to the house then once refreshed or clicked another link it goes back to 100 WILL and house is known as homeless???

also this estate i don't know why it dont function once the house is sold (which i tried before this problem came up ) the Will bar seemed to break and become soo long 356 something Will bar i dont want that.

can anyone help me fix it i tried many ways am not too good at coding but making a Effort.. :)

 

<?php
include "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($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['hNAME']}.";
}
else
{
$db->query("UPDATE users SET money=money-{$np['hPRICE']},will=0,maxwill={$np['hWILL']},maxdealers={$np['maxdealers']} WHERE userid=$userid");
print "Congrats, you bought the {$np['hNAME']} for \${$np['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 money=money+{$np['hPRICE']},maxwill=100,willmax=100 WHERE userid=$userid",$c);
print "You sold your {$np['hNAME']} and went back to being homeless.";
}
}
else
{
print "<center>Your current property: <font color=blue><b>{$mp['hNAME']}</b></font><br />
The houses you can buy are listed below. Click a house to buy it.<br />";
if($ir['maxwill'] > 100 && $ir['marriedwill'] == 0) {
echo'<a href="?sellhouse">Sell Your House</a><br /><br />';
}

$hq=mysql_query("SELECT * FROM houses WHERE hWILL>{$ir['willmax']} ORDER BY hWILL ASC",$c);
while($r=mysql_fetch_array($hq))

{
print "<br />
<table cellspacing=1 class='table'><tr style='background:gray;'><th>House</th><th>Pic</th><th>House Price</th><th>House Will</th><th>Buy?</th></tr>";
$hq=mysql_query("SELECT * FROM houses WHERE hWILL>{$ir['willmax']} ORDER BY hWILL ASC",$c);
while($r=mysql_fetch_array($hq))
{
print "<tr><td>{$r['hNAME']}</a></td>
<td><img src='{$r['hPIC']}' width='137' height='72' alt='' /></td>
<td>\$$t".money_formatter($r['hPRICE'],'')."</td>
<td>{$r['hWILL']}</td>
<td><a href='estate.php?property={$r['hID']}'>Buy</tr>";
}
print "</table>";
}
}
$h->endpage();

?>
Posted

A couple of things...

1. After buying a house and the players will resets to 100 appears to be happening outside of this file. Is there a function called on every page that is checking a players will? (example: a marriage script)

2. In the query that updates players after they purchase a house it is updating a field named maxdealers. I'm assuming this is for a mod you have added. I've add an update to the query willmax=$np['hWILL']}) as it appears other parts of the code use that field as well.

3. When selling a house the fields maxwill and willmax were being updated but no will. Changed that query to update will to 100.

 

<?php
include "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($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['hNAME']}.";
		}
	else
		{
			$db->query("UPDATE users SET money=money-{$np['hPRICE']},will=0,maxwill={$np['hWILL']},willmax={$np['hWILL']},maxdealers={$np['maxdealers']} WHERE userid=$userid");
			print "Congrats, you bought the {$np['hNAME']} for \${$np['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 money=money+{$np['hPRICE']},will=100,maxwill=100,willmax=100 WHERE userid=$userid",$c);
			print "You sold your {$np['hNAME']} and went back to being homeless.";
		}
}
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['maxwill'] > 100 && $ir['marriedwill'] == 0) 
		{
			echo'<a href="?sellhouse">Sell Your House</a>';
		}
	$hq=mysql_query("SELECT * FROM houses WHERE hWILL>{$ir['willmax']} ORDER BY hWILL ASC",$c);
	while($r=mysql_fetch_array($hq))
		{
			print "<table cellspacing=1 class='table'><tr style='background:gray;'><th>House</th><th>Pic</th><th>House Price</th><th>House Will</th><th>Buy?</th></tr>";
			$hq=mysql_query("SELECT * FROM houses WHERE hWILL>{$ir['willmax']} ORDER BY hWILL ASC",$c);
			while($r=mysql_fetch_array($hq))
				{
					print "<tr><td>{$r['hNAME']}</a></td>
					<td><img src='{$r['hPIC']}' width='137' height='72' alt='' /></td>
					<td>\$$t".money_formatter($r['hPRICE'],'')."</td>
					<td>{$r['hWILL']}</td>
					<td><a href='estate.php?property={$r['hID']}'>Buy</tr>";
				}
			print "</table>";
		}
}
$h->endpage();
?>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...