Jump to content

Manual Cron not working at all


ryeman98

Recommended Posts

So there aren't any errors that pop up, it's just plain not working

 

// SHOP RESTOCKING CRON
$shops = mysql_query("SELECT * FROM `shops`");
$forward = time()+480;
$res_time = date("F j - H:i"); // Current time
$res_update_time = date("F j - H:i", $forward); // 8 minutes from now

while ($shops_row = mysql_fetch_array($shops)) {
$shop_id = $shops_row['id'];
$restocks = mysql_query("SELECT * FROM `shop_restocking` WHERE shop_id='$shop_id'");
while ($restocks_row = mysql_fetch_array($restocks)) {
	$amount_items = $restocks_row['SUM(amount)']; // Total amount of items in the shop
	$i = $amount_items;
	if ($amount_items <= 5) { // If the amount of items equals 5 or less, continue
		if ($res_time >= $res_update_time) { // If the 8 minute wait is up, continue
			while ($i<=50) { // Loop while $i is less than 50
			$restock_min = 1;
			$restock_max = $restocks_row['COUNT(id)'];
			$rand_num = rand($restock_min, $restock_max); // Picks a random number
			$res_check_id = mysql_query("SELECT * FROM `shop_restocking` WHERE item_id='$rand_num'"); // Check if the id exists
				if (!$res_check_id) { // If the id does not exist, do nothing
				} else { // If the id exists, continue
					$check_id_row = mysql_fetch_array($res_check_id);
					$rarity = $check_id_row['rarity']; // The item's rarity
					$amount = round($rarity/8); // The amount of items that will be entered
					$res_update = mysql_query("UPDATE `shop_restocking` SET amount='$amount' WHERE id='$rand_num'"); // Reset the amount
				} // End if
			$i=$i+$amount;
			} // End while
		} // End if
	} // End if
} // End while
} // End while

 

So it works by checking the total amount of items in a shop. If there are less than 5 items, then the shop should wait 8 minutes and then be restocked. Then it just starts picking random items to put into the shop up until there are a total of at least 50 items.

 

I know the code is a bit sloppy but I'd rather get it working before making it look pretty. What good is pretty code if it doesn't work?

Link to comment
https://forums.phpfreaks.com/topic/113358-manual-cron-not-working-at-all/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.