Jump to content
MakeWebGames

Cron problem - No energy for some users, others get it.


Recommended Posts

Posted

I've got a big problem with my five-min cron. Some users get their energy, while others get nothing! I've got no idea what's causing this, though it seems it applies mostly, if not only, to users who is level one.

Please help, anyone?

Here is my cron.

 

<?php
include "config.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'];
}
//brave update
$query="UPDATE users SET brave=brave+1 WHERE brave<maxbrave ";
$query2="UPDATE users SET brave=maxbrave WHERE brave>maxbrave";
$query3="UPDATE users SET hp=hp+(maxhp/3) WHERE hp<maxhp";
$query4="UPDATE users SET hp=maxhp WHERE hp>maxhp";
$db->query($query);
$db->query($query2);
$db->query($query3);
$db->query($query4);
//enerwill update
$query="UPDATE users SET energy=energy+(maxenergy/(25)) WHERE energy<maxenergy AND donatordays=0";
$query5="UPDATE users SET energy=energy+(maxenergy/(12.5)) WHERE energy<maxenergy AND donatordays>0";
$query2="UPDATE users SET energy=maxenergy WHERE energy>maxenergy";
$query3="UPDATE users SET will=will+10 WHERE will<maxwill";
$query4="UPDATE users SET will=maxwill WHERE will>maxwill";
$db->query($query);
$db->query($query5);
$db->query($query2);
$db->query($query3);
$db->query($query4);
if($set['validate_period'] == 5 && $set['validate_on'])
{
$db->query("UPDATE users SET verified=0");
}
if($set['validate_period'] == 15 && $set['validate_on'] && in_array(date('i'),array("00", "15", "30", "45")))
{
$db->query("UPDATE users SET verified=0");
}
?>
Posted

Re: Cron problem - No energy for some users, others get it.

I was wrong. It's not level one's who don't gain energy. I manually upgraded my level one testaccount to have a maxenergy of 13, instead of 12, and suddenly he began regaining energy. When I then went into register.php and changed the default to 13 maxenergy, instead of 12, they, again, didn't regain energy. When I then changeed the maxenergy from 13 to 12, he began regaining energy again!

So, for some reason, it seems that all my users need to have their maxenergy upgraded before the cron works on them, and they can regain energy.

This only applies to the energy, everything else works fine... I'm still really stuck on this stuff, so if anyone has any ideas?

Posted

Re: Cron problem - No energy for some users, others get it.

you have energy=energy+maxenergy/25

if max energy is 10 you are dividing that by 25 which equals 0.4

0.4 will be rounded up to 0 hence its not updating...

you need to set the default max energy higher or lower the amount you want it to update by so its at least over 0.5

Posted

Re: Cron problem - No energy for some users, others get it.

for a percent i use this from time to time. this would be 10%

ofcourse it meight not always work./

energy = energy + maxenergy/100*10

Posted

Re: Cron problem - No energy for some users, others get it.

 

for a percent i use this from time to time. this would be 10%

ofcourse it meight not always work./

energy = energy + maxenergy/100*10

why don't you just do this,

energy = energy + maxenergy/10 or energy = energy + maxenergy*1.10

Don't you think its shorter, and it give out the same income

Posted

Re: Cron problem - No energy for some users, others get it.

becasue that example was to show them how to get a percent. not just 10.

so they can use /100*12 for 12 pecente just / 12 is not going to work. that is why i did it that way.

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