Event

anticheat:sync

Server

Fired when a peer sends entity sync data it is not allowed to send

Signal

"anticheat:sync"

This signal is only fired on the server.

  • Trigger — fired when the server rejects data from a peer; it never kicks, your script decides.
  • Throttling — one signal per peer and reason per second; count is the violations since the last signal.
  • Repeated reports — a single report can be harmless, act on a repeated count, not the first report.
  • Kicking — use core.engine.disconnect_peer to kick a peer.

Arguments

TypeNameDescription
intpeer_idId of the peer that sent the rejected data
stringreasonWhy it was rejected, see below
intnet_idNet id of the entity involved, 0 for spoofed
intcountViolations of this reason since the last signal, at least 1

Reasons

ReasonDescription
unauthorizedThe peer sent sync data for an entity it is not the syncer of
spoofedThe sender id inside the sync packet does not match the connection
malformedThe sync data is invalid or contains non-finite values (NaN or infinity)

Example

Kick on forged or broken packets
util.event.on("anticheat:sync", function(peer_id, reason, net_id, count)
    if reason == "spoofed" or reason == "malformed" then
        core.engine.disconnect_peer(peer_id)
    end
end)
Kick after repeated unauthorized updates
local strikes = {}

util.event.on("anticheat:sync", function(peer_id, reason, net_id, count)
    if reason ~= "unauthorized" then return end

    strikes[peer_id] = (strikes[peer_id] or 0) + count
    if strikes[peer_id] >= 50 then
        core.engine.disconnect_peer(peer_id)
    end
end)

util.event.on("peer:leave", function(peer_id)
    strikes[peer_id] = nil
end)

On this page