Bennyh789 Posted January 12, 2013 Share Posted January 12, 2013 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 Quote Link to comment Share on other sites More sharing options...
Someone Posted January 12, 2013 Share Posted January 12, 2013 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.