GetServerTime()

Type
Function

Description

This function requests the epoch time on your server

Where do I get the server time?

After a successful time check on your server the callback function callback_GotServerTime() is called. So under Scripts/Rocket Networking/Callback Functions , you can edit this to do whatever you want…

Example Implementation of callback - Countdown Timer

image

If your game needs a timer by the minute and it needs to go from 59 to 0, you can use this code to get the seconds out of 60, and this will be the same on all clients because it is derived from the server.

📌
You do not need to keep calling this function very frequently. You can sync up the client time once with the server like this. time_difference = server_time - current_time ; And later at any time… correct_time = current_time + time_difference ;