Newbie Posted March 13, 2012 Share Posted March 13, 2012 hello all i have been trying to get my house tax cron to send a user a event when he loses his house due to non payement of tax but everything i try doesnt work can anyone help me out please thanks steven Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted March 13, 2012 Share Posted March 13, 2012 use the event_add function Quote Link to comment Share on other sites More sharing options...
newttster Posted March 13, 2012 Share Posted March 13, 2012 It might help if you post what you have tried ... it's possible that you are close to what you want. It's hard for anyone to help if they have no idea what you have tried. Good luck. Quote Link to comment Share on other sites More sharing options...
Newbie Posted March 13, 2012 Author Share Posted March 13, 2012 ok i have been trying to use this but its not working event_add($r['userid'],"You failed to pay the tax, so you have lost the house.",$c); Quote Link to comment Share on other sites More sharing options...
newttster Posted March 13, 2012 Share Posted March 13, 2012 Did you check your globals to make sure that the event_add function is there? Where are you placing that in your code? Quote Link to comment Share on other sites More sharing options...
Newbie Posted March 13, 2012 Author Share Posted March 13, 2012 yeh the event function is there in globals already checked that its proberly me just putting it in wrong place lol //House Tax Update $uq=$db->query("SELECT * FROM users"); $Row=0; while($r=$db->fetch_row($uq)) { $will = $r['maxwill']; $hq=$db->query("SELECT * FROM houses WHERE hWILL='{$will}'"); if($db->num_rows($hq) == 0) { } $r2=$db->fetch_row($hq); if($r['bankmoney'] < $r2['hTAX']) { $money=$r['money']; $db->query("UPDATE users SET money=money+'{$r2['hSPRICE']}', will=100, maxwill=100 WHERE userid={$r['userid']}"); event_add($r['userid'],"You failed to pay the tax, so you have lost the house.",$c); } else { $db->query("UPDATE users SET bankmoney=bankmoney-'{$r2['hTAX']}' WHERE userid='{$r['userid']}'"); } $Rows++; } ?> Totally there were <?php print($Rows); ?> rows which were executed. Quote Link to comment Share on other sites More sharing options...
HauntedDawg Posted March 13, 2012 Share Posted March 13, 2012 Will need to see more. Try removing the , $c at the end.. So make it: event_add($r['userid'],"You failed to pay the tax, so you have lost the house."); Could be calling the wrong link identifier? It's late for me so cant notice right now x.x working on a "special" project :P Quote Link to comment Share on other sites More sharing options...
newttster Posted March 13, 2012 Share Posted March 13, 2012 Not sure but shouldn't it be hPRICE instead of hSPRICE? Atleast that is what it is called in my house table. Quote Link to comment Share on other sites More sharing options...
HauntedDawg Posted March 13, 2012 Share Posted March 13, 2012 hSPRICE is the price it give's back to the user for tax. Not the full amount. Quote Link to comment Share on other sites More sharing options...
newttster Posted March 13, 2012 Share Posted March 13, 2012 hSPRICE is the price it give's back to the user for tax. Not the full amount. Meaning it is the sell price? My mistake ... I don't have my houses mod changed, only have the original table which is why this caught my eye. Hey ... I'm learning too. Sorry about that ... gave it a shot. Quote Link to comment Share on other sites More sharing options...
Newbie Posted March 14, 2012 Author Share Posted March 14, 2012 yeh i made it so users dont get the full amount back iv seen on some games that users sell there house before reset and gain intrest from it so by only giving them half the money back it wont work my house structure is hID hNAME hPRICE hWILL hPIC hPOINTS hTAX hSPRICE <?php include "config.php"; global $_CONFIG; if($_GET['code'] != $_CONFIG['code']) { die(""); } define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; $set=array(); $settq=$db->query("SELECT * FROM settings"); while($r=$db->fetch_row($settq)) { $set[$r['conf_name']]=$r['conf_value']; } //House Tax Update $uq=$db->query("SELECT * FROM users"); $Row=0; while($r=$db->fetch_row($uq)) { $will = $r['maxwill']; $hq=$db->query("SELECT * FROM houses WHERE hWILL='{$will}'"); if($db->num_rows($hq) == 0) { } $r2=$db->fetch_row($hq); if($r['bankmoney'] < $r2['hTAX']) { $money=$r['money']; $db->query("UPDATE users SET money=money+'{$r2['hSPRICE']}', will=100, maxwill=100 WHERE userid={$r['userid']}"); event_add($r['userid'],"You failed to pay the tax, so you have lost the house.",$c); } else { $db->query("UPDATE users SET bankmoney=bankmoney-'{$r2['hTAX']}' WHERE userid='{$r['userid']}'"); } $Rows++; } ?> Totally there were <?php print($Rows); ?> rows which were executed. this is all the crontax.php Quote Link to comment Share on other sites More sharing options...
Curt Posted March 14, 2012 Share Posted March 14, 2012 The event add Function is in the global_func.php script, which I don't think is included in the cron files. Instead of using the event add function, just use a simple query insert for the event. :) Quote Link to comment Share on other sites More sharing options...
Newbie Posted March 14, 2012 Author Share Posted March 14, 2012 <?php include_once('config.php'); global $_CONFIG; if($_GET['code'] != $_CONFIG['code']) { echo 'Script execution failed'; exit; } define("MONO_ON", 1); require_once("class/class_db_{$_CONFIG['driver']}.php"); $db = new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c = $db->connection_id; $set = array(); $settq = $db->query("SELECT * FROM settings"); while($r = $db->fetch_row($settq)) { $set[$r['conf_name']] = $r['conf_value']; } /* All stuff above this comment has been pretty much left "as is" with minor edit. I have no idea why the settings are called, but considering I have no testing server, I don't want it to not run because I missed it out */ // Pull records where maxwill > 100. Since 100 is default, no tax can be applied at that point, right? $sql = "SELECT u.`userid`, u.`bankmoney`, h.* FROM `users` u LEFT JOIN `houses` h ON h.`hWILL` = u.`maxwill` WHERE u.`maxwill` > 100 ORDER BY u.`userid` ASC"; $run = mysql_query($sql); // Count results $count = mysql_num_rows($run); // If there are results, start the cron if($count > 0) { // Loop through all the results. while ($res = mysql_fetch_array($run, MYSQL_ASSOC)) { // If they don't have enough money in their bank to pay the tax, take the house if($res['bankmoney'] < $res['hTAX']) { // Set their money as the hSPRICE and remove their house (maxwill = 100 && will = 100); $sql = "UPDATE `users` SET `money` = `money` + '{$res['hSPRICE']}', `maxwill` = 100, `will` = 100 WHERE `userid` = '{$res['userid']}' LIMIT 1"; // Execute $sql mysql_query($sql); // Include global_func.php to allow the event_add() include_once('global_func.php'); // Send event to the user event_add($res['userid'], "You failed to pay your property tax, so you have been evicted from your property.", $c); } else { // They have the money to pay the property tax, so take it. $sql = "UPDATE `users` SET `bankmoney` = `bankmoney` - '{$res['hTAX']}' WHERE `userid` = '{$res['userid']}' LIMIT 1"; // Execute $sql mysql_query($sql); } } } // return count of results returned echo number_format($count) . ' records ran'; Should work. Untested. thanks works perfectly now :) 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.