Re: Resource based game
Posted: Mon Mar 28, 2011 3:27 pm
ive actually come across this sort of a problem in my game where i need to add stamina to a player even while offline. my solution:upix wrote:i need help to create a code that will add constantly resources even the player is not online.
problem is that I can not install on my server, any program type Crono, I available only a scheduler function on a server that in can run a file at 1 hour interval.
Ex:
food= [food_current +(food_id * food_workers)] -(food eaten in the time interval)
thy for help
save a timestamp in the resource table, then each time the player is active ie: logs in or performs an action on a page,
create a function that compares the current time and the saved timestamp in the resources table. then you can write some code that will say: divide the number of hours passed between the current time and the timestamp; then you can multiply the resource gain or loss by the number of hours passed.
in essence youre creating an "on view" version of a cron rather than rely on a cron itself.
hope this helps you.