ID:170973
 
Hello,How would a check to see how long a server has been up. Like when i go to the hub page i want it to show in world status.

world/status="Server uptime [time] Minute(s)"


How would i keep checking and updating the hub page to put the information there that says how long the game has been running? I'm not looking for code just asking how to accomplish this,Thanks in advance.

~>Jiskuha
You could use the world.realtime or world.timeofday variables. When the world starts up, save the current time in a variable. Whenever you want to see how long the world has been up for, subtract the new variable from the old, and use time2text().

If your server stays up for more than a day, you might need to make a more complicated procedure to build a text string out of the time. :)
The world.time var does exactly what you want (look it up in the reference). It measures in ticks, so divide by 600 (and, optionally, round off) to get the number of minutes.

You'll need to run a loop that updates world.status every so often with the new value. Once every minute, say.
In response to Crispy
I was going to reply and say that, then I realised Jon probably didn't go with the time variable since it can be innacurate after a while, especially if the server has a large load and ticks get slowed down.
In response to Loduwijk
Mmm, true. Perhaps world.realtime would be more appropriate. There's not much point using world.timeofday, though; what if the server runs overnight? You'll get negative uptime. =P Besides, the granularity of world.realtime doesn't matter much if you're talking in minutes.