ID:153449
 
Is there a way for Byond to check the time on the players computer clock?

I was thinking of making some sort of system, where every day, the player gets so many points in using them for something.

So I was hoping maybe there would be a quick answer, like checking the computers time on that players pc and compaire their new time, or maybe possibly make it so it saves the players date when they log off, and when they log back on it compairs with the current date.

Any ideas?
You might be able to use world.realtime for what you want. Save it along with the player when they log out, or something, and when they log back in, compare the saved value to the current one. Although, if the person hosting the game really wanted to, they could probably fake years passing by adjusting the date in windows(or linux, macos, or *BSD).
Barring using world.realtime and making checks upon login, you could use a timer. It's fairly easy to set up.
mob
var/onlinetime

proc/timer()
onlinetime++
spawn(1) timer()

Login()
..()
timer()


If you want to use actual dates, save world.realtime when the mob is first created and add onlinetime to it for the actual timestamp.
In response to sapphiremagus (#2)
No need to set up a timer. Just use world.time, and have a variable that holds the amount of time previous to this server session. When the server goes down, add world.time to that variable and save it; when counting the current amount of time that has passed in-game, use world.time + that variable.
What the others have said are all very good ideas... as many people know, I'm a big fan of giving participation-based rewards for the time that players log. One thing that you'll want to consider, though... aside from being much harder (if even possible), going off the player's clock is a huge mistake. The player's clock is within the player's control. Log on at 1:00 p.m., and one minute later, it's 11:01 p.m.... woohoo, ten hours worth of points!
In response to sapphiremagus (#2)
A timer like that is way too CPU-intensive for the extremely restricted use it provides. I would be more likely to increase the timer by 600 every single time, and respawn that procedure every 600 ticks (1 minute). After all, if someone loses 490 ticks here or there because they didn't log out after an exact minute interval, they're not really going to complain much.
In response to Spuzzum (#5)
Actully I have gotten a free time demo from the hub, and after some tweeking, I got it to work in sync with my day/night cycles and player times. So it adds to the player every tic
In response to Shades (#6)
Doesn't mean I don't still think that tracking to the exact decisecond is pointless. =P
In response to Spuzzum (#5)
After all, if someone loses 490 ticks here or there because they didn't log out after an exact minute interval, they're not really going to complain much.

Ha ha ha ha ha ha ha!

You are seriously funny.
Any ideas?

As already noted it's best to use the host's time instead of the players to avoid easy cheating. The best way to this is quite simple and wastes no time counting like the other solution.

mob
var/jointime
var/totaltime

Login()
//TODO: Load totaltime or set to 0 if it's a new player

//Record the time the player joined
jointime = world.realtime

Logout()
//Now add the difference of the current time and the
//join time to the total time
totaltime += world.realtime - jointime
//save total time so it can be retrieved the next time
//the player logs on.


And this solution wastes no extra time doing trivial counting.

[Edit] Actually alternativly you could use world.time for more accuracy. With world.realtime I think you're measuring in ~6.5 second chunks whereas with world.time you get 0.1 second chunks.
In response to Hedgemistress (#8)
Hedgerow Hall players seriously complained about losing a whole 49 seconds if they logged off at the wrong time?
In response to Jon88 (#10)
The clock-watchers sure did. I didn't show seconds, but any time they had one minute less than they felt they should, I heard about it.
In response to Hedgemistress (#11)
That would have been the point that I'd have told them to shut up and get a life, and then pager banned them. =P
In response to Spuzzum (#12)
Pager banning someone on my computer will crash Dream Seeker, 95% of the time, otherwise I would do that a lot more often.
In response to Hedgemistress (#13)
I thought that a recent version fixed that bug...
In any case, ".hub add-ban KeyToBan" hasn't crashed me yet, and seems to work pretty well.
In response to Hedgemistress (#11)
You do want to pager ban them when you can hard code some very interesting things...
I'm thinking along the lines of them having to wait an extra 5 seconds for every time they log on. So if the wait is 1 minute the next logon time they'll have to wait 1 min. 5 sec. and then the next time 1 min. 10 sec. and so on.