Protected Collection (Pro)
Important data is not only a single number. It can also be a list, a queue, or a stack. A cheat tool can change the items inside. Anti-Cheat has protected versions of those three. You can ask each one if it was changed.
Protected collections need the Pro version.
The three collections
The types are in the namespace GUPS.AntiCheat.Protected.Collection.
| Normal type | Protected type | Good for |
|---|---|---|
List<T> |
ProtectedList<T> |
An inventory, high scores, quest goals |
Queue<T> |
ProtectedQueue<T> |
Player actions or events that are handled in order, first in, first out |
Stack<T> |
ProtectedStack<T> |
Undo steps, a movement history, buffs that are removed last in, first out |
They work like the normal types. You add, read, and remove items the same way.
How to use
Replace the normal collection with the protected one. Then call CheckIntegrity before you rely on the data. It returns false when the content was changed from outside.
A list:
using GUPS.AntiCheat.Protected.Collection;
ProtectedList<int> scores = new ProtectedList<int>();
scores.Add(1);
scores.Add(2);
scores.Add(3);
if (scores.CheckIntegrity())
{
// The list is fine. Use it, or send it to your server.
}
else
{
// The list was changed, most likely by a memory tool.
}
A queue:
ProtectedQueue<int> actions = new ProtectedQueue<int>();
actions.Enqueue(1);
actions.Enqueue(2);
if (!actions.CheckIntegrity())
{
// The queue was changed.
}
A stack:
ProtectedStack<int> history = new ProtectedStack<int>();
history.Push(1);
history.Push(2);
if (!history.CheckIntegrity())
{
// The stack was changed.
}
Good to know
Important
A protected collection does not tell a detector on its own. Nothing is reported until you call CheckIntegrity and react to the result yourself.
- When to check. Check before the data matters, for example before you grant a reward or send a score. Checking on every access can be slow.
- Value types only. The items must be value types (structs), such as
int,float, orVector3. Classes are not allowed. A class could be changed from outside the collection, and the check could not tell that apart from a cheat. - A chain that checks itself. If you want every change to be checked and reported for you, use a data chain.
Back to the Protected overview.