Jump to content
MakeWebGames

[mccodes v2] Awsome cron help [TIMESTAMP]


kjehun
 Share

Recommended Posts

I need help with cron, and i want to use timestamp instead. i have only one problem, i have no idea how.

I have made a site, and I've got it online, but i cant deal with the crons.

 

can some of you make a full timestamp mod? Please? :|

 

:mrgreen:

Link to comment
Share on other sites

Re: [mccodes v2] Awsome cron help [TIMESTAMP]

 

Yo like i said rong board too most needs to be moved xD :)

Yeah I read the first time and yes it is in the wrong place but I bet it'll get moved - I didnt want to wait so asked my question to him now

Link to comment
Share on other sites

Re: [mccodes v2] Awsome cron help [TIMESTAMP]

This is only a guide ( i created this for a non mccodes game ;) )..

 

<?php
$result = $DB->query("SELECT * FROM `updates` WHERE `name` = '5min'");
$result = $DB->fetchRow($result);
$howLongAgo = time() - $result['last'];
if($howLongAgo > (300)) {
$n = floor($howLongAgo / 300);
$user = new User($_SESSION['userid']);
$energy = ($user->energy) + (5 * $n);
$energy = ($energy > $user->maxenergy) ? $user->maxenergy : $energy;
$brave = ($user->brave) + (2 * $n);
$brave = ($brave > $user->brave) ? $user->maxbrave : $brave;
$hp = $user->hp + (($user->maxhp * .25) * $n);

$hp = ($hp > $user->maxhp) ? $user->maxhp : $newhp;
$will = ($user->will) + (5 * $n);
$will = ($will > $user->will) ? $user->maxwill : $will;
$string = sprintf("UPDATE `users` SET `energy` = '%u', `brave` = '%u', `hp` = '%u', `will` = '%u'",
abs(@intval($energy)),abs(@intval($brave)),abs(@intval($hp,$will)));
$DB->query($string);
$t = time();

$result = $DB->query("UPDATE `updates` SET `last` = '%u' WHERE `name` = '5min'",$t);

$l = $t - (floor($t / 300) * 300);

if ($l > 0) { $newUpdate =  time() - $l; $result = $DB->query(sprintf("UPDATE `updates` SET `last` = '%u' WHERE `name` = '5min'",$newUpdate)); }	
}
?>
Link to comment
Share on other sites

Re: [mccodes v2] Awsome cron help [TIMESTAMP]

 

This is only a guide ( i created this for a non mccodes game ;) )..

 

<?php
$result = $DB->query("SELECT * FROM `updates` WHERE `name` = '5min'");
$result = $DB->fetchRow($result);
$howLongAgo = time() - $result['last'];
if($howLongAgo > (300)) {
$n = floor($howLongAgo / 300);
$user = new User($_SESSION['userid']);
$energy = ($user->energy) + (5 * $n);
$energy = ($energy > $user->maxenergy) ? $user->maxenergy : $energy;
$brave = ($user->brave) + (2 * $n);
$brave = ($brave > $user->brave) ? $user->maxbrave : $brave;
$hp = $user->hp + (($user->maxhp * .25) * $n);

$hp = ($hp > $user->maxhp) ? $user->maxhp : $newhp;
$will = ($user->will) + (5 * $n);
$will = ($will > $user->will) ? $user->maxwill : $will;
$string = sprintf("UPDATE `users` SET `energy` = '%u', `brave` = '%u', `hp` = '%u', `will` = '%u'",
abs(@intval($energy)),abs(@intval($brave)),abs(@intval($hp,$will)));
$DB->query($string);
$t = time();

$result = $DB->query("UPDATE `updates` SET `last` = '%u' WHERE `name` = '5min'",$t);

$l = $t - (floor($t / 300) * 300);

if ($l > 0) { $newUpdate =  time() - $l; $result = $DB->query(sprintf("UPDATE `updates` SET `last` = '%u' WHERE `name` = '5min'",$newUpdate)); }	
}
?>

 

 

How can i use this instead of cron? :D

Write something in my index or login or..? ;) Sorry, but im a n00b in this. Trying to learn

Link to comment
Share on other sites

  • 11 months later...
This is only a guide ( i created this for a non mccodes game ;) )..

 

$result = $DB->query("SELECT * FROM `updates` WHERE `name` = '5min'");
$result = $DB->fetchRow($result);
$howLongAgo = time() - $result['last'];
if($howLongAgo > (300)) {
$n = floor($howLongAgo / 300);
$user = new User($_SESSION['userid']);
$energy = ($user->energy) + (5 * $n);
$energy = ($energy > $user->maxenergy) ? $user->maxenergy : $energy;
$brave = ($user->brave) + (2 * $n);
$brave = ($brave > $user->brave) ? $user->maxbrave : $brave;
$hp = $user->hp + (($user->maxhp * .25) * $n);

$hp = ($hp > $user->maxhp) ? $user->maxhp : $newhp;
$will = ($user->will) + (5 * $n);
$will = ($will > $user->will) ? $user->maxwill : $will;
$string = sprintf("UPDATE `users` SET `energy` = '%u', `brave` = '%u', `hp` = '%u', `will` = '%u'",
abs(@intval($energy)),abs(@intval($brave)),abs(@intval($hp,$will)));
$DB->query($string);
$t = time();

$result = $DB->query("UPDATE `updates` SET `last` = '%u' WHERE `name` = '5min'",$t);

$l = $t - (floor($t / 300) * 300);

if ($l > 0) { $newUpdate =  time() - $l; $result = $DB->query(sprintf("UPDATE `updates` SET `last` = '%u' WHERE `name` = '5min'",$newUpdate)); }	
}
?>
I apologize for bumping ancient posts, but I'd like to know how I can use this instead of crons. Can anybody give me a little guidance? I'm trying to completely replace all my crons.

Where would I put this code?

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.

 Share

×
×
  • Create New...