Hello everyone,
I am working on a script right now that works a little something like this: There is a shield, and I may launch an attack upon said shield at any time I please as the admin. However, once the attack is launched, there is a 2 hour countdown until the shield is broken through, and then a 30 minute countdown until the forces arrive at the target. But this target is where every player is (Hogwarts), so they all may either choose not to participate, or participate in the defense against the attack. Regardless, I want every player to be able to see the same countdown (whether you're in Ireland or America, or wherever) so that it ends at the same time for everyone. I have managed to get a working countdown, but it is only player specific (where it starts the countdown upon refreshing the page/on my command, and if one player logs on an hour after the other, the timer starts for them when they log on)
So if I didn't make it clear in that blurb what my question was, which I don't think I did hahaha, how can I make this one universal countdown where everyone can see it all the same, regardless of how many times they refresh a page or when they log on/where they are in the world. I'm pretty sure for that, it needs to be in the database, but beyond that I have absolutely no idea what to do. Any and all help is much appreciated!
Thanks,
~Kevin
Universal Countdown
Universal Countdown
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Re: Universal Countdown
Well, like you have a players category in your DB, you make up a 'worldstats' category as well, and have it store 'shieldtime' or whatever. Then everyone uses that, rather than a time entry in every single players DB entry (which is what I assume your using now).
Atleast that's what I do - there needs to be a central stat and the player category just isn't much good for that.
Atleast that's what I do - there needs to be a central stat and the player category just isn't much good for that.
- Foofighter
- Posts: 121
- Joined: Sun Mar 04, 2012 1:52 pm
Re: Universal Countdown
Hi,
i wrote my script for this in this Thread, hope it helps
http://indie-resource.com/forums/viewto ... =71&t=4666
regards
i wrote my script for this in this Thread, hope it helps
http://indie-resource.com/forums/viewto ... =71&t=4666
regards
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Universal Countdown
It will probably need to be server-side to keep everyone in-sync. When a player loads the page, a time value in the database is used to calculate how much time is left. That value is sent to the browser, at which point the browser turns it into a client-side timer to simulate the countdown. I would say this would keep everyone's time together within maybe a second or two for various network lag, browser loading times, and slower computers. If that second or two difference is OK, I would say this would be the easiest. If its not OK, then you would likely have to go web sockets with maybe something like a node.js back-end and make each second tick real-time, which would be significantly more work.
The indelible lord of tl;dr
Re: Universal Countdown
Thanks so much for the help/suggestions everyone! And Jack, it isn't going to be a big deal if it's a few seconds off, I'll keep it simple for now. Come beta though, I may use sockets/make it more accurate just to clear it up (in the event that for some reason it did become a problem). I'll test this soon and let you all know how it goes, and thanks again!
~Kevin
~Kevin
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny