[SOLVED] Resource per hour

Location of the Videos
Post Reply
User avatar
noswear
Posts: 18
Joined: Thu Jan 13, 2011 9:39 pm

[SOLVED] Resource per hour

Post by noswear »

For my browser game, im making a resource system, with wood, food and stone. The resources are gain bases on the building level, per hour: lumber yard is at 5, so i want to get 500 wood per hour. Can anyone explain me how to make that system?
Last edited by noswear on Thu Apr 28, 2011 12:44 pm, edited 1 time in total.
Image
ConceptDestiny
Posts: 261
Joined: Wed Apr 28, 2010 8:35 am

Re: Resource per hour

Post by ConceptDestiny »

assuming you've already got a grid map system... I'd go with as a pure example:

1. create table called mines (mineid, mapr, mapc, minename, mineamount)
2. insert into mines table new mine at x,y coords on the map, set default amount
3. set up a cron to update the mines table, set mineamount=mineamount+whatever, and set the cron to execute every hour? or such.
User avatar
noswear
Posts: 18
Joined: Thu Jan 13, 2011 9:39 pm

Re: Resource per hour

Post by noswear »

Yes i have a grid map system, but thats not what im saying. I want something like Travian or Ikariam, to have resources per hour based on the building level.
Image
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: Resource per hour

Post by vitinho444 »

thats with the time function...
i want it too but i want to make like a job and be payed for like 1 hour.
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
Xaleph
Posts: 897
Joined: Mon Feb 07, 2011 2:55 am

Re: Resource per hour

Post by Xaleph »

Use timestamps. You can calculate offsets based on time right? Like 60*60 is 1 hour ( 60 seconds * 60 minutes = 3600 secs == hour ) and thus you know how many you should gain. This is based on hours, but ikariam and travian are minute based ( which is better )

You should have a last_update_time and a update function which checks the time every minute, if more then 60 seconds ( or 1 hour ) have passed since the last_update_time, you can update your resources for the player and once they have been updated, change the last_update_time to the current timestamp.
User avatar
noswear
Posts: 18
Joined: Thu Jan 13, 2011 9:39 pm

Re: Resource per hour

Post by noswear »

Thanks for the tip, its done and working :D once i finish the system, ill upload it to the game ;)
Image
Post Reply

Return to “Older Browser MMO Videos”