Jump to content
MakeWebGames

Education.php


athena26

Recommended Posts

3 hours ago, athena26 said:

How do I fix this .

What can I do to fix this should I post my education.php in here and the cron I'm using ?

It would be helpful, yea or supply the necessary/relevant lines of code..

Do you have a globals file running for education that handles the data or is this all done in crons, you need to make sure a DELETE FROM or something appropriate is actioned when the education time hits zero or is equal to current time

Pm me if you need any assistance

Link to comment
Share on other sites

ok here the education.php that i have i got it from here in the forums ,,,

 

 

<?php
/*
This is free work of Razor42!
Do not try to re-sell this!
*/
include "globals.php";
print "<h3>Schooling</h3>";
if($ir['course'] > 0)
{
$cd=$db->query("SELECT * FROM courses WHERE crID={$ir['course']}");
$coud=$db->fetch_row($cd);
print "You are currently doing the {$coud['crNAME']}, you have {$ir['cdays']} days remaining.";
}
else
{
if($_GET['cstart'])
{
$_GET['cstart'] = abs((int) $_GET['cstart']);
//Verify.
$cd=$db->query("SELECT * FROM courses WHERE crID={$_GET['cstart']}");
if($db->num_rows($cd) == 0)
{
print "You are trying to start a non-existant course!";
}
else
{
$coud=$db->fetch_row($cd);
$cdo=$db->query("SELECT * FROM coursesdone WHERE userid=$userid AND courseid={$_GET['cstart']}");
if($ir['money'] < $coud['crCOST'])
{
print "You don't have enough money to start this course.";
$h->endpage();
exit;
}
if($ir['level'] < $coud['crLEVEL'])
{
print "Your don't have the required level to start this course.";
$h->endpage();
exit;
}
if($db->num_rows($cdo) > 0)
{
print "You have already done this course.";
$h->endpage();
exit;
}
$db->query("UPDATE users SET course={$_GET['cstart']},cdays={$coud['crDAYS']},money=money-{$coud['crCOST']} WHERE userid=$userid");
print "You have started the {$coud['crNAME']}, it will take {$coud['crDAYS']} days to complete.";
}
}
else
{
//list courses
print "Here is a list of available courses.";
$q=$db->query("SELECT * FROM courses");
print "<br /><table width=75% cellspacing=1 class='table'><tr style='background:gray;'><th>Course</th><th>Description</th><th>Cost</th><th>Level</th><th>Take</th></tr>";
while($r=$db->fetch_row($q))
{
$cdo=$db->query("SELECT * FROM coursesdone WHERE userid=$userid AND courseid={$r['crID']}");
if($db->num_rows($cdo)) { $do="<i>Done</i>"; } else { $do="<a href='education.php?cstart={$r['crID']}'>Take</a>"; }
print "<tr><td>{$r['crNAME']}</td><td>{$r['crDESC']}</td><td>\${$r['crCOST']}</td><td>{$r['crLEVEL']}</td><td>$do</td></tr>";
}
print "</table>";
}
}
$h->endpage();
?>


and the cron that is currently running on this education file is
 

$db->query("UPDATE users SET cdays=cdays-1 WHERE course > 0");

$q=$db->query("SELECT * FROM users WHERE cdays=0 AND course > 0");
while($r=$db->fetch_row($q))
{
$cd=$db->query("SELECT * FROM courses WHERE crID={$r['course']}");
$coud=$db->fetch_row($cd);
$userid=$r['userid'];
$db->query("INSERT INTO coursesdone VALUES({$r['userid']},{$r['course']})");
$upd="";
$ev="";
if($coud['crSTR'] > 0)
{
$upd.=",us.strength=us.strength+{$coud['crSTR']}";
$ev.=", {$coud['crSTR']} strength";
}
if($coud['crGUARD'] > 0)
{
$upd.=",us.guard=us.guard+{$coud['crGUARD']}";
$ev.=", {$coud['crGUARD']} guard";
}
if($coud['crLABOUR'] > 0)
{
$upd.=",us.labour=us.labour+{$coud['crLABOUR']}";
$ev.=", {$coud['crLABOUR']} labour";
}
if($coud['crAGIL'] > 0)
{
$upd.=",us.agility=us.agility+{$coud['crAGIL']}";
$ev.=", {$coud['crAGIL']} agility";
}
if($coud['crIQ'] > 0)
{
$upd.=",us.IQ=us.IQ+{$coud['crIQ']}";
$ev.=", {$coud['crIQ']} IQ";
}
$ev=substr($ev,1);
if ($upd) {
$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET us.userid=us.userid $upd WHERE u.userid=$userid");
}
$db->query("INSERT INTO events VALUES('',$userid,unix_timestamp(),0,'Congratulations, you completed the {$coud['crNAME']} and gained $ev!')");
}
$db->query("UPDATE users SET course=0 WHERE cdays=0");
$db->query("TRUNCATE TABLE votes;");
?>

 

Link to comment
Share on other sites

Thats very odd. -21days. I dont see how it got to -21days. Once at 0 days it should delete course according to code.

But

$db->query("TRUNCATE TABLE votes;");

y is thus here in education cron?

Edited by Sim
Link to comment
Share on other sites

On 3/15/2021 at 10:03 PM, Sim said:

Thats very odd. -21days. I dont see how it got to -21days. Once at 0 days it should delete course according to code.

But


$db->query("TRUNCATE TABLE votes;");

y is thus here in education cron?

That's in that cron file because that's base mccodes day cron. So it truncates votes daily.

  • Like 1
Link to comment
Share on other sites

It would probably be easier if you just used timestamps instead im very new at coding too  i tried mccodes and was a pain there is timestamps for mccodes somewhere on mkg id take a look at it 😉 i mean its good to learn but it would make your life eadier:)

Like his

 

Link to comment
Share on other sites

  • 4 weeks later...

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