Detection hooks

Your own resources can see each detection hit as it happens. A hook can add a note to the hit, or ask Sculk not to act on a hit that only logs or goes to staff review. Use it when your scripts know something Sculk cannot, such as a garage that teleports players or a job that hands out items.

Hooks need a Sculk build that has them. The dashboard's Detection hooks screen says whether your server's build does, and lists everything your resources did with them.

The rules

  • Any resource can add a note with d.annotate(text). Notes show next to the hit on the dashboard.
  • Suppressing is narrow. d.suppress(reason) works only when all four are true:
    1. The resource has the permission: add_ace resource.<name> sculk.hooks allow in server.cfg.
    2. The hit's tier is observe (only recorded) or review (goes to the staff queue). A hit that cancels, kicks or bans (enforce) can never be suppressed.
    3. The detection is not one that can never be bypassed.
    4. The reason is 3 to 200 characters.
  • A suppressed hit is still recorded, marked as suppressed by your resource. It gives no strike, opens no case and takes no action. It stays out of the learning report.
  • Every suppression is on the dashboard, with the resource, the detection, the player and the reason, for 90 days. A refused attempt is listed too, with why.

Grant the permission only to resources you wrote or have read. A resource with sculk.hooks can quiet review-level hits for every player.

# server.cfg: allow one resource to suppress observe and review hits add_ace resource.my_garages sculk.hooks allow

The API

local handle = exports.sculk:onDetection(function(d) -- d.detection, d.tier, d.action, d.source, d.ref, d.observed, d.threshold, d.measured, d.opens_case end, { detections = { 'move.', 'aim.silent' } }) exports.sculk:offDetection(handle)
  • opts.detections is optional: exact ids, or prefixes ending with a dot ('move.'), at most 32. Without it the hook sees every detection.

  • At most 8 hooks per resource. When your resource stops, its hooks are removed.

  • The callback runs during the hit, in the order hooks were added. It must return quickly: a hook that errors, waits (Wait, Citizen.Await) or takes more than 2 ms is skipped and logged once a minute, and the hit goes on as if the hook were not there.

  • detection: The detection id, for example move.teleport. The detection catalogue lists them all

  • class: deterministic, strong, statistical, client, prevention or tool

  • tier: What the hit does now on this server: observe, review or enforce

  • action: What Sculk does with this hit if no hook suppresses it

  • source: The player's server id

  • ref: The player ref the dashboard uses

  • at: Time of the hit, Unix milliseconds

  • observed, threshold: The reading and the limit, when the detection has them

  • measured: The value each parameter was compared with, for example { max_speed_ms = 412.7 }

  • opens_case: Whether this hit opens or adds to a case

Type files for your editor, the same ones the Sculk resource repository ships: sculk.lua (LuaLS annotations for every Sculk server export, hooks included; ---@type SculkDetection) and sculk.d.ts (JavaScript and TypeScript resources). Point your editor at them; never add the .lua file to a resource's fxmanifest.lua: it is types only.

ESX: a garage that teleports players

The garage moves the player to their car. Mark the moment, then quiet a teleport hit that follows within 3 seconds.

-- my_garages/server.lua (server.cfg: add_ace resource.my_garages sculk.hooks allow) local ESX = exports['es_extended']:getSharedObject() local movedAt = {} RegisterNetEvent('my_garages:takeOut', function(plate) local src = source local xPlayer = ESX.GetPlayerFromId(src) if not xPlayer then return end -- ... your own checks, then move the player server-side ... movedAt[src] = GetGameTimer() end) AddEventHandler('playerDropped', function() movedAt[source] = nil end) exports.sculk:onDetection(function(d) local t = movedAt[d.source] if t and GetGameTimer() - t < 3000 then d.suppress('garage take-out teleport') end end, { detections = { 'move.teleport' } })

QBCore: tell staff who was on duty

Notes need no permission. This adds the player's job to aim hits so the reviewer sees it next to the evidence.

-- qb-sculknotes/server.lua local QBCore = exports['qb-core']:GetCoreObject() exports.sculk:onDetection(function(d) local Player = QBCore.Functions.GetPlayer(d.source) if not Player then return end local job = Player.PlayerData.job if job and job.onduty then d.annotate(('on duty as %s (grade %s)'):format(job.name, job.grade.level)) end end, { detections = { 'aim.' } })

Qbox: the same with qbx_core

-- qbx-sculknotes/server.lua exports.sculk:onDetection(function(d) local player = exports.qbx_core:GetPlayer(d.source) if not player then return end local job = player.PlayerData.job if job and job.onduty then d.annotate(('on duty as %s'):format(job.name)) end end, { detections = { 'aim.', 'combat.' } })

ox_inventory and ox_lib: shop purchases and staff teleports

ox_inventory's buyItem hook tells you a player just bought something, so an item-rate hit right after is explained. An ox_lib command marks a staff teleport.

-- my_shops/server.lua (fxmanifest: shared_script '@ox_lib/init.lua') -- server.cfg: add_ace resource.my_shops sculk.hooks allow local boughtAt = {} exports.ox_inventory:registerHook('buyItem', function(payload) boughtAt[payload.source] = GetGameTimer() end) lib.addCommand('tpm', { help = 'Teleport to marker', restricted = 'group.admin' }, function(source) Player(source).state:set('staffMovedAt', GetGameTimer(), false) -- ... teleport ... end) exports.sculk:onDetection(function(d) if d.detection:find('^econ%.item') then local t = boughtAt[d.source] if t and GetGameTimer() - t < 5000 then d.suppress('bought from an ox_inventory shop') end elseif d.detection == 'move.teleport' then local t = Player(d.source).state.staffMovedAt if t and GetGameTimer() - t < 3000 then d.annotate('staff /tpm teleport') end end end, { detections = { 'econ.', 'move.teleport' } })

A staff teleport is only annotated here, not suppressed. For staff, an exemption is the better tool: see staff exemptions.

JavaScript resources

/// <reference path="./sculk.d.ts" /> exports.sculk.onDetection((d) => { if (d.tier !== 'enforce' && d.detection === 'move.teleport' && recentlyMoved(d.source)) { d.suppress('scripted teleport'); } }, { detections: ['move.teleport'] });

Checking it works

Open the dashboard, pick the server, then Detection hooks. Each suppression, note and refused attempt is listed with the resource that made it. If a suppression shows as Refused, the reason is next to it: no permission, a hit that enforces, a detection that cannot be bypassed, or a missing reason.