Jump to content
MakeWebGames

Day cron help for upkeep mod


gurpreet

Recommended Posts

Hey everyone, I am currently trying to an upkeep mod for the community as a free mod, and it's quite complex (i think it is). So I'm having a bit of trouble with the last bit, which is the daily cron. I was wondering if there is a better way to do the code I have. Also I know the RemoveItems part is not complete. I want to keep this code as efficient as possible because I'm fixing up my cron_day, which takes 20 seconds to load!

However, there are a few problems, the main one being that the upkeepowed does not get updated. I have my setting set to StackUp and I've set my upkeep to 150,000. If someone can help with that, it would be great. If needed I can post up other pages and such.

Anyway here's what I've got so far:

 

$upkeepcheck = $db->query("SELECT i.itmid, i.upkeep, inv . * , u.userid, u.will, u.maxwill, u.upkeepowed, u.money, h.hPRICE, hWILL
FROM items i
LEFT JOIN inventory inv ON inv.inv_itemid = i.itmid
LEFT JOIN users u ON inv.inv_userid = u.userid
LEFT JOIN houses h ON h.hWILL = u.maxwill
WHERE i.upkeep >0");
$q5 = $db->query("SELECT * FROM settings WHERE conf_name = 'upkeep'");
while($upkeep=mysql_fetch_array($upkeepcheck))
{
while($upkeep1=mysql_fetch_array($q5))
{
	if($upkeep['money'] > $upkeep['upkeep'])
	{
		$db->query("UPDATE users SET money = money - {$upkeep['upkeep']} WHERE userid = {$upkeep['userid']}");
	}
	else if($upkeep['upkeep'] > $upkeep['money'])
	{
		$db->query("UPDATE users SET upkeepowed = upkeepowed + {$upkeep['upkeep']} WHERE userid = {$upkeep['userid']}");
	}


	if($upkeep1['conf_value'] == 'Stackup')
	{
		if($upkeep['upkeepowed'] > $upkeep['hPRICE'])
		{
			$db->query("UPDATE users SET will=100,maxwill=100 WHERE userid = {$upkeep['userid']}");
			$db->query("UPDATE users SET upkeepowed = 0 WHERE userid = {$upkeep['userid']}");
			event_add($upkeep['userid'], "You haven't paid your upkeep, so your house has been taken away. Next time sell some weapons or earn some more money to pay your upkeep!", $c);
		}
		else
		{
		$rem = $db->query("SELECT i.itmid, i.upkeep, inv.*, u.userid, u.upkeepowed
		FROM items i
		LEFT JOIN inventory inv ON inv.inv_itemid = i.itmid
		LEFT JOIN users u ON inv.inv_userid = u.userid
		WHERE userid = {$upkeep['userid']}");
		$remove = mysql_fetch_array($rem);
			if(isset($remove['upkeep']))
			{
				$new_upkeep += $remove['upkeep'];
				$db->query("UPDATE users SET upkeepowed = upkeepowed + $new_upkeep WHERE userid = {$upkeep['userid']}");
			}
		}
	}
	else if($upkeep1['conf_value'] == 'RemoveItems')
	{
		$rem = $db->query("SELECT i.itmid, i.upkeep, inv.*, u.userid, u.upkeepowed
		FROM items i
		LEFT JOIN inventory inv ON inv.inv_itemid = i.itmid
		LEFT JOIN users u ON inv.inv_userid = u.userid
		WHERE userid = {$upkeep['userid']}");
		$remove = mysql_fetch_array($rem);
		if(isset($remove['upkeep']))
		{
			$new_upkeep += $remove['upkeep'];
			//More code is going here
		}
	}
}
}
Edited by gurpreet
Link to comment
Share on other sites

Basically certain items, mostly expensive weapons/armours will have 'upkeep'. This is like tax, but for items. Basically something to keep the economy stable so the rich guys will have to pay some stuff, instead of getting richer and richer. It turned out to be much larger than I thought though

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.

×
×
  • Create New...