Jump to content

Adding gold every minute???!!!!!!


Thauwa

Recommended Posts

cronjob - good option

ajax - ok option gives you direct controle throgh a browser

 

process  - dosent need to be cronned will run as a demon this can be done in the cronjob or started manualy to run forver will be good on saving resources

create a file call it resourcesadd.php then sudo php resourcesadd.php in cmd  execute it on the server and then just leave it running

while(1){

    sleep((1000*60));

    //add resources

}

 

you can use a web site page to start and kiill this process or start and kill a cron job

Link to comment
Share on other sites

nah best way to do that is the following on every user.

 

Time of last update

get Time Now, work out how many mins have passed from last update.

If greater then 1 min change last update to time now.

Give what ever resources * mins passed.

Link to comment
Share on other sites

Both ajax and on page request (basically the same thing) would require at least one player at all times.

Even worse on page request you'd need to have one person visiting a page every minute.

 

So yeah, cronjob

Link to comment
Share on other sites

Both ajax and on page request (basically the same thing) would require at least one player at all times.

Even worse on page request you'd need to have one person visiting a page every minute.

 

So yeah, cronjob

 

i was thinking you could have an admin page that you just leave running on some admins computer with repeated ajax calls to the required script, or he coudl write a demon, cronjob is all good thogh

Link to comment
Share on other sites

YEah. Thanks guys for all the help, from what you all said, cron job is my solution. But now I have an idea of what to do.

What I really need is to have the an constant income of gold, so that many users would not get fed up of the game, and earn other resources manually. So, cron job, here I come!

P.S. Please  post of more ideas, I will post back! I think my question was good, for what was on my mind was posted here.

Another question. Can a php page be viewed with its codes, and the mysql passwords stolen?

Link to comment
Share on other sites

And, has anyone an idea on how to put a thing like what is at the bottom of this page?

Powered by SMF 2.0 RC1 | SMF © 2006–2009, Simple Machines LLC 
XHTML RSS WAP2

Even I use SMF, but I have developed my own software (online), and want to put something like that, a one which can't be deleted. Does anyone have any suggestions?  ???

Link to comment
Share on other sites

I dont think you need a cron job for this,

 

you can simply use mysql / php in a function script included on every page...

 


function addGold($gold, $timer = 60)
{
   $query = "SELECT lastGold, curGold FROM userTable WHERE userField = '" . mysql_real_escape_string($_SESSION['userSess']) . "' LIMIT 1";
   $result = musql_query($query)or trigger_error("Mysql Error, could not get userdata gold.");

      $row = mysql_fetch_row($result);

     $lastGold = $row[0] - time();
     $curGold = $row[1];
     $toAdd   = 0;

     while ($lastGold > $timer)
     {
         $lastGold -= $timer;
         $toAdd   += $gold;
     }

   $curGold += $toAdd;
   mysql_query("UPDATE userTable SET lastGold = " . time() + $lastGold. ", curGold = " . intVal($curGold) . " WHERE userField = '" . mysql_real_escape_string($_SESSION['userSess']) . "' LIMIT 1")or trigger_error("Mysql Error, Could not add gold."); 
     return $toAdd;

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.