GameMaker (2.0 - 2.2.x)
Icon

GMTime

Meseta

You must be logged in to obtain assets

Description

GMTime is an internet time (NTP) client for GM. This allows your GM game to fetch the real time from the internet's network of atomic clocks, allowing your game to have a more accurate record of time than the user's system clock. This can be useful for things like unlock events, or helping combat time-editing cheating.

To use:

  1. Drop the ntp_handler object into a room in your game. This object will attempt to contact NTP servers to fetch the time
  2. Allow the object a few seconds to fetch the time, as it may take a second to a few seconds to fetch the time from the internet.
  3. If and when the object gets a response, it will set the global.timestamp_offset variable with the offset between internet time, and the system clock. The variable will be undefined if the object has not gotten a time yet.

Example:

if (not is_undefined(global.timestamp_offset)) {
    real_time = date_current_datetime() + global.timestamp_offset;
}

Notes:

  • If the player's computer does not have an internet connection, or NTP is blocked, then the object will never be able to fetch the offset
  • A knowledgeable person can quite easily spoof the returned time, so this is not totally immune to hacking/cheating
  • Be aware of what happens to timezones. the global.timestamp_offset can be added to date_current_datetime() to correct the datetime value for the timezone that it is set to. To get UTC time, set gamemaker's timezone to UTC time before doing the above calculation

End User Licence Agreement (EULA).

Age Rating: 4+

Version

GMS2 - Version 1.0.1. Published June 8, 2020

Loading, please wait

Package contents

Loading, please wait

What is the issue?

Loading, please wait