Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

After purchasing with us the download link will be delivered to your forum message box.


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

AuthorTopic: houses  (Read 609 times)

muthchris

  • Basic Member
  • *
  • Reputation Power: 20
  • muthchris has no influence.
  • Offline Offline
  • Posts: 14
    • View Profile
houses
« on: July 30, 2010, 12:00:10 AM »
My houses are set up to require bricks, land, cement and money to buy the next house. I just purchased this mod from someone, but it allows them to buy the next house whether they have the essential criteria or not. If they do not have enough of one or more of the items, it allows them to buy the house and just puts them with negative money/bricks/land/cement etc. How do I stop this?? Here is that part of the code:

<?php
include "globals.php";
$mpq=$db->query("SELECT * FROM houses WHERE hWILL={$ir['maxwill']}");
$mp=$db->fetch_row($mpq);
$_GET['property']=abs((int) $_GET['property']);
if($_GET['property'])
{
$npq=$db->query("SELECT * FROM houses WHERE hID={$_GET['property']}");
$np=$db->fetch_row($npq);
if($np['hWILL'] < $mp['hWILL'])
{
print "You cannot go backwards in houses!";
}
else if ($np['hPRICE'] AND $ir['money'] < $userid['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']}, brick=brick-{$np['hBRICK']}, cement=cement-{$np['hCEMENT']}, land=land-{$np['hLAND']} WHERE userid=$userid");
print "Congrats, you bought the {$np['hNAME']} for \${$np['hPRICE']} , {$np['hBRICK']}, {$np['hCEMENT']} and {$np['hLAND']}!";
}
Logged

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: houses
« Reply #1 on: July 30, 2010, 09:35:48 AM »
Ok, if you'd have bothered to learn php, even very basic php syntax, then you'd know this.
Logged
Project Choosen - 10%
Daniel - Hanson . Com

muthchris

  • Basic Member
  • *
  • Reputation Power: 20
  • muthchris has no influence.
  • Offline Offline
  • Posts: 14
    • View Profile
Re: houses
« Reply #2 on: July 31, 2010, 08:57:22 AM »
ok, I didnt ask for criticism, I asked for help. Obviously I'm trying to learn right now. Thanks for help Danny!
Logged

muthchris

  • Basic Member
  • *
  • Reputation Power: 20
  • muthchris has no influence.
  • Offline Offline
  • Posts: 14
    • View Profile
Re: houses
« Reply #3 on: July 31, 2010, 09:00:27 AM »
Also, that was the wrong code, this is the actual code. Sorry.

<?php
include "globals.php";
$mpq=$db->query("SELECT * FROM houses WHERE hWILL={$ir['maxwill']}");
$mp=$db->fetch_row($mpq);
$_GET['property']=abs((int) $_GET['property']);
if($_GET['property'])
{
$npq=$db->query("SELECT * FROM houses WHERE hID={$_GET['property']}");
$np=$db->fetch_row($npq);
if($np['hWILL'] < $mp['hWILL'])
{
print "You cannot go backwards in houses!";
}
else if ($np['hPRICE'] AND $ir['money'] AND $ir['hCEMENT'] AND $ir['hLAND'] AND $ir['hBRICK'])
{
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']}, brick=brick-{$np['hBRICK']}, cement=cement-{$np['hCEMENT']}, land=land-{$np['hLAND']} WHERE userid=$userid");
print "Congrats, you bought the {$np['hNAME']} for \${$np['hPRICE']} , {$np['hBRICK']}, {$np['hCEMENT']} and {$np['hLAND']}!";
}
}
Logged

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: houses
« Reply #4 on: July 31, 2010, 09:29:31 AM »
basic if statement
Logged
Project Choosen - 10%
Daniel - Hanson . Com

muthchris

  • Basic Member
  • *
  • Reputation Power: 20
  • muthchris has no influence.
  • Offline Offline
  • Posts: 14
    • View Profile
Re: houses
« Reply #5 on: July 31, 2010, 10:06:00 AM »
ok so can you help me?? Sorry man, I'm new at this and trying to learn as much as I can
Logged

muthchris

  • Basic Member
  • *
  • Reputation Power: 20
  • muthchris has no influence.
  • Offline Offline
  • Posts: 14
    • View Profile
Re: houses
« Reply #6 on: July 31, 2010, 10:09:48 AM »
Would this work?

if($r['hPRICE'] == ($r['money'] || $r['hCEMENT'] || $r['hLAND'] || $r['hBRICK']) )
Logged

muthchris

  • Basic Member
  • *
  • Reputation Power: 20
  • muthchris has no influence.
  • Offline Offline
  • Posts: 14
    • View Profile
Re: houses
« Reply #7 on: July 31, 2010, 10:16:22 AM »
nope, that doesnt work
Logged

Dusty

  • Basic Member
  • *
  • Reputation Power: 21
  • Dusty has no influence.
  • Offline Offline
  • Posts: 39
  • TRD Computer Repair
    • Yahoo Instant Messenger - peewee986
    • View Profile
    • WWW
Re: houses
« Reply #8 on: August 24, 2010, 08:14:39 PM »
The problem you are having is in fact in the
Code: [Select]
else if ($np['hPRICE'] AND $ir['money'] AND $ir['hCEMENT'] AND $ir['hLAND'] AND $ir['hBRICK']) 

Strand of code..  I have problems with them all the time.. 
Try some thing like this strand of code..   im not sure if i have the == right I have to play with these some times my self to get them to work ..    but i would think that for this code to work your hPRICE would have to have the other payments in there also some where..  so im guessing that it does have it all in there in that one field 
Code: [Select]
elseif($np['hPRICE'] == $ir['money'] AND $ir['hCEMENT'] AND $ir['hLAND'] AND $ir['hBRICK']) 
Logged
TRD Computer Repair Services
www.trdcomputer.com

JoshuaDams

  • Active Member
  • **
  • Reputation Power: 129
  • JoshuaDams is working their way up.JoshuaDams is working their way up.JoshuaDams is working their way up.
  • Offline Offline
  • Posts: 240
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
Re: houses
« Reply #9 on: October 11, 2010, 07:22:09 PM »
Oh good lord.

The script fails miserably, but here.


<?php
	
	
	
require_once(
'globals.php');

	
	
	
$_GET['property']=abs((int) $_GET['property']);

	
	

	
	

	
	
$mpq $db->query("SELECT * FROM `houses` WHERE (hWILL=".$ir['maxwill'].")");

	
	
$mp=$db->fetch_row($mpq);
	
	

	
	
	
if(!
$_GET['property']) { echo 'You did not select a valid propery'$h->endpage(); exit; }


	
	
	

	
	
	
	
	
if(isset(
$_GET['property']))
	

	
	
	
	
	
{
	
	
	
	
	
$npq $db->query("SELECT * FROM `houses` WHERE (hID=".$_GET['property'].")");
	
	
	
	
	

	
	
	
	
	
if(!
$db->num_rows($npq))
	
	
	
	
	
{
	
	
	
	
	
echo 
'The house in which you selected does not exist';
	
	
	
	
	
$h->endpage();
	
	
	
	
	
exit;
	
	
	
	
	
}

	
	
	
	
	
$np=$db->fetch_row($npq);

	
	
	
	
	
$fail = ($np['hWILL'] < $mp['hWILL']) ? 'You cannot go backwards in housing' $fail;
	
	
	
	
	
$fail = ($np['hPRICE'] > $ir['money']) ? 'You cannot afford this house'$fail;
	
	
	
	
	
$fail = ($ir['hCEMENT'] != 'You do not have enough Cement.' $fail;
	
	
	
	
	
$fail = ($ir['hLAND'] != 'You do not have enough Land'$fail;
	
	
	
	
	
$fail = ($ir['hBRICK'] != 'You do not have enough bricks'$fail;
	
	
	
	
	

	
	
	
	
	
// Define Above ^ $ir['hLAND']/$ir['hBRICK']/$ir['hCEMENT'] Values they must have greater than
	
	
	
	
	
// example.  $ir['hBRICK'] < $np['requiredbrickamount']
	
	
	
	
	
// Also you request above $ir['hBRICK'] and below where you update the user
	
	
	
	
	
// you call $np['hBRICK'] 
	
	
	
	
	
// In lighter news, I really hope you didnt pay for this script...or lack there of ;-)
	
	
	
	
	
// http://www.purifiedgaming.com
	
	
	
	
	
// -Tyr

	
	
	
if(isset(
$fail))
	
	
	
{
	
	
	
	
echo 
' ' $fail ' ';
	
	
	
	
$h->endpage();
	
	
	
	
exit;
	
	
	
	
	
	
}

	
	
else
	
	
{
	
	
$db->query("UPDATE `users` SET `money`=`money`-".$np['hPRICE'].",
	
	
	
	
	
`will`=0,`maxwill`="
.$np['hWILL'].", `brick`=`brick`-".$np['hBRICK'].", 
	
	
	
	
	
`cement`=`cement`-"
.$np['hCEMENT'].", `land`=`land`-".$np['hLAND']."
	
	
	
	
	
WHERE (`userid`=$userid)"
);
	
	
	
	
	

	
	
	
print 
"Congrats, you bought the ".$np['hNAME'].
	
	
	
	
	
for \$"
.$np['hPRICE']." , ".$np['hBRICK'].", ".$np['hCEMENT']." and ".$np['hLAND']."!";
}
}


If you cannot figure out where to go from there ^

I dno what to tell you :P
 


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