Thread: Timevar?
View Single Post
  #3  
Old 05-10-2011, 03:54 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Quote:
Originally Posted by Skyld View Post
Well, timevar increases by 1 every 5 seconds. timevar2 is the number of seconds since the UNIX epoch (midnight 1st January 1970).

If you save timevar2's value somewhere (for example, clientr.lasttime), you can then do something like timevar2 - clientr.lasttime to see how many seconds have passed since the flag clientr.lasttime was set. You could even do something like if ((timevar2 - clientr.lasttime) > 30) which would check if the flag was set over 30 seconds ago.

The only problem is that timevar2's behaviour is not perfect on the clientside, it works differently on Windows/Mac/Linux (on Windows, it returns how many seconds the client has been open, whereas on Mac and Linux it returns the seconds since the UNIX epoch based on the system clock/timezone). On the serverside though it will work well, and should provide good relative calculations. Plain ol' timevar, on the other hand, should be the same on both clientside and serverside (it is synchronised by the client automatically), but the fact that it increases by 1 every 5 seconds makes it a much less accurate measure of time.
I understand what you say, I just dont understand how to use it in a script? Can you give me a mini example?
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote