Jump to content
MakeWebGames

Please for the love of god help me. will take 10 seconds


Bennyh789
 Share

Recommended Posts

Hello all,

Thanks in advance for your help!!!!!!!!!!!!!!!!!!!

Ok so in my houses mod i cant get my cron to run properly HOWEVER when run manually it is running without errors:

Below is the part of my cron that I have added

 

$houses = mysql_query(sprintf("SELECT * FROM `owned_houses` LEFT JOIN `users` ON (`userid` = `uhouseTenant`) WHERE `uhouseTenant` > '0'"));
while ($r = mysql_fetch_array($houses))
{
mysql_query("UPDATE `owned_houses` SET `uhouseRTime` = `uhouseRTime` - '1' WHERE `uhouseRTime` > '0'");
mysql_query(sprintf("UPDATE `users` SET `money` = `money` - '%d' WHERE `userid` = '%u'", $r['uhouseRent'], $r['uhouseTenant']));
mysql_query(sprintf("UPDATE `users` SET `money` = `money` + '%d' WHERE `userid` = '%u'", $r['uhouseRent'], $r['uhouseOwner']));
mysql_query("UPDATE `owned_houses` SET `uhouseTenant` = '0' WHERE `uhouseRTime` <= '0'");
}

 

Below is the code thats in houses.php

mysql_query(sprintf("UPDATE `users` SET `money` = `money` + '%d' WHERE (`userid` = '%u')", $r['hPRICE'], $ir['userid']));

 

Both of the money lines are NOT working, money is not going from one user to the other HOWEVER the uhouseRTime IS decreasing as it should be

Please help guys ive tried everything im running mccodes v2

Link to comment
Share on other sites

I am not an McCodes user, so I don't know the table structures. But there is some code you can use for debugging.

 

// This assumes that you are testing the cron by loading it in a browser and not using the cronjob
$houses = mysql_query(sprintf("SELECT * FROM `owned_houses` LEFT JOIN `users` ON (`userid` = `uhouseTenant`) WHERE `uhouseTenant` > '0'")) or die(mysql_error());

while ($r = mysql_fetch_array($houses))
{
echo '<pre>'.print_r($r).'</pre>';
mysql_query("UPDATE `owned_houses` SET `uhouseRTime` = `uhouseRTime` - '1' WHERE `uhouseRTime` > '0'") or die(mysql_error());
mysql_query(sprintf("UPDATE `users` SET `money` = `money` - '%d' WHERE `userid` = '%u'", $r['uhouseRent'], $r['uhouseTenant'])) or die(mysql_error());
mysql_query(sprintf("UPDATE `users` SET `money` = `money` + '%d' WHERE `userid` = '%u'", $r['uhouseRent'], $r['uhouseOwner'])) or die(mysql_error());
mysql_query("UPDATE `owned_houses` SET `uhouseTenant` = '0' WHERE `uhouseRTime` <= '0'");
}

 

Another note, I think you risk players going into negative money, or not needing to pay rent, as you are not checking ig the player have the money to pay.

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...