Jump to content
MakeWebGames

Removal of 1 minute crons help


boots

Recommended Posts

Please help Im trying to get this to run my bodygaurd cron all works fine with the hosp and jail but i cant seem to make it work for the bgaurd this what i have now like i say hosp and jail work fine

 

<?PHP
$result = $db->query("SELECT * FROM `updates` WHERE `name` = '1min'");
$result = $db->fetch_row($result);
$hla    = time() - $result['last'];

if($hla > (60))
{
   $n = floor($hla / 60); 
   $hospital = (1 * $n);
   $bguard = (1 * $n);
   $jail   = (1 * $n);

   $query_hos = sprintf("UPDATE users SET hospital = hospital - %u WHERE hospital <> 0", $hospital);
   $query_jail = sprintf("UPDATE users SET jail = jail - %u WHERE jail <> 0", $jail);
   $query_bguard = sprintf("UPDATE users SET bguard = bguard - %u WHERE bguard <> 0", $bguard);


   $db->query($query_hos);
   $db->query($query_jail);
   $db->query($query_bguard);  
   $db->query("UPDATE `users` SET `hospital` = 0 WHERE `hospital` < 0");
   $db->query("UPDATE `users` SET `jail` = 0 WHERE `jail` < 0");
   $db->query("UPDATE users SET bguard=bguard-1 WHERE bguard>0");
   $db->query("UPDATE users SET bguard=0 WHERE bguard<0");

   $time = time();
   $db->query("UPDATE `updates` SET `last` = ".$time." WHERE `name` = '1min'");
   $floor = $time - (floor($time / 60) * 60);
   if($floor > 0)
   {
       $newUpdate = time() - $floor;
       $db->query("UPDATE `updates` SET `last` = ".$newUpdate." WHERE `name` = '1min'");
   }
}

?>

 

This is my 1 min cron

 

<?PHP
include "config.php";
include "language.php";
global $_CONFIG;
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;
$db->query("UPDATE users set hospital=hospital-1 WHERE hospital>0");
$db->query("UPDATE `users` SET jail=jail-1 WHERE `jail` > 0");
$db->query("UPDATE users SET traveltime=traveltime-1 WHERE traveltime > 0");
$db->query("UPDATE users SET bguard=bguard-1 WHERE bguard>0");
$db->query("UPDATE users SET bguard=0 WHERE bguard<0");
$hc=$db->num_rows($db->query("SELECT * FROM users WHERE hospital > 0"));
$jc=$db->num_rows($db->query("SELECT * FROM users WHERE jail > 0"));
$db->query("UPDATE settings SET conf_value='$hc' WHERE conf_name='hospital_count'");
$db->query("UPDATE settings SET conf_value='$jc' WHERE conf_name='jail_count'");

?>
Edited by illusions
Added code tags
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...