Configuration/rules.yml

The rules.yml file defines scriptable events that allows you to specify your own Rules that the system will use. You can define what sorts of things AntiCheat should do and under what circumstances they should do them. Rules are for the more advanced user and, ideally, someone who has a general idea of how expressions work in programming. Rules are evaluated every time a player fails a check.

The only currently available rule parsing system is called the ConditionalRule. Its notation is

BOOLEAN ? ACTION IF TRUE : ACTION IF FALSE

In English, that means the first part is an expression that will either be evaluated to TRUE or FALSE, the expression followed by the ? will occur if the statement evaluates to true, while the following expression will occur if the statement is false.

For example,

Check_SPIDER > 0 ? Player.KICK : null

evaluates to 'If the player has used the SPIDER check more than 0 (more than once), kick them. Otherwise, do nothing.'

Variables

You might notice that we're using statements like 'Check_SPIDER' to evaluate the level of a check, and 'Player.KICK' to kick a player. The former example is known as a 'variable' and is a string pre-defined by AntiCheat to have a value of the checks' name. When you enter 'Check_SPIDER', the system evaluates that and turns it into '3', for example, if the player has used spider 3 times. The statement then becomes '3 > 0' which is true, meaning the Player.KICK expression is called. Variables are defined by the variable type, in this case 'Check' because we want to access a check value, followed by an underscore, '_', followed by the variable name, in this case 'SPIDER'.

Valid variables:

  • Check: Contains all valid checks as listed in CheckType, and will return the number of times this user has failed the given check.
  • Player: Contains LEVEL, the player's current level and CHECK, the check that was just failed.

Functions

The true and false expressions are called 'functions'. They are noted with the function type, in this case 'Player' because we want to access a player function, followed by a period '.', followed by the name of the function, in this case 'KICK' because we want to the player to be kicked. Functions are ways to access the internals of the system and execute your very own actions.

Valid functions:

You may also set specific variables in an expression. For instance,

Check_SPIDER > 0 : Player_LEVEL = 20 : null

Is a valid rule. What the above code will do is make the player's level 20 when they use spider more than once. As of now, Player_LEVEL is the only settable variable, but this may change in the future.

Comparisons & Logical Operators

If you're not a programmer, you may be unfamiliar with comparison operators. A symbol like '>' is an comparison operator that you are probably familiar with from any math class; it means greater than, and it's counterpart '<' means less than. In Computer Science there are many comparisons you can use to check equality or evaluate a value.

OperatorMeaning
==
Is equal to
!=
Is not equal to
>
Is greater than
<
Is less than
>=
Is greater than or equal to
<=
Is less than or equal to

In addition, there are also conditional operators you can use to further expand your rules. As opposed to simply evaluating one thing, it's possible to take multiple values into account to pick the correct action. The conditional operators are:

OperatorMeaning
&& (two ampersands)and
II (two pipes, the key above enter)or

Let's combine all this knowledge together for some example statements.

Examples

Player_LEVEL == 20 ? Player.KICK : null

Meaning: If the player's level is 20, kick them. Otherwise, do nothing.


Player_LEVEL == 20 && Check_SPIDER != 4 ? Player_LEVEL = 3 : Player.RESET

Meaning: If the player's level is 20 AND the spider check's level isnt' 4, set their level to 3. Otherwise, reset their level.


Player_LEVEL == 20 || Player_LEVEL == 21 ? Player.COMMAND[pardon &player] : Player.COMMAND[ban &player]

Meaning: If the player's level is 20 OR the player's level is 21, execute the command 'pardon &player'. Otherwise, execute the command 'ban &player'.


You may also NEST conditional statements to have more outcomes.

Player_LEVEL == 20 ? Check_SPIDER == 0 ? Player.WARN : Player.KICK : null

Meaning: If the player's level is 20, check if their spider level is 0. If it is, warn them, if it is not, kick them. If the player's level is not 20, do nothing.


The conditional statements implements a version of JavaScript to parse user input, so if you're a JS junkie who knows what they're doing, feel free to employ tactics that I haven't discussed in this document.

You can view full documentation on the Rule system here: http://gravitydevelopment.net/docs/anticheat/net/gravitydevelopment/anticheat/util/rule/package-summary.html

If you need more assistance with Rules, want to share your configurations, get feedback from others, or look at more examples, feel free to check out the Rules section of our forums