Jump to content
MakeWebGames

Problem regarding Hour_Cron IN Mccode V2


chaoswar4u

Recommended Posts

The bug is regarding the bit of code that is used for the organised crimes. When it comes to the end of the crime you seceed or fail thus the cron comes with this message when failing to add events.

The error is - Call to undefined function event_add() on line 36

This is the code out the cron

$db->query("UPDATE gangs SET gangCHOURS=gangCHOURS-1 WHERE gangCRIME>0");

$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 here 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 here to view the details.",$c);

}

}

}

Line 36 being this

event_add($rm['userid'],"Your Gang's Organised Crime Succeeded. Go here to view the details.",$c);

error also applies to

event_add($rm['userid'],"Your Gang's Organised Crime Failed. Go here to view the details.",$c);

Anyone out there no how to fix? Thx for any help in advance.

Link to comment
Share on other sites

Re: Problem regarding Hour_Cron IN Mccode V2

I'm unclear on the details, but most crons dont seem to access global_func in 2.0.

There is likely a reason for that. *shrug* I haven't bothered to figure it out.

Anyway, I usually copy the event_add function from global_func and add it to any cron I want to use it

Link to comment
Share on other sites

Re: Problem regarding Hour_Cron IN Mccode V2

Well Done deathstar. Another un useful reply. I added that function UCC but then came up with another error for undefined function. Ill have a look into and post my findings otherwise if anyone has already got the fix for this then your help would be great.

Link to comment
Share on other sites

Re: Problem regarding Hour_Cron IN Mccode V2

if you have your crons in a different directory to your global_func.php, you will either need to reference the global_func.php from your cron file or make a copy of global_func.php and add it to ur cron directory

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