Rule Engine

The rule engine lets you add your own checks on top of the built-in detections, without writing code. A rule says: when this happens, and this is true, do this. For example, block a vehicle model nobody should spawn, or turn away Discord accounts that are only a few days old.

The Example Rules Ship Turned Off

CXA comes with two example rules, block_adder and new_discord_accounts. Both are disabled. Open them, read how they are built, then change them or turn them on.

How It Works

A rule has four parts:

PartPanel nameConfig keyWhat it is
EventWhenEventThe game event that starts the check, for example a vehicle being spawned.
ConditionConditionConditionA short test, for example model == 'adder'.
ActionsThenActionsWhat happens when the condition is true, for example block and log.
ReasonReason shown in logsReasonThe text in logs, kick screens and ban records.
  • When the anticheat starts, CXA reads every enabled rule and translates its condition once. A condition it cannot read is skipped, with a warning in the console.
  • CXA only listens to an event when at least one enabled rule uses it. Events nobody uses cost nothing.
  • Each time the event happens, CXA checks every enabled rule for that event. Every rule that matches carries out its actions.
  • Staff who bypass the anticheat are never matched. For the playerConnecting event, only the Bypass Identifiers list counts. See Staff Bypass.
  • Rules run on top of the built-in detections. They never switch a detection off.

Setting It Up

Step 1 — Open the Rules

Open Configuration → Network & rules → Security rules in the web panel. Each rule is a row you can expand, with an on/off switch on the right.

Step 2 — Add a Rule

Type a name in the field that says "New rule name, e.g. block_tanks" and click Add rule. The name is turned into lowercase, and characters other than a-z, 0-9 and _ become _. It can be up to 32 characters long.

A new rule starts switched off, on the Entity spawned event, with the condition model == 'adder' and the actions Block and Log, so you have an example to edit.

Step 3 — Pick the Event and Write the Condition

Choose the event under When. Then write the condition under Condition. The line below the field lists the fields you can use, for example Fields: model, type, script. If the panel cannot read the condition, the line turns red and explains why, and the rule shows an Error badge.

Step 4 — Choose the Actions and the Reason

Under Then, click one or more of Block, Log, Warn, Kick and Ban. Write a short Reason shown in logs, up to 120 characters. Without a reason, the rule name is used.

Step 5 — Turn It On and Save

Switch the rule on and click Save changes. Your server picks it up within a minute and reloads the anticheat.

Rules in config.lua

In config.lua, and in code you paste into Import code, rules live in Config.Rules. Each rule is a table under its name:

Config.Rules = {
    block_lazer = {                              -- Rule name: a-z, 0-9 and _
        Enabled = true,                          -- false = rule is ignored
        Event = 'entityCreating',                -- When: one of the five events below
        Condition = "model == 'lazer' and script == true", -- Double quotes outside, single quotes inside
        Actions = { 'block', 'log' },            -- Then: block, log, warn, kick, ban
        Reason = 'Spawned a fighter jet',        -- Shown in logs
    },
}

Import code adds the rules you paste to the ones you already have; it does not delete others. With a license, the rules saved in the panel replace the ones in config.lua.

Events

EventPanel nameWhen it firesWhat block does
entityCreatingEntity spawnedA player's game creates a networked vehicle, ped or objectThe entity is not created.
explosionEventExplosionA player's game reports an explosionThe explosion is cancelled.
weaponDamageEventWeapon damageA player's game reports damage to another ped or playerThe damage is cancelled.
chatMessageChat messageA player sends a chat message through the standard chat resourceThe message is not sent.
playerConnectingPlayer connectingA player connects to the serverThe connection is refused.

Fields

FieldDescriptionAvailable in
modelThe entity's model. Write the name in quotes, for example 'adder'. CXA turns it into the game's hash.entityCreating
typeThe kind of entity: 1 = ped, 2 = vehicle, 3 = object.entityCreating
scripttrue when a script created the entity, false for traffic and other ambient population.entityCreating
typeThe explosion type number, the same numbers as in the explosion types list, for example 7 = Car, 37 = ProxMine.explosionEvent
damageScaleThe damage scale of the explosion.explosionEvent
invisibletrue when the explosion is invisible.explosionEvent
audibletrue when the explosion makes a sound.explosionEvent
weaponThe weapon. Write the name in quotes, for example 'WEAPON_PISTOL'. CXA turns it into the game's hash.weaponDamageEvent
damageThe damage of the hit, as a number.weaponDamageEvent
distanceMeters between the shooter and the entity that was hit. 0 when CXA cannot find the target.weaponDamageEvent
headshottrue when the hit landed on the head.weaponDamageEvent
messageThe full text of the chat message.chatMessage
nameThe player's FiveM name.playerConnecting
discordAgeAge of the player's Discord account in days, worked out from the Discord ID. Empty when the player has no Discord identifier.playerConnecting
hasDiscordtrue when the player has a Discord identifier.playerConnecting
hasSteamtrue when the player has a Steam identifier.playerConnecting
identifiersHow many identifiers the player connects with.playerConnecting

Field names are case-sensitive. Write discordAge, not discordage.

Condition Language

Comparisons

OperatorMeaningExample
==Equalmodel == 'adder'
~= or !=Not equaltype ~= 2
<Less thandiscordAge < 30
<=Less than or equaldamage <= 0
>Greater thandistance > 300
>=Greater than or equaldamageScale >= 2
containsThe text contains this partmessage contains 'discord.gg'
  • == and ~= compare numbers as numbers and everything else as text, ignoring case. name == 'ADMIN' also matches admin.
  • <, <=, > and >= only work with numbers. If one side is not a number, the comparison is false. A player without Discord has no discordAge, so discordAge < 30 is false for them.
  • contains looks for a piece of text and ignores case. Write it in lowercase, with a space on both sides.

Values

  • Text goes in single or double quotes: 'adder' or "adder". Text without quotes cannot be read.
  • Numbers are written as they are: 30, 1.5.
  • true and false are written without quotes.
  • For model and weapon, write the name. CXA turns it into the game's hash, so the case does not matter: 'WEAPON_PISTOL' and 'weapon_pistol' are the same. A number hash works too.
  • contains does not search inside model or weapon names, because CXA compares hashes, not names. Use == or ~= for those fields.
  • In config.lua the whole condition is a Lua string. Put double quotes around it and single quotes inside: Condition = "model == 'adder'". In the panel you only type the condition itself.

Combining With and / or

  • and means every part must be true. or means at least one part must be true.
  • and is checked before or. a or b and c means a or (b and c).
  • Parentheses are not supported. Write (a or b) and c as a and c or b and c.
  • and and or ignore case but need a space on both sides.
  • Quoted text cannot contain the words and or or between spaces, because CXA splits the condition at those words first.

Example: hasDiscord == false or discordAge < 7 matches players without Discord and players whose Discord account is younger than 7 days.

Actions

ActionPanel buttonOn in-game eventsOn playerConnecting
blockBlockCancels the event: the entity, explosion, damage or chat message never happens.Refuses the player with You cannot join this server: <reason>.
logLogLogs a Security rule detection: Detections channel, the panel's Detections tab, the console and an in-game staff alert.Writes Security rule matched to the Connections channel.
warnWarnShows the player an on-screen warning and logs to the Warns channel.No effect.
kickKickRemoves the player with your reason and logs to the Kicks channel.Refuses the player like block and logs to the Connections channel.
banBanBans the player permanently, removes them and logs to the Bans channel.Bans the player permanently, shows the ban screen and logs to the Connections channel.
  • A rule applies only one punishment, the strongest one you picked: ban, then kick, then warn, then log. block can be added to any of them.
  • On in-game events, a rule with only block cancels the event silently, without a log. Add log to see it.
  • Bans from rules are always permanent. The ban reason is your Reason.
  • warn shows Anticheat warning: Security rule. Keep doing it and you will be removed from the server.
  • With the default Shared detections list, bans from rules are not shared with the CXA network.

Built-In Example Rules

Both rules ship with Enabled = false:

Config.Rules = {
    block_adder = {
        Enabled = false,
        Event = 'entityCreating',
        Condition = "model == 'adder'",           -- Any adder, also from traffic
        Actions = { 'block', 'log' },
        Reason = 'Spawned an adder',
    },
    new_discord_accounts = {
        Enabled = false,
        Event = 'playerConnecting',
        Condition = 'discordAge < 30',            -- Discord account younger than 30 days
        Actions = { 'block', 'log' },
        Reason = 'Discord account younger than 30 days',
    },
}

block_adder matches every adder, including ones from traffic. Add and script == true before you use it, as in the first example below.

Examples

Block a Vehicle Model

Stop players from spawning a fighter jet with a script, while traffic stays untouched.

  • When: Entity spawned
  • Condition: model == 'lazer' and script == true
  • Then: Block, Log
block_lazer = {
    Enabled = true,
    Event = 'entityCreating',
    Condition = "model == 'lazer' and script == true", -- Only script spawns, not traffic
    Actions = { 'block', 'log' },
    Reason = 'Spawned a fighter jet',
},

Reject New Discord Accounts

Turn away Discord accounts younger than 7 days. The second rule also refuses players who have no Discord at all.

young_discord = {
    Enabled = true,
    Event = 'playerConnecting',
    Condition = 'discordAge < 7',                 -- Players without Discord pass this one
    Actions = { 'block', 'log' },
    Reason = 'Discord account younger than 7 days',
},
discord_required = {
    Enabled = true,
    Event = 'playerConnecting',
    Condition = 'hasDiscord == false or discordAge < 7', -- No Discord, or too new
    Actions = { 'block', 'log' },
    Reason = 'Discord missing or younger than 7 days',
},

Refused players see You cannot join this server: Discord account younger than 7 days.

Log a Weapon

Write a log entry when someone hits a target with a heavy sniper from more than 300 meters, without blocking anything.

log_long_sniper = {
    Enabled = true,
    Event = 'weaponDamageEvent',
    Condition = "weapon == 'WEAPON_HEAVYSNIPER' and distance > 300", -- Distance in meters
    Actions = { 'log' },
    Reason = 'Heavy sniper hit from over 300 m',
},

Stop chat messages with Discord invites and warn the sender.

no_invites = {
    Enabled = true,
    Event = 'chatMessage',
    Condition = "message contains 'discord.gg/'", -- Not case-sensitive
    Actions = { 'block', 'warn' },
    Reason = 'Posted a Discord invite',
},

Panel Validation Messages

The panel checks every rule while you type and again when you save or import code. You cannot save a rule it cannot read.

MessageWhat it means
Write a condition.The condition is empty.
Cannot read "...".One part of the condition could not be read: text without quotes, a missing value, a misspelled operator or a parenthesis. The quoted part shows where.
"..." is not a field of this event.The field does not exist for the chosen event, or its case is different.
Unknown event.The event is not one of the five supported events.
Rule ...: pick at least one action.The rule has no action selected.
Rule name "..." may only use a-z, 0-9 and _.Imported code uses a rule name with other characters.
Maximum 50 rules.Your server has reached the rule limit.

For rules written in config.lua, the console shows a yellow warning instead and skips the rule:

Output
[CXA] Security rule block_lazer has an invalid condition near: model == lazer

Limits and Performance

LimitValue
Rules per server50
Rule namea-z, 0-9 and _, up to 32 characters
ConditionUp to 300 characters
ReasonUp to 120 characters
  • Conditions are translated once when the anticheat starts, not on every event.
  • CXA only listens to events that at least one enabled rule uses.
  • Entity spawned and Weapon damage fire very often on a full server, and every enabled rule on them is checked each time. Keep these rules few and their conditions short.
  • All rules share one detection name, SecurityRule. After a log or warn for a player, further log or warn matches for the same player are skipped for the Detection cooldown (Config.Logs.DetectionCooldown, default 10 seconds). Blocking still happens every time.

Recommendations

Recommended:

  • Start a new rule with Log only. Check the logs for a few days, then add Block, Kick or Ban.
  • Add script == true to Entity spawned rules, so traffic is never matched.
  • Write a clear Reason. Players see it on kick screens and in ban records.
  • Use hasDiscord == false or ... when a Discord rule should also cover players without Discord.

Avoid:

  • Ban on a rule you have not tested. Rule bans are permanent.
  • Rules that repeat a built-in detection, such as blacklisted vehicles or chat words. Use the detection and its own settings instead.
  • Many rules on Weapon damage. That event fires on every hit.

Join Screening

  • playerConnecting rules run while players connect, next to the built-in join checks.
  • See Join Screening.

Entity Control

  • The entity blacklists already block listed vehicles, peds and objects. Rules add conditions the lists cannot express.
  • See Entity Control.

Explosion Control

Detections & Punishments

Bypass & Pause Exports

  • PauseDetection(src, 'SecurityRule', seconds) pauses rule punishments for one player. Blocking still happens.
  • See Bypass & Pause Exports.

Config Editor

  • Import code is the fastest way to add several rules at once.
  • See Config Editor.

Limitations

  • Conditions support no parentheses, and quoted text cannot contain the words and or or between spaces.
  • Only the fields in the table above are available.
  • Bans from rules are permanent; there is no duration setting.
  • On playerConnecting, warn has no effect, and logs go to Discord only. They do not appear in the panel's Detections tab.
  • Chat message rules only see messages sent through the chatMessage event of the standard chat resource.
  • Rules never take screenshots.

Common Problems

The Rule Shows "Error" in the Panel

What you see: The rule has a red Error badge and you cannot save.

How to fix it:

  • Read the red line under Condition. It names the part that is wrong.
  • Put text in quotes, check the field names in the hint line and remove parentheses.

The Console Says "Security rule ... has an invalid condition near"

What you see: On start, the console prints [CXA] Security rule <name> has an invalid condition near: <text>.

How to fix it:

  • The condition comes from config.lua and was skipped. Fix the part shown after near:.
  • Paste the rule into Import code in the panel; the validation messages show exactly what is wrong.

My Rule Never Matches

What you see: The rule is on, but nothing is ever blocked or logged.

How to fix it:

  • Check that the rule is switched on and saved, and wait a minute for the server to reload.
  • Test with a staff member who does not bypass the anticheat. Bypassed players are never matched.
  • Add Log to the actions. A rule with only Block cancels silently.
  • For < and > checks, make sure the field is a number for that player. discordAge is empty for players without Discord.

Players Without Discord Still Get In

What you see: A discordAge < 30 rule refuses young accounts, but players with no Discord join freely.

How to fix it:

  • Write hasDiscord == false or discordAge < 30.

Traffic Vehicles Are Blocked Too

What you see: A model rule also blocks that car when it appears in traffic, and logs the player whose game spawned it.

How to fix it:

  • Add and script == true to the condition.

Only the First Match Is Logged

What you see: A player triggers a rule several times in a row, but only one log appears.

How to fix it:

  • This is the Detection cooldown. Logs and warnings of the same player are skipped for Config.Logs.DetectionCooldown seconds. Lower it in Configuration → Logs → Logging if you need every entry.

Common Condition Mistakes

Lua
-- ❌ Text without quotes cannot be read
Condition = "model == adder"
-- ✅ Put names and text in quotes
Condition = "model == 'adder'"

-- ❌ Field names are case-sensitive
Condition = "discordage < 30"
-- ✅ Write the field exactly as listed
Condition = "discordAge < 30"

-- ❌ "contains" does not search inside model names
Condition = "model contains 'police'"
-- ✅ Compare each model with ==
Condition = "model == 'police' or model == 'police2'"

-- ❌ Parentheses are not supported
Condition = "(type == 2 or type == 3) and script == true"
-- ✅ Repeat the shared part in each group
Condition = "type == 2 and script == true or type == 3 and script == true"

-- ❌ " and " inside quoted text splits the condition
Condition = "message contains 'cash and items'"
-- ✅ Check each word on its own
Condition = "message contains 'cash' and message contains 'items'"

-- ❌ "contains" must be lowercase
Condition = "message CONTAINS 'cheat'"
-- ✅ Write operators in lowercase
Condition = "message contains 'cheat'"

© 2026 CodeXart Studios · CXA Anticheat