Jump to content
MakeWebGames

Recommended Posts

Posted

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:

Posted

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

Posted

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)); }	
}
?>
Posted

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

I am looking for someone that can help me, or make a timestamp instead of cron. Cron is impossible to get to work free...

+ My crons are not working, the link does not work...

Posted

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

  • 11 months later...
Posted
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?

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