Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Register your account to receive email notifications when new services and mods are added.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: [Mccodes Version 2] Estate Agents  (Read 416 times)

MonoD

  • Basic Member
  • *
  • Reputation Power: 23
  • MonoD has no influence.
  • Offline Offline
  • Posts: 34
    • MSN Messenger - Contact@Monodistrict.com
    • View Profile
    • WWW
    • Email
[Mccodes Version 2] Estate Agents
« on: July 05, 2011, 08:55:51 PM »
Hi Cronwerks, Just thought i would share this very simple Estate Agents revamp for Mccodes Version 2.

Feel free to use, Works perfectly tested 100%!

Screenshots:




estate.php:
Code: [Select]
<?php
include_once(DIRNAME(__FILE__) . '/globals.php');
echo 
"<h3>Estate Agents</h3>";
$mpq              $db->query("SELECT * FROM houses WHERE hWILL={$ir['maxwill']}");
$mp               $db->fetch_row($mpq);
$_GET['purchase'] = abs((int) $_GET['purchase']);
if (
$_GET['purchase']) {
        
$npq $db->query("SELECT * FROM houses WHERE hID={$_GET['purchase']}");
        
$np  $db->fetch_row($npq);
        if (
$np['hWILL'] < $mp['hWILL']) {
                echo 
"<b>Error:</b> You cannot go backwards in properties!<br /><br /> &gt <a href='estate.php'>Back</a>";
        } else if (
$np['hPRICE'] > $ir['money']) {
                echo 
"<b>Error:</b> You do not have enough money to buy the {$np['hNAME']}.<br /><br /> &gt <a href='estate.php'>Back</a>";
        } else {
                
$db->query("UPDATE users SET money=money-{$np['hPRICE']},will=0,maxwill={$np['hWILL']} WHERE userid=$userid");
                echo 
"<b>Success:</b> You bought the {$np['hNAME']} for \${$np['hPRICE']}!<br /><br /> &gt <a href='estate.php'>Back</a>";
        }
} else if (isset(
$_GET['sell'])) {
        
$npq $db->query("SELECT * FROM houses WHERE hWILL={$ir['maxwill']}");
        
$np  $db->fetch_row($npq);
        if (
$ir['maxwill'] == 100) {
                echo 
"<b>Error:</b> You already live in the lowest property!<br /><br /> &gt <a href='estate.php'>Back</a>";
        } else {
                
$db->query("UPDATE users SET money=money+{$np['hPRICE']},will=0,maxwill=100 WHERE userid=$userid");
                echo 
"<b>Success:</b> You sold your {$np['hNAME']} and went back to your {$mp['hNAME']}.<br /><br /> &gt <a href='estate.php'>Back</a>";
        }
} else {
        echo 
"<center>Your property: <b>{$mp['hNAME']}</b><br /> The properties you can purchase are listed below.<br /><br />";
        echo 
"&gt <a href='estate.php?sell'>Sell your Property</a> &lt<br /><br />";
        if (
$ir['willmax'] > 100) {
        }
        
$hq $db->query("SELECT * FROM houses WHERE hWILL>{$ir['maxwill']} ORDER BY hWILL ASC");
        while (
$r $db->fetch_row($hq)) {
                echo 
"<table width='80%' cellspacing='1' class='table'><tr><th>Property</th><th>Price</th><th>Will</th><th>Action</th></tr>";
                
$hq mysql_query("SELECT * FROM houses WHERE hWILL>{$ir['maxwill']} ORDER BY hWILL ASC"$c);
                while (
$r $db->fetch_row($hq)) {
                        echo 
"<tr><td>{$r['hNAME']}</a></td><td>\$$t" money_formatter($r['hPRICE'], '') . "</td><td>{$r['hWILL']}</td><td><a href='estate.php?purchase={$r['hID']}'>Purchase</a></tr>";
                }
                echo 
"</table>";
        }
}
$h->endpage();
?>

Thanks
Logged

newbie

  • Basic Member
  • *
  • Reputation Power: 1
  • newbie has no influence.
  • Offline Offline
  • Posts: 4
    • View Profile
    • Email
Re: [Mccodes Version 2] Estate Agents
« Reply #1 on: October 02, 2011, 06:56:11 PM »
nice looks much better than standerd estate.php
Logged

fahy

  • Basic Member
  • *
  • Reputation Power: 0
  • fahy has no influence.
  • Offline Offline
  • Posts: 1
    • View Profile
Re: [Mccodes Version 2] Estate Agents
« Reply #2 on: November 15, 2011, 08:03:25 AM »
Hey is there a version of this for V1 because when i am trying to get it to work it is comming up with :

Fatal error: Call to a member function query() on a non-object in /home/fahy/public_html/estate.php on line 4
Logged

Zeddicus

  • Basic Member
  • *
  • Reputation Power: 0
  • Zeddicus is looked down upon.Zeddicus is looked down upon.
  • Offline Offline
  • Posts: 42
    • View Profile
    • WWW
Re: [Mccodes Version 2] Estate Agents
« Reply #3 on: November 16, 2011, 03:59:20 PM »
Looks better than the default, for sure. :)
Logged

MonoD

  • Basic Member
  • *
  • Reputation Power: 23
  • MonoD has no influence.
  • Offline Offline
  • Posts: 34
    • MSN Messenger - Contact@Monodistrict.com
    • View Profile
    • WWW
    • Email
Re: [Mccodes Version 2] Estate Agents
« Reply #4 on: November 23, 2011, 07:07:15 AM »
Hey is there a version of this for V1 because when i am trying to get it to work it is comming up with :

Fatal error: Call to a member function query() on a non-object in /home/fahy/public_html/estate.php on line 4

Try this:
Code: [Select]
<?php
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 
"<h3>Estate Agents</h3>";
$mpq              mysql_query("SELECT * FROM houses WHERE hWILL={$ir['maxwill']}");
$mp               mysql_fetch_array($mpq);
$_GET['purchase'] = abs((int) $_GET['purchase']);
if (
$_GET['purchase']) {
                
$npq mysql_query("SELECT * FROM houses WHERE hID={$_GET['purchase']}");
                
$np  mysql_fetch_array($npq);
                if (
$np['hWILL'] < $mp['hWILL']) {
                                echo 
"<b>Error:</b> You cannot go backwards in properties!<br /><br /> &gt <a href='estate.php'>Back</a>";
                } else if (
$np['hPRICE'] > $ir['money']) {
                                echo 
"<b>Error:</b> You do not have enough money to buy the {$np['hNAME']}.<br /><br /> &gt <a href='estate.php'>Back</a>";
                } else {
                                
mysql_query("UPDATE users SET money=money-{$np['hPRICE']},will=0,maxwill={$np['hWILL']} WHERE userid=$userid");
                                echo 
"<b>Success:</b> You bought the {$np['hNAME']} for \${$np['hPRICE']}!<br /><br /> &gt <a href='estate.php'>Back</a>";
                }
} else if (isset(
$_GET['sell'])) {
                
$npq mysql_query("SELECT * FROM houses WHERE hWILL={$ir['maxwill']}");
                
$np  mysql_fetch_array($npq);
                if (
$ir['maxwill'] == 100) {
                                echo 
"<b>Error:</b> You already live in the lowest property!<br /><br /> &gt <a href='estate.php'>Back</a>";
                } else {
                                
mysql_query("UPDATE users SET money=money+{$np['hPRICE']},will=0,maxwill=100 WHERE userid=$userid");
                                echo 
"<b>Success:</b> You sold your {$np['hNAME']} and went back to your {$mp['hNAME']}.<br /><br /> &gt <a href='estate.php'>Back</a>";
                }
} else {
                echo 
"<center>Your property: <b>{$mp['hNAME']}</b><br /> The properties you can purchase are listed below.<br /><br />";
                echo 
"&gt <a href='estate.php?sell'>Sell your Property</a> &lt<br /><br />";
                if (
$ir['willmax'] > 100) {
                }
                
$hq mysql_query("SELECT * FROM houses WHERE hWILL>{$ir['maxwill']} ORDER BY hWILL ASC");
                while (
$r mysql_fetch_array($hq)) {
                                echo 
"<table width='80%' cellspacing='1' class='table'><tr><th>Property</th><th>Price</th><th>Will</th><th>Action</th></tr>";
                                
$hq mysql_query("SELECT * FROM houses WHERE hWILL>{$ir['maxwill']} ORDER BY hWILL ASC"$c);
                                while (
$r mysql_fetch_array($hq)) {
                                                echo 
"<tr><td>{$r['hNAME']}</a></td><td>\$$t" money_formatter($r['hPRICE'], '') . "</td><td>{$r['hWILL']}</td><td><a href='estate.php?purchase={$r['hID']}'>Purchase</a></tr>";
                                }
                                echo 
"</table>";
                }
}
$h->endpage();
?>
Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.