How to use NTP in Godot

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By salihkallai

I want sync time with NTP server to prevent game time cheating. I succesfully implemented this in LIbgdx (Java) using Apache Commons library. But How to implement this in Godot. Please note that the question is only for NTP , I dont want http third party time sync services.

You may be able to get local time via the OS class.

Ertain | 2019-05-25 14:55

I found an alternate solution by using Date from header in Http request. But I dont know how accurate it

salihkallai | 2019-05-25 16:26

If I were to compare times from within the engine (using Godot-based server and client), I would check the local time. But getting it from the HTTP header may be more secure.

Ertain | 2019-05-25 20:49

:bust_in_silhouette: Reply From: andersmmg

Really even using NTP is just as easy to cheat with. It’s surprisingly simple to spoof the NTP response using software. The way I’ve found to help with this is to detect when time goes backwards. If the game ever notices time going backwards at all it could penalty the player in some way. This way if they change the time to go forward, it will have to stay that way and they’ll need to be extra careful not to let it update or anything because they’ll get penalized for it.