![]() |
Anti-Cheat Toolkit
2024.3.5
Multi-purpose anti-cheat solution for Unity Engine
|
Inherits ACTkDetectorBase< TimeCheatingDetector >.
Classes | |
struct | OnlineTimeResult |
Public Types | |
enum class | CheckResult { Unknown = 0 , CheckPassed = 5 , WrongTimeDetected = 10 , CheatDetected = 15 , Error = 100 } |
enum class | ErrorKind { NoError = 0 , IncorrectUri = 3 , OnlineTimeError = 5 , NotStarted = 10 , AlreadyCheckingForCheat = 15 , Unknown = 100 } |
enum class | RequestMethod { Head , Get } |
Public Member Functions | |
delegate void | OnlineTimeCallback (OnlineTimeResult result) |
delegate void | TimeCheatingDetectorEventHandler (CheckResult result, ErrorKind error) |
void | TriggerDetection () |
bool | ForceCheck () |
IEnumerator | ForceCheckEnumerator () |
async Task< CheckResult > | ForceCheckTask () |
bool | IsReadyForForceCheck () |
Public Attributes | |
RequestMethod | requestMethod = RequestMethod.Head |
int | timeoutSeconds = 10 |
float | interval = 5 |
int | realCheatThreshold = 65 |
int | wrongTimeThreshold = 65 |
bool | ignoreSetCorrectTime = true |
bool | autoStart |
bool | autoDispose |
Properties | |
string | RequestUrl [get, set] |
ErrorKind | LastError [get] |
CheckResult | LastResult [get] |
OnlineTimeResult | LastOnlineTimeResult [get] |
bool | IsCheckingForCheat [get] |
bool | IsCheatDetected [get, protected set] |
bool | IsStarted [get, protected set] |
bool | IsRunning [get, protected set] |
Events | |
TimeCheatingDetectorEventHandler | CheatChecked |
Action | CheatDetected |
Allows to detect time cheating using time from any properly configured server (almost all servers around the web).
Requires Internet connection and appropriate 'android.permission.INTERNET' permission when used on Android platform.
Automatically switches to the current domain on WebGL (if RequestUrl leads to any external resource) to avoid CORS limitation.
Make sure your server returns correct Date response header value in case of problems.
Doesn't detects cheating if there is no Internet connection, should work even with weak connection though.
Just add it to any GameObject as usual or through the "GameObject > Create Other > Code Stage > Anti-Cheat Toolkit" menu to get started.
You can use detector completely from inspector without writing any code except the actual reaction on cheating.
Avoid using detectors from code at the Awake phase.
|
strong |
Describes possible detector check results.
Enumerator | |
---|---|
Unknown | Cheat detection was not started yet or is in progress. |
CheckPassed | Cheat check successfully passed and nor cheating nor wrong time was detected. |
WrongTimeDetected | Direct time cheating was not detected but difference between local and online UTC clocks exceeds the wrongTimeThreshold. |
CheatDetected | Subsequent measurements difference of local and online time difference exceeded the realCheatThreshold. |
Error | There was error while making cheat check, please check LastError for details. |
|
strong |
Describes possible detector errors.
Enumerator | |
---|---|
NoError | Indicates there were no any error registered. |
IncorrectUri | Url set for the online time receiving is not a correct URI. |
OnlineTimeError | Error while receiving online time (check logs for error details). |
NotStarted | Detector was not started yet. It should be started before performing any cheat checks. |
AlreadyCheckingForCheat | Detector already checks for the cheat. Please make sure IsCheckingForCheat == false before trying to force another cheat check. |
Unknown | Something strange happened, please check logs for details. |
|
strong |
Method of the request to the server. Please consider Head by default and fall back to Get in case of problems.
Some servers do not like HEAD requests and sometimes treat it as a malicious bot activity and may temporary block the caller.
For such servers use GET method as a more compatible yet slower and loading all page data.
Enumerator | |
---|---|
Head | Preferable method as it requests only headers thus it runs faster and has minimal possible traffic. |
Get | More compatible method which loads whole content at the given URL. |
delegate void OnlineTimeCallback | ( | OnlineTimeResult | result | ) |
Delegate with result of online time receive attempt.
result | OnlineTimeResult instance with details about operation result. |
delegate void TimeCheatingDetectorEventHandler | ( | CheckResult | result, |
ErrorKind | error | ||
) |
Delegate with cheat check result.
result | Result of the cheat check. |
error | Kind of occured error, if any. |
|
inlinestatic |
Creates new instance of the detector at scene if it doesn't exists. Make sure to call NOT from Awake phase.
|
inlinestatic |
Starts detection with specified callback.
If you have detector in scene make sure it has empty Detection Event.
Creates a new detector instance if it doesn't exists in scene.
cheatCheckedEventHandler | Method to call after each cheat check. Pass null if you wish to use event, set in detector inspector. |
|
inlinestatic |
Starts detection with specified callback using passed interval.
If you pass cheatCheckedCallback than make sure you have no filled Detection Event on detector instance in scene to avoid duplicate event calls.
Creates a new detector instance if it doesn't exists in scene.
|
inlinestatic |
- Stops detector. Detector's component remains in the scene. Use Dispose() to completely remove detector.
|
inlinestatic |
Stops and completely disposes detector component.
On dispose Detector follows 2 rules:
|
inlinestatic |
Receives UTC seconds from url. Runs asynchronously in coroutine.
Automatically switches to the current domain when running in WebGL to avoid CORS limitation.
url | Absolute url to receive time from. Make sure this server has proper Date values in the response headers (almost all popular web sites are suitable). |
callback | Delegate to call and pass OnlineTimeResult to. |
method | Method to use for url request. Use Head method if possible and fall back to get if server does not reply or block head requests. |
|
inlinestatic |
Receives UTC seconds from url. Runs asynchronously in coroutine.
Automatically switches to the current domain when running in WebGL to avoid CORS limitation.
uri | Absolute url to receive time from. Make sure this server has proper Date values in the response headers (almost all popular web sites are suitable). |
callback | Delegate to call and pass OnlineTimeResult to. |
method | Method to use for url request. Use Head method if possible and fall back to get if server does not reply or block head requests. |
|
inlinestatic |
Receives UTC seconds from url. Runs asynchronously.
Automatically switches to the current domain when running in WebGL to avoid CORS limitation.
url | Absolute url to receive time from. Make sure this server has proper Date values in the response headers (almost all popular web sites are suitable). |
method | Method to use for url request. Use Head method if possible and fall back to get if server does not reply or block head requests. |
|
inlinestatic |
Receives UTC seconds from url. Runs asynchronously.
Automatically switches to the current domain when running in WebGL to avoid CORS limitation.
url | Absolute url to receive time from. Make sure this server has proper Date values in the response headers (almost all popular web sites are suitable). |
cancellationToken | CancellationToken to cancel the operation. |
method | Method to use for url request. Use Head method if possible and fall back to get if server does not reply or block head requests. |
|
inlinestatic |
Receives UTC seconds from url. Runs asynchronously.
Automatically switches to the current domain when running in WebGL to avoid CORS limitation.
uri | Absolute url to receive time from. Make sure this server has proper Date values in the response headers (almost all popular web sites are suitable). |
method | Method to use for url request. Use Head method if possible and fall back to get if server does not reply or block head requests. |
|
inlinestatic |
Receives UTC seconds from url. Runs asynchronously.
Automatically switches to the current domain when running in WebGL to avoid CORS limitation.
uri | Absolute url to receive time from. Make sure this server has proper Date values in the response headers (almost all popular web sites are suitable). |
cancellationToken | CancellationToken to cancel the operation. |
method | Method to use for url request. Use Head method if possible and fall back to get if server does not reply or block head requests. |
|
inline |
Manually triggers cheating detection and invokes assigned events.
|
inline |
Allows to manually execute cheating check. Restarts interval.
Listen for detector events to know about check result.
|
inline |
Allows to manually execute cheating check and wait for the completion within coroutine. Restarts interval.
Use inside of the coroutine and check LastResult property after yielding this method. Detector events will be invoked too. Example:
|
inline |
Allows to manually execute cheating check and wait for the completion within async method. Restarts interval.
Await this method in async method to wait for the check completion and to get the check result. Detector events will be invoked too. Disabled for WebGL platform.
|
inline |
Call this to make sure detector is ready for the ForceCheck() call.
RequestMethod requestMethod = RequestMethod.Head |
Method to use for url request. Use Head method if possible and fall back to get if server does not reply or block head requests.
int timeoutSeconds = 10 |
Online time request timeout in seconds. Request will be automatically aborted if server will not response in specified time.
float interval = 5 |
Time (in minutes) between detector checks. Set to 0 to disable automatic time checks and use ForceCheck(), ForceCheckEnumerator() or ForceCheckTask() to manually run a check.
int realCheatThreshold = 65 |
Maximum allowed difference between subsequent measurements, in minutes.
int wrongTimeThreshold = 65 |
Maximum allowed difference between local and online time, in minutes.
If online and local time difference exceed this threshold, detector will raise an event with
bool ignoreSetCorrectTime = true |
Ignore case when time changes to be in sync with online correct time.
Wrong time threshold is taken into account.
|
inherited |
Allows to start detector automatically. Otherwise, you'll need to call StartDetection() method to start it.
Useful in conjunction with proper Detection Event configuration in the inspector. Allows to use detector without writing any code except the actual reaction on cheating.
|
inherited |
Detector component will be automatically disposed after firing callback if enabled. Otherwise, it will just stop internal processes.
On dispose Detector follows 2 rules:
|
getset |
Absolute URL which will return correct Date in response header to the HEAD request (nearly any popular web server out there including google.com, microsoft.com etc.).
|
get |
Last detector error kind. Will be ErrorKind.NoError if there were no errors.
|
get |
Last check result. Check LastError if this has value of CheckResult.Error.
|
get |
Complete response data for the last time request.
|
get |
Allows to check if cheating check is currently in process.
|
getprotected setinherited |
Indicates if cheat was detected by this detector.
|
getprotected setinherited |
Allows to check if detector is started (stays true even when it's paused).
|
getprotected setinherited |
Allows to check if detection is currently running and not paused.
TimeCheatingDetectorEventHandler CheatChecked |
Gets called after each cheat check and provides results of the check.
|
inherited |
Subscribe to this event to get notified when cheat will be detected.