Jump to content
MakeWebGames

Recommended Posts

Posted

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

Posted

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.

Posted

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.
Posted

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

Posted
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.

Posted

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

Posted

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. :)

Posted
<?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 :)

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.

×
×
  • Create New...