Jump to content
MakeWebGames

Recommended Posts

Posted
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.

> Back";

$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.

> Back";

$h->endpage();

exit;

}

$db->query("INSERT INTO `properties` (`prID`, `prOWNER`, `prHOUSE`) VALUES

('NULL', '$userid', '{$r['hID']}');",$c);

event_add($r['prOWNER'],"{$ir['username']} 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();

?>

Can anyone fix this function when i buy house from the market it dosent take money away from me and the person that puts it on the market he dosent get paid for the house

Posted

Re: house bug

Change this part:

 

$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();
?> 

 

To this:

$db->query("INSERT INTO `properties` (`prID`, `prOWNER`, `prHOUSE`) VALUES
('NULL', '$userid', '{$r['hID']}');",$c);
$db->query("UPDATE users SET money=money+{$r['prCOST']} WHERE userid={$r['prOWNER']}");
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);
$db->query("UPDATE users SET money=money-{$r['prCOST']} WHERE userid=$userid");
print "You bought the {$r['hNAME']} from the market for \$".number_format($r['prCOST']).".";
}
$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...