• Hello
Search Results for

    Show / Hide Table of Contents

    Protected Primitives

    Score, health, and position live in memory. A cheat tool can search for those numbers and change them. A protected type hides the real value and notices when someone tampers with it.

    Protected primitives are part of the Free and the Pro version.

    Walkthrough: Memory protection.

    How to use

    Replace the normal type with the protected type. Reading, writing, and math stay the same.

    Before:

    private int coins = 0;
    

    After:

    using GUPS.AntiCheat.Protected;
    
    private ProtectedInt32 coins = 0;
    
    coins += 10;          // math works as before
    int value = coins;    // reading works as before
    

    All protected types

    The types are in the namespace GUPS.AntiCheat.Protected.

    Normal type Protected type
    bool ProtectedBool
    short, int, long ProtectedInt16, ProtectedInt32, ProtectedInt64
    ushort, uint, ulong ProtectedUInt16, ProtectedUInt32, ProtectedUInt64
    float, double, decimal ProtectedFloat, ProtectedDouble, ProtectedDecimal
    string ProtectedString
    DateTime ProtectedDateTime
    Vector2, Vector3, Vector4 ProtectedVector2, ProtectedVector3, ProtectedVector4
    Vector2Int, Vector3Int ProtectedVector2Int, ProtectedVector3Int
    Quaternion ProtectedQuaternion

    A few examples:

    ProtectedInt32 score = 5678;
    ProtectedFloat speed = 1234.123f;
    ProtectedBool isAlive = true;
    ProtectedString playerName = "My Protected Text";
    ProtectedVector3 position = new Vector3(1, 2, 3);
    ProtectedQuaternion rotation = new Quaternion(1, 2, 3, 4);
    ProtectedDateTime lastLogin = System.DateTime.Now;
    

    How a change is noticed

    A protected type keeps a fake value in place of the real one. This fake value is a trap, also called a honeypot. A cheat tool that searches for the number on screen finds the trap. When the trap is changed, the protected type tells the PrimitiveCheatingDetector.

    Do you need to add the detector?

    Most of the time, no. The predefined Anti-Cheat-Monitor prefab already includes the Primitive Cheating Detector.

    If you use your own monitor prefab, drag the Primitive Cheating Detector prefab onto the monitor in your prefab so it becomes a child.

    The detector prefabs in Assets/GUPS/AntiCheat/Resources/Prefabs/Detectors.

    Settings: Memory tampering detector.

    Good to know

    • You can use protected types as fields on a MonoBehaviour and set them in the Inspector.
    • A protected type is a little slower than a plain one. Protect the values that matter, not every counter.
    • Without the detector, the value is still hidden, but a change is not reported.
    • To save these values as JSON, see the FAQ.

    React to a change

    Ask the detector in code:

    var detector = AntiCheatMonitor.Instance.GetDetector<PrimitiveCheatingDetector>();
    
    if (detector != null && detector.PossibleCheatingDetected)
    {
        // A protected value was changed at least once.
    }
    

    More ways to react: Reacting to cheating.


    Back to the Protected overview.

    In This Article
    Back to top GuardingPearSoftware documentation