Protected Device Time (Pro)
Using the current date and time is essential for many applications. However, relying on the clock of the user's device creates trust issues as users can manipulate it for various purposes, such as extending trial periods or gaining advantages in games.
How to use
AntiCheat supports a protected Coordinated Universal Time (UTC) DateTime, which calculates the current DateTime based on a reference value. This can either be the local time of the computer or a time from the Internet.
// Instead of using DateTime.UtcNow, use the UtcNow from GUPS.AntiCheat.Protected.Time.ProtectedTime.
public static class ProtectedTime
{
// The protected Coordinated Universal Time (UTC) DateTime (Read Only). The calculated utc time, which may differs from the original DateTime.UtcNow
// because it is calculated to be secure and trustable as possible.
public static DateTime UtcNow { get; }
}
To counteract such manipulation, the AntiCheats Game Time Monitor and Detector are invaluable. They warn you if an attempt is made to change the date and time and ensures that users cannot exploit such changes to gain undeserved advantages.
Drag and drop the prefab to the anti cheat monitor in your scene.
Custom Observer
If you would like to write a custom listener to the detector, you can attach an observer:
// Get the detector from the anti cheat monitor.
var detector = AntiCheatMonitor.Instance
.GetDetector<DeviceTimeCheatingDetector>();
// Subscribe as observer and get notified on cheating.
detector.Subscribe(myObserver);