Jump to content
MakeWebGames

Recommended Posts

Posted

I have searched the forums for an answer on how to fix the hour cron v2 from making the gang crimes go into the negative, can't find it..or figure it out.

 

<?php
include "config.php";
include "mysql.php";
mysql_query("UPDATE gangs SET gangCHOURS=gangCHOURS-1 WHERE gangCRIME>0",$c);
$q=mysql_query("SELECT g.*,oc.* FROM gangs g LEFT JOIN orgcrimes oc ON g.gangCRIME=oc.ocID WHERE g.gangCRIME > 0 AND g.gangCHOURS = 0",$c);
while($r=mysql_fetch_array($q))
{
$suc=rand(0,1);
if($suc) {
$log=$r['ocSTARTTEXT'].$r['ocSUCCTEXT'];
$muny=(int) (rand($r['ocMINMONEY'],$r['ocMAXMONEY']));
$log=str_replace(array("{muny}","'"),array($muny,"''"),$log);
$db->query("UPDATE gangs SET gangMONEY=gangMONEY+$muny,gangCRIME=0 WHERE gangID={$r['gangID']}",$c);
$db->query("INSERT INTO oclogs VALUES ('',{$r['ocID']},{$r['gangID']}, '$log', 'success', $muny, '{$r['ocNAME']}', unix_timestamp())",$c);
$i=mysql_insert_id($c);
$qm=mysql_query("SELECT * FROM users WHERE gang={$r['gangID']}",$c);
while($rm=mysql_fetch_array($qm))
{
$db->("INSERT INTO events VALUES ('',{$rm['userid']},unix_timestamp(),'0',\"Your gang's Organised Crime Succeeded. Go [url='oclog.php?ID=$i']here[/url] to view the details.\")");
}
}
else
{
$log=$r['ocSTARTTEXT'].$r['ocFAILTEXT'];
$muny=0;
$log=str_replace(array("{muny}","'"),array($muny,"''"),$log);
$db->query("UPDATE gangs SET gangCRIME=0 WHERE gangID={$r['gangID']}",$c);
$db->query("INSERT INTO oclogs VALUES ('',{$r['ocID']},{$r['gangID']}, '$log', 'failure', $muny, '{$r['ocNAME']}', unix_timestamp())",$c);
$i=mysql_insert_id($c);
$qm=mysql_query("SELECT * FROM users WHERE gang={$r['gangID']}",$c);
while($rm=mysql_fetch_array($qm))
{
event_add($rm['userid'],"Your Gang's Organised Crime Failed. Go [url='oclog.php?ID=$i']here[/url] to view the details.",$c);
}
}
}
if(date('G')==17)
{
$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN jobs j ON j.jID=u.job LEFT JOIN jobranks jr ON u.jobrank=jr.jrID SET u.money=u.money+jr.jrPAY, u.jobpoints=u.jobpoints+jr.jrPOINTS, u.exp=u.exp+(jr.jrPAY/20) WHERE u.job > 0 AND u.jobrank > 0");
$db->query("UPDATE userstats us LEFT JOIN users u ON u.userid=us.userid LEFT JOIN jobs j ON j.jID=u.job LEFT JOIN jobranks jr ON u.jobrank=jr.jrID SET us.strength=(us.strength+1)+jr.jrSTRG-1,us.labour=(us.labour+1)+jr.jrLABOURG-1,us.IQ=(us.IQ+1)+jr.jrIQG-1 WHERE u.job > 0 AND u.jobrank > 0");
}
if($set['validate_period'] == 60 && $set['validate_on'])
{
$db->query("UPDATE users SET verified=0");
}
?>
Posted

Re: hour cron negative v2

Try changing

 

mysql_query("UPDATE gangs SET gangCHOURS=gangCHOURS-1 WHERE gangCRIME>0",$c);

 

To This

 

mysql_query("UPDATE gangs SET gangCHOURS=gangCHOURS-1 WHERE gangCHOURS > 0 AND gangCRIME>0",$c);
Posted

Re: hour cron negative v2

now I get :

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/m/o/b/mobsterworld/html/images2/cron_hour.php on line 38

 

line 38 is:

 

while($rm=mysql_fetch_array($qm))

 

but not getting negative anymore :lol:

Posted

Re: hour cron negative v2

huh....you should have been getting that before then, lol....all u did was limit what that query ran

 

are you require "global_func.php";

I think you need to do that for the event_adds lol i noticed that looking at page.

Posted

Re: hour cron negative v2

thanks for the lesson on global_func. I understand this a little more. I still get the same error, even when I include it. You only get the error when you complete the course

  • 4 weeks later...
Posted

Re: hour cron negative v2

My gang cron doesnt change...stuck at -19 hours. Even if I run the cron through the cron_hour?code=blahblah it gives me a blank page, but doesn't change the hours.

My cron_hour:

 

<?php
include "config.php";
include "mysql.php";
require "global_func.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'];
}



$db->query("UPDATE gangs SET gangCHOURS=gangCHOURS-1 WHERE gangCHOURS > 0 AND gangCRIME>0",$c);
$q=$db->query("SELECT g.*,oc.* FROM gangs g LEFT JOIN orgcrimes oc ON g.gangCRIME=oc.ocID WHERE g.gangCRIME > 0 AND g.gangCHOURS = 0");

while($r=$db->fetch_row($q))
{
$suc=rand(0,1);
if($suc) {
$log=$r['ocSTARTTEXT'].$r['ocSUCCTEXT'];
$muny=(int) (rand($r['ocMINMONEY'],$r['ocMAXMONEY']));
$log=str_replace(array("{muny}","'"),array($muny,"''"),$log);
$db->query("UPDATE gangs SET gangMONEY=gangMONEY+$muny,gangCRIME=0 WHERE gangID={$r['gangID']}");
$db->query("INSERT INTO oclogs VALUES ('',{$r['ocID']},{$r['gangID']}, '$log', 'success', $muny, '{$r['ocNAME']}', unix_timestamp())");
$i=$db->insert_id();
$qm=$db->query("SELECT * FROM users WHERE gang={$r['gangID']}");
while($rm=$db->fetch_row($qm))
{
event_add($rm['userid'],"Your Gang's Organised Crime Succeeded. Go [url='oclog.php?ID=$i']here[/url] to view the details.",$c);
}
}
else
{
$log=$r['ocSTARTTEXT'].$r['ocFAILTEXT'];
$muny=0;
$log=str_replace(array("{muny}","'"),array($muny,"''"),$log);
$db->query("UPDATE gangs SET gangCRIME=0 WHERE gangID={$r['gangID']}");
$db->query("INSERT INTO oclogs VALUES ('',{$r['ocID']},{$r['gangID']}, '$log', 'failure', $muny, '{$r['ocNAME']}', unix_timestamp())");
$i=$db->insert_id();
$qm=$db->query("SELECT * FROM users WHERE gang={$r['gangID']}");
while($rm=$db->fetch_row($qm))
{
event_add($rm['userid'],"Your Gang's Organised Crime Failed. Go [url='oclog.php?ID=$i']here[/url] to view the details.",$c);
}
}
}

if($set['validate_period'] == 60 && $set['validate_on'])
{
$db->query("UPDATE users SET verified=0");
}
$db->disconnect();
?>
Posted

Re: hour cron negative v2

try zero'ing the time value and see if it goes neg again, it stuck at that point probably because you fixed the code while negative and never zero'ed it.

Posted

Re: hour cron negative v2

 

try zero'ing the time value and see if it goes neg again, it stuck at that point probably because you fixed the code while negative and never zero'ed it.

Do you mean zero it through the cpanel or what?

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