Time drifting out of sync over time
#1

Basically using IRL time, but using variables in my script to set it to make it easier to work with, and to be able to override it/not have to call gettime every second.

Using a 1 second task/timer using y_timers:
Код:
	
        wsecond++;
	if(wsecond == 59)
	{
		if(wminute == 59)
		{
			if(whour == 23)
			{
				wminute = 0;
				whour = 0;
			}
			else 
			{
				wminute = 0;
				whour++;
			}
			SetWorldTime(whour);
			if(!timeoverride) TimeSync(); //syncs time that may get out of sync over time 
		}
		else wminute++;
		wsecond = 0;
	}
Snippit of some debug logs, about 5 minutes after I started the server. Gradually gets more out of sync over the course of time.
Код:
[01/07/2015 01:23:05] Time out of sync! Server time: 01:23:03 | gettime: 01:23:05
[01/07/2015 01:23:06] Time out of sync! Server time: 01:23:04 | gettime: 01:23:06
[01/07/2015 01:23:07] Time out of sync! Server time: 01:23:05 | gettime: 01:23:07
[01/07/2015 01:23:08] Time out of sync! Server time: 01:23:06 | gettime: 01:23:08
[01/07/2015 01:23:09] Time out of sync! Server time: 01:23:07 | gettime: 01:23:09
[01/07/2015 01:23:10] Time out of sync! Server time: 01:23:08 | gettime: 01:23:10
[01/07/2015 01:23:11] Time out of sync! Server time: 01:23:09 | gettime: 01:23:11
[01/07/2015 01:23:12] Time out of sync! Server time: 01:23:10 | gettime: 01:23:12
[01/07/2015 01:23:13] Time out of sync! Server time: 01:23:11 | gettime: 01:23:13
[01/07/2015 01:23:14] Time out of sync! Server time: 01:23:12 | gettime: 01:23:14
[01/07/2015 01:23:15] Time out of sync! Server time: 01:23:13 | gettime: 01:23:15
[01/07/2015 01:23:16] Time out of sync! Server time: 01:23:14 | gettime: 01:23:16
[01/07/2015 01:23:17] Time out of sync! Server time: 01:23:15 | gettime: 01:23:17
[01/07/2015 01:23:18] Time out of sync! Server time: 01:23:16 | gettime: 01:23:18
[01/07/2015 01:23:19] Time out of sync! Server time: 01:23:17 | gettime: 01:23:19
[01/07/2015 01:23:20] Time out of sync! Server time: 01:23:18 | gettime: 01:23:20
[01/07/2015 01:23:21] Time out of sync! Server time: 01:23:19 | gettime: 01:23:21
[01/07/2015 01:23:22] Time out of sync! Server time: 01:23:20 | gettime: 01:23:22
[01/07/2015 01:23:23] Time out of sync! Server time: 01:23:21 | gettime: 01:23:23
[01/07/2015 01:23:24] Time out of sync! Server time: 01:23:22 | gettime: 01:23:24
[01/07/2015 01:23:25] Time out of sync! Server time: 01:23:23 | gettime: 01:23:25
[01/07/2015 01:23:26] Time out of sync! Server time: 01:23:24 | gettime: 01:23:26
[01/07/2015 01:23:27] Time out of sync! Server time: 01:23:25 | gettime: 01:23:27
[01/07/2015 01:23:28] Time out of sync! Server time: 01:23:26 | gettime: 01:23:28
[01/07/2015 01:23:29] Time out of sync! Server time: 01:23:27 | gettime: 01:23:29
[01/07/2015 01:23:30] Time out of sync! Server time: 01:23:28 | gettime: 01:23:30
[01/07/2015 01:23:31] Time out of sync! Server time: 01:23:29 | gettime: 01:23:31
[01/07/2015 01:23:33] Time out of sync! Server time: 01:23:30 | gettime: 01:23:33
[01/07/2015 01:23:34] Time out of sync! Server time: 01:23:31 | gettime: 01:23:34
[01/07/2015 01:23:35] Time out of sync! Server time: 01:23:32 | gettime: 01:23:35
[01/07/2015 01:23:36] Time out of sync! Server time: 01:23:33 | gettime: 01:23:36
[01/07/2015 01:23:37] Time out of sync! Server time: 01:23:34 | gettime: 01:23:37
[01/07/2015 01:23:38] Time out of sync! Server time: 01:23:35 | gettime: 01:23:38
[01/07/2015 01:23:39] Time out of sync! Server time: 01:23:36 | gettime: 01:23:39
[01/07/2015 01:23:40] Time out of sync! Server time: 01:23:37 | gettime: 01:23:40
[01/07/2015 01:23:41] Time out of sync! Server time: 01:23:38 | gettime: 01:23:41
[01/07/2015 01:23:42] Time out of sync! Server time: 01:23:39 | gettime: 01:23:42
[01/07/2015 01:23:43] Time out of sync! Server time: 01:23:40 | gettime: 01:23:43
[01/07/2015 01:23:44] Time out of sync! Server time: 01:23:41 | gettime: 01:23:44
[01/07/2015 01:23:45] Time out of sync! Server time: 01:23:42 | gettime: 01:23:45
[01/07/2015 01:23:46] Time out of sync! Server time: 01:23:43 | gettime: 01:23:46
[01/07/2015 01:23:47] Time out of sync! Server time: 01:23:44 | gettime: 01:23:47
[01/07/2015 01:23:48] Time out of sync! Server time: 01:23:45 | gettime: 01:23:48
[01/07/2015 01:23:49] Time out of sync! Server time: 01:23:46 | gettime: 01:23:49
[01/07/2015 01:23:50] Time out of sync! Server time: 01:23:47 | gettime: 01:23:50
[01/07/2015 01:23:51] Time out of sync! Server time: 01:23:48 | gettime: 01:23:51
[01/07/2015 01:23:52] Time out of sync! Server time: 01:23:49 | gettime: 01:23:52
[01/07/2015 01:23:53] Time out of sync! Server time: 01:23:50 | gettime: 01:23:53
[01/07/2015 01:23:54] Time out of sync! Server time: 01:23:51 | gettime: 01:23:54
[01/07/2015 01:23:55] Time out of sync! Server time: 01:23:52 | gettime: 01:23:55
[01/07/2015 01:23:56] Time out of sync! Server time: 01:23:53 | gettime: 01:23:56
[01/07/2015 01:23:57] Time out of sync! Server time: 01:23:54 | gettime: 01:23:57
[01/07/2015 01:23:58] Time out of sync! Server time: 01:23:55 | gettime: 01:23:58
[01/07/2015 01:23:59] Time out of sync! Server time: 01:23:56 | gettime: 01:23:59
[01/07/2015 01:24:00] Time out of sync! Server time: 01:23:57 | gettime: 01:24:00
[01/07/2015 01:24:01] Time out of sync! Server time: 01:23:58 | gettime: 01:24:01
[01/07/2015 01:24:02] Time out of sync! Server time: 01:24:00 | gettime: 01:24:02
[01/07/2015 01:24:03] Time out of sync! Server time: 01:24:01 | gettime: 01:24:03
...later snippits...

[01/07/2015 01:39:42] Time out of sync! Server time: 01:39:36 | gettime: 01:39:42
[01/07/2015 01:39:43] Time out of sync! Server time: 01:39:37 | gettime: 01:39:43
[01/07/2015 01:39:44] Time out of sync! Server time: 01:39:38 | gettime: 01:39:44
[01/07/2015 01:39:45] Time out of sync! Server time: 01:39:39 | gettime: 01:39:45
[01/07/2015 01:39:46] Time out of sync! Server time: 01:39:40 | gettime: 01:39:46
[01/07/2015 01:39:47] Time out of sync! Server time: 01:39:41 | gettime: 01:39:47
[01/07/2015 01:39:48] Time out of sync! Server time: 01:39:42 | gettime: 01:39:48
[01/07/2015 01:39:49] Time out of sync! Server time: 01:39:43 | gettime: 01:39:49
[01/07/2015 01:39:50] Time out of sync! Server time: 01:39:44 | gettime: 01:39:50
[01/07/2015 01:39:51] Time out of sync! Server time: 01:39:45 | gettime: 01:39:51
[01/07/2015 01:39:52] Time out of sync! Server time: 01:39:46 | gettime: 01:39:52
[01/07/2015 01:39:53] Time out of sync! Server time: 01:39:47 | gettime: 01:39:53
[01/07/2015 01:39:54] Time out of sync! Server time: 01:39:48 | gettime: 01:39:54
I do understand that timers aren't perfect in SA-MP and that's more than likely the cause, just looking if anyone has any better ideas in terms of time, or anything related to how I'm incrementing it, etc. I'm guessing the consensus will be that to make it perfect, use gettime every second instead of incrementing via variables.
Reply
#2

Are you making a timer here? Timers are not accurate.
Just make a 1sec timer and use gettime, write hours and minutes into variables and use them
Reply
#3

Quote:
Originally Posted by zaibaslr2
Посмотреть сообщение
Are you making a timer here? Timers are not accurate.
Just make a 1sec timer and use gettime, write hours and minutes into variables and use them
Yes, I know timers aren't accurate, but they aren't this inaccurate. The fixes2 plugin addresses this, and there was a slight error in my code that I didn't notice(thanks to ev0lution and damo for pointing it out).

The massive desync was a combination of the fact that every second due to an incrementation error time was set off a second due to the fact that when time got to 59, it was instantly set back to 0 and then incremented. You'll see it if you look at the OP.

The issue I'm facing now is that after some time, fixes2 seems to go completely hayware into a infinite loop triggering all of my timers.
Reply
#4

Forementioned issues where timers go haywire was caused by fixes2, fix available here: https://github.com/Southclaw/fixes2/...2764b7ccb67e89

Recompiled the plugin and everything looks good.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)