![]() |
Clientsided Time Calculation
Hi,
uhm so i had a discussion with that weird coreys guy right now...(he's really weird lol) now i told him how i calculate the time, using the clients, not calculating it on the serv i was like i use this.timevar5, thats the timevar2 of the serv, he sends it to the players the clients then do the time calculating no he was like "WTF THATS NO GLOBALTIME!" and im like "uhm why not?" hes like "cause its clientside, it will be different at different times for different people" and im like "why would it be different? they all use the same formula" and hes like again "CAUSE IT'S FKIN CLIENTSIDE" uhm... well so can anyone tell me what he meant(he quit, after calling me an idiot & telling me to stop scripting) :) |
Hmm, I'm not really sure, timevar I believe has different values depending if it's clientside or serverside, but timevar2 is the time since some 1970 date or something :o so it's independent of anything clientside. I'll test it out though.
|
Way to include the very last part of the conversation when I had gotten frustrated with your lack of intelligence.
|
Anyways, here's the results. I was wrong:
Serverside Timevar: 40974023 Serverside Timevar2: 1185918933.553539991 Clientside Timevar: 40974023 Clientside Timevar2: 437.106929791 It looks like this means if you use timevar2 on the clientside for a time system, people will get different times. |
HolySheepy, you were suggesting doing this sort of thing clientside...
PHP Code:
And even still, timevar2 isn't the same clientside as it is serverside. Edit: btw, Stan called you an idiot, not me. Also, why are you using timevar2 for a clock for a server that isn't using realtime? |
Ya, that won't work.
You could do something similar in a database NPC, and access findNPC("timeNPC").this.tvar or such... but ya, timevar/timevar2 is the simplest way to do it. Making your own variables is unneeded really. Hell, you could even go as far as grabbing Timevar2 from the serverside on the onCreated, and then manually add time onto it clientside, and sync it every minute or so, to keep traffic to the serverside, then back to the clientside, down. EDIT: Just noticed your edit, timevar2 is useful because it's updated by the nanoseconds, compared to timevar which is just updated 1 every 5 seconds. |
timevar2 is useful if you want to check the time between two things (like a double tap of a key) and for realtime, but not for a world clock that goes through a day in 6 hours.
|
It's good if you want to show time that doesn't update every 5 seconds. I personally like my time systems to be a little faster than that. I like to make my system where 1 second = 1 minute in the game.
|
How is timevar defined?
Also timevar2 clientside is your system time, on serverside it is the server's time. |
Quote:
|
Hmm, would you be able to take the serverside timevar2, and compare it to the clientside timevar2, to have a timevar that is the same for all players, without having to constantly access it from serverside?
|
well as i said earlier in the conversation i use this.timevar5 to calc, it the server sends his timevar2 to the players, they set it to this.timevar5, resend from the serv like ever 5 minutes, even with my kinda slow pc that would be only 1-2 minutes difference in est time :P
well im planning to use the timevar2 from the serv as a starting point for the players timevar2 instead of using this.timevar5 still its about the same time for everyone, and now dont tell me every clock in reallife shows the exactly same time.. so basically every client uses the same formula with the same variable for calculation, thats like saying if you have 30 calculators and input 4+5 in everyone some wont return 9 |
How about we just demand timevar3? Graal 3d gets it: why not add it for us?
For those who don't know, timevar3 is synchronized between server and client. |
well, you can demand, i dont think you will get it :(
|
He's Twinny. He get what he wants.
Or else. |
Quote:
|
Well that's just stupid. :)
|
On Windows, timevar2 is the number of seconds since the client was opened.
On Linux/Mac, it is the number of seconds since 1st January 1970 (see UNIX time). On the serverside, timevar2 is representing the time in France I guess, while on the clientside on Linux/Mac, it is representing the local timezone. If it is important that your time is the same for every user, then run your calculations serverside, since Linux/Mac users will get time relevant to their timezone, and Windows users will get something altogether completely different. |
:)
This will let you have the accuracy of timevar2, while keeping your time the same as everyone elses(though I haven't tested it with others to compare the time). PHP Code:
|
Geez, just have a serversided DB calculate the time every second and set it as serverr variable(s) then have the clientsided system read those x_x
|
serverside variables are the bane!!!!
|
Quote:
|
Nothing, I just try to avoid server.variables as I've always been told they can 'cause a bit of lag or some such when they pile up.
Either way I don't see the need of constantly transferring serverside timevar2 when you can just sync it with the clientside timevar2 |
Quote:
|
im avoiding servside timeouts because i was told they lag xP
|
Quote:
And Dusty, why bother doing that if you can just do everything serverside in a DB NPC or a weapon. PHP Code:
Anyways... |
Because then there's no need to transfer data between the client and server. The way I did it, the only time information is sent is once, from then on it uses comparison to retrieve the same time as everyone else, all on the clientside.
It's just more convenient to have something like the time on the clientside for fast and smooth access, since most things related to time(seteffect, lights) are on the clientside. |
Serverside timeouts are 0.1 seconds minimum.
|
Quote:
|
Quote:
Quote:
Quote:
|
Eh, either way I'd rather keep it all on the clientside and avoid serverr's, but I guess to each their own.
|
Quote:
I read on the wiki that a serverside timeout shouldn't need to go faster than 0.5 but it's always been common knowledge to me that the limit is 0.1 =P |
| All times are GMT +2. The time now is 11:54 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.