SAFScriptsDocs

Checks & codes

SAF Anticheat is coming soon. These docs describe the build that will ship.

On this page

How a flag becomes an action

Text
check -> flag (code, severity, numbers) -> history -> score (+severity, drains Config.Score.Decay per minute)
      -> action: the higher of the code's own action and the score's (alert 40, screenshot 70, kick 100)
      -> alert in game + Discord, case file, screenshot when it reaches that far
  • Cooldowns. The same code for the same player raises a flag at most once per cooldown seconds. Repeats in between are counted on the next one.
  • Alerts. One line in game for staff with ac.staff, at most once a minute per player and code.
  • Kicks from the score wait KickDelay seconds. If a staff member opens the player in the panel or acts on them, the kick is off.
  • Bans only happen for certain flags with Config.AutoBan on. With it off, a ban becomes a kick, and a certain flag doesn't escalate past its code's action and the score.
  • Staff get flagged, scored and alerted like anyone else. Config.StaffMaxAction (default screenshot) only stops the anticheat kicking or banning them on its own. Set it to nil to treat staff exactly like players.
  • Shadow mode caps every action at Config.Shadow.MaxAction and only keeps the cancels in Config.Shadow.StillCancel.

Per-check settings

Every code has an entry in Config.Checks:

KeyWhat it does
enabledTurn the check off
severityPoints added to the score, 1 to 100
actionThe code's own action: 'log', 'alert', 'screenshot', 'kick' or 'ban'
cooldownSeconds between two flags of this code for the same player
cancelBlock the thing when it can be blocked
custom/shared/checks.lua
Config.Checks.SPECTATE.enabled = false
Config.Checks.HEAL_INSTANT.severity = 5
Config.Checks.NOCLIP.action = 'screenshot'

Codes

Severity and action are the defaults. Certain means the code can ban on its own once Config.AutoBan is on.

Entities

CodeWhat it meansSevActionCertain
ENT_BLACKLISTSpawned a model nobody needs (ramps, UFOs, cargo planes). Blocked60alert
ENT_SPAMSpawned more objects, vehicles or peds than allowed in 10 s. Blocked30log5 times in 30 s
ENT_CAPOwns more entities at once than allowed. Blocked10log
ENT_MODELWent over a per-model limit you set. Blocked20log

Explosions

CodeWhat it meansSevActionCertain
EXPL_BLOCKEDAn explosion type normal play doesn't create (grenades, rockets, explosive ammo). Blocked40log
EXPL_REMOTEAn explosion far from the player who sent it. Blocked40alertover 500 m
EXPL_SILENTAn invisible or silent explosion. Blocked70alertyes
EXPL_RATEMore than 4 explosions in 5 s. Blocked30log

Movement

CodeWhat it meansSevActionCertain
TP_DISTMoved further in a second than possible30 / 80logover 2 km on foot, no grace in 30 s
SPDOver the speed limit in 3 of the last 5 seconds25log
NOCLIPHanging in the air for 4 s, client and server agree40log
TP_OOBOutside the map or far under it40log
SPECTATECamera far from the ped, or in spectator mode10log

Health

CodeWhat it meansSevActionCertain
GOD_HPHealth or armour over the max50alert500 health or more
GOD_DMG10 hits in a row from other players and no health or armour lost60alert
GOD_FLAGInvincible on the client for 30 s20log
HEAL_INSTANTHealth from low to full in a second with no known heal15log

Weapons and damage

CodeWhat it meansSevActionCertain
WEAP_GIVE_OTHERGave a weapon to another player. Blocked80alertyes
WEAP_REMOVE_OTHERTook weapons from another player. Not blocked by default40log
WEAP_BLACKLISTHolding a restricted weapon. Removed40alert
DMG_WEAPONHits with a weapon that isn't in their hand15log
DMG_RANGEHit someone beyond the weapon's range30log
DMG_AMOUNTClaimed more damage than the weapon does30log
DMG_MULTIKILLKilled several players within a second40alert
DMG_VEH_FARDamaged a vehicle from very far30log
DMG_HEADSHOTHeadshot rate far above the server's10log
AMMO_INFINITEKept firing with the ammo count never dropping15log

Events

CodeWhat it meansSevActionCertain
EVT_RATEFired the same event over 40 times in 10 s20logover 200 in 10 s
EVT_HONEYPOTFired a fake event menus try100alertyes
EVT_SCHEMAWrong arguments for an event you listed30log
EVT_EXPLOITFired a known exploitable event without the job40alert
EVT_TOKENOur own events with a wrong session token, or a replayed heartbeat30log

Players affecting players

CodeWhat it meansSevActionCertain
PLY_ATTACHAttached to another player's ped for a while10log
PLY_TASKSCleared another player's tasks (froze or stopped them). Blocked40log3 times in 10 s
PLY_PTFXParticle effects far away or in a flood. Blocked20log

Tamper and client

CodeWhat it meansSevActionCertain
HB_MISSThe anticheat on their client stopped answering. Kick after 3 in a row50log
RES_STOPA watched resource was stopped on their client40alert
RES_INJECTA resource the server never started90alertyes
MENU_TXDA known menu's textures are loaded30log
MENU_CMDA known menu's command is registered30log
MENU_GLOBALA known menu left its code in our resource40log
MENU_PEDFLAGJumped higher than possible (super jump)25log

The client checks (GOD_FLAG, SPECTATE, the client half of NOCLIP, AMMO_INFINITE, MENU_*, RES_*) are weak on their own: good menus hide from them. They exist to raise the score and get a screenshot.

Certain flags

Only codes in Config.Certain can ban on their own, and only with Config.AutoBan on. Some are certain on every flag, others only past a condition:

CodeCertain when
EVT_HONEYPOT, EXPL_SILENT, WEAP_GIVE_OTHER, RES_INJECTEvery flag
ENT_SPAM5 times in 30 s
EXPL_REMOTEOver 500 m from the sender
GOD_HP500 health or more
TP_DISTOver 2 km on foot, outside any grace and none in the last 30 s
PLY_TASKS3 times in 10 s
EVT_RATEOver 200 in 10 s

Add or remove codes freely:

custom/shared/certain.lua
Config.Certain.EXPL_REMOTE = nil   -- never ban on remote explosions

Grace windows

A legit teleport or heal opens a grace window. Flags inside it are scaled by the window's severity (0 is no flag, 0.25 a quarter) and are never certain.

WindowWhenDefault
spawnJoining120 s, no flags
characterCharacter loaded or switched (Qbox, QBCore, ESX, ox_core, ND events)30 s, no flags
respawnThe server sees the ped die and come back, or get replaced15 s, no flags
scriptAnother resource calls AllowTeleport or fires saf-anticheat:grace10 s, no flags
clientThe player's own client asks (client AllowTeleport export)10 s, half severity, 6 per 5 min
vmenuvMenu summon or teleport to player, checked against vMenu's ACE15 s, quarter severity
easyadminEasyAdmin teleports and spectate, checked against its ACE15 s, quarter severity
txadmintxAdmin menu teleports and heals15 s, quarter severity
panelGoto, bring or spectate from this panel15 s, quarter severity
healAllowHeal, txAdmin heal, respawn5 s, covers HEAL_INSTANT
attachCarry or escort scripts firing saf-anticheat:grace with 'attach'30 s, covers PLY_ATTACH

Teleports that only happen on the client (vMenu teleport to waypoint, noclip) can't be seen by the server and are flagged normally. To have those logged only, add an exemption for the ACE that gives them.

For your own scripts, open a window right before a legit teleport:

Lua
-- server
exports['saf-anticheat']:AllowTeleport(src, 10)
TriggerEvent('saf-anticheat:grace', src, 'teleport', 10)   -- if you'd rather not depend on the resource

-- client
exports['saf-anticheat']:AllowTeleport(10)

Exemptions

None by default. Add them in Config.Exempt, per identifier, per ACE or per code. Each one is a mode for every code, or a table of code = mode ('*' for the rest).

ModeWhat it does
'ignore'The check doesn't run for them
'log'Flagged and logged only: no score, alert or action
'normal'Checked like everyone else
Lua
Config.Exempt = {
    players = { ['license:abc123'] = 'log' },
    aces = { ['vMenu.NoClip'] = { NOCLIP = 'log', TP_DIST = 'log', SPD = 'log' } },
    codes = { HEAL_INSTANT = 'log' },
}

The panel shows every exemption on the Checks screen and marks exempt players in the list. Staff with ac.exempt can also set a player to log-only for their session from the panel (Config.PanelAllowMode).

SAF Scripts by San Andreas' Finest StoreDiscordsupprot@safrp.org

Not affiliated with or endorsed by Rockstar Games, Take-Two Interactive or Cfx.re.