The online racing simulator
Timer that counts down while the user is offline
Hi i was wondering if someone would be able to help me with a c# timer that counts down while the user is offline and while they are online like a lottery timer my timer dosent work for people being offline this is the code i use:

LottoTimer = (int)Math.Round((new Random().NextDouble() + .1) * 3600);

and i tried system timers but when it says you have to wait 1023452 minutes or something and i cant fix it so if anyone can help it will be appreciated thanks guys


Just to make it more clear, While the user is offline it will count down and update their txt user file.
-
(JasonJ) DELETED by JasonJ
#2 - Silox
If you mean that people can only use the lottery once in 24 hours for example (cause I don't really understand your problem now) you just should save the seconds, milliseconds or something from (for example) their first time on the server. If they buy a lottery ticket, you just have to check if the difference between the time now and the time of their last lottery is bigger then 24 hours.
#3 - gru
save DateTime on user exit, load it on user join, substract from DateTime.Now - U have Your offline time span

using timer isnt best idea, U would have to loop through all txt files, and what if Your system has 5000 users?
yes time and date is what im using now and if it was reading and updateing when the user is offline it would lag like hell.
Quote from Azzano62 :yes time and date is what im using now and if it was reading and updateing when the user is offline it would lag like hell.

Then you're doing something wrong, all it has to do is log the time a user signed off at (the unix-style timestamp) and subtract it from the timestamp when the user joines again, that's the time (in seconds) the user has been offline

Example: I leave the server at 12:00 today, that's 1245672000. At 3pm (1245682800), I join the server again.
(1245682800 - 1245672000) = 10800 seconds / 3600 = 3 hours.

FGED GREDG RDFGDR GSFDG