---
title: "Events"
description: "Server events Asphyxia fires so your own resources can react to bans, strikes and detections."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.asphyxia.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Events

Asphyxia fires a server event whenever something meaningful happens. Listen for
them to post to your own Discord, notify staff in-game, sync a punishment to
another system, or keep your own records.

All of these are **server-side**, and all are triggered locally — they're for
your resources, not for clients.

```lua
AddEventHandler("asphyxia:server:playerBanned", function(data)
print(("%s was banned: %s"):format(data.playerName, data.reason))
end)
```

> **Note**
>
> These fire after Asphyxia has already acted. They're for reacting, not for
> vetoing — a handler can't stop a ban.

## `asphyxia:server:playerBanned`

Fires when a player is banned, for any reason — a detection, an admin, the
console, or one of your own scripts.

| Field | Type | Description |
| :--- | :--- | :--- |
| `banId` | `string` | The new Ban ID |
| `playerId` | `number` | Their net ID |
| `playerName` | `string` | Their name |
| `license` | `string` | Their license |
| `identifiers` | `table` | Every identifier on record |
| `reason` | `string` | Why they were banned |
| `details` | `string` | Extra context |
| `bannedBy` | `string` | Who or what requested it |

```lua
AddEventHandler("asphyxia:server:playerBanned", function(data)
TriggerEvent("myserver:announce",
    ("%s was banned (%s). Ban ID: %s"):format(data.playerName, data.reason, data.banId))
end)
```

## `asphyxia:server:playerUnbanned`

Fires when a single ban is lifted.

| Field | Type | Description |
| :--- | :--- | :--- |
| `banId` | `string` | The ban that was lifted |
| `reason` | `string` | Why |
| `revokedBy` | `string` | Who lifted it |

## `asphyxia:server:allPlayersUnbanned`

Fires when every active ban is lifted at once via
[`asphyxia unbanall`](/anticheat/commands).

| Field | Type | Description |
| :--- | :--- | :--- |
| `lifted` | `number` | How many bans were lifted |
| `reason` | `string` | Why |
| `revokedBy` | `string` | Who did it |

## `asphyxia:server:playerStriked`

Fires on every [strike](/anticheat/strikes), before any resulting ban.

| Field | Type | Description |
| :--- | :--- | :--- |
| `strikeId` | `string` | The new Strike ID |
| `playerId` | `number` | Their net ID |
| `playerName` | `string` | Their name |
| `license` | `string` | Their license |
| `reason` | `string` | What they were struck for |
| `description` | `string?` | Extra detail |
| `severity` | `string` | `low`, `medium` or `high` |
| `sessionCount` | `number` | How many of this severity they have this session |

`sessionCount` is useful for warning staff before a ban happens:

```lua
AddEventHandler("asphyxia:server:playerStriked", function(data)
if data.severity == "high" and data.sessionCount >= 1 then
    TriggerEvent("myserver:staffAlert",
        ("%s is one strike from a ban (%s)"):format(data.playerName, data.reason))
end
end)
```

## `asphyxia:server:detectionTriggered`

Fires the moment a client detection is confirmed, before the resulting ban or
strike. Whitelisted players never reach this event.

| Field | Type | Description |
| :--- | :--- | :--- |
| `playerId` | `number` | Their net ID |
| `playerName` | `string` | Their name |
| `detection` | `string` | The detection name |
| `detail` | `string` | What was observed |
| `strikeOnly` | `boolean` | `true` if it strikes, `false` if it bans outright |

## `asphyxia:server:riskScoreChanged`

Fires when a player's [risk score](/anticheat/strikes) changes.

| Field | Type | Description |
| :--- | :--- | :--- |
| `playerId` | `number` | Their net ID |
| `playerName` | `string` | Their name |
| `license` | `string` | Their license |
| `previous` | `number` | The score before |
| `current` | `number` | The score after |

## `asphyxia:server:playerWhitelisted`

Fires when a detection [whitelist](/anticheat/whitelisting) is added.

Arguments are positional rather than a table:

```lua
AddEventHandler("asphyxia:server:playerWhitelisted",
function(license, detection, expiresAt, grantedBy)
    print(("%s was exempted from %s by %s"):format(license, detection, grantedBy))
end)
```

`expiresAt` is a Unix timestamp, or `nil` when it lasts until restart.

## `asphyxia:server:whitelistRemoved`

Fires when a whitelist is lifted.

```lua
AddEventHandler("asphyxia:server:whitelistRemoved", function(license, detection)
-- detection is nil when every exemption was cleared at once
end)
```

## A worked example

Mirroring every punishment into your own Discord webhook:

```lua
local WEBHOOK = "https://discord.com/api/webhooks/..."

local function post(title, description, color)
PerformHttpRequest(WEBHOOK, function() end, "POST", json.encode({
    embeds = { { title = title, description = description, color = color } },
}), { ["Content-Type"] = "application/json" })
end

AddEventHandler("asphyxia:server:playerBanned", function(data)
post("Player banned",
    ("**%s**\n%s\n`%s`"):format(data.playerName, data.reason, data.banId), 15548997)
end)

AddEventHandler("asphyxia:server:playerStriked", function(data)
if data.severity ~= "high" then return end
post("High-severity strike",
    ("**%s**\n%s"):format(data.playerName, data.reason), 16776960)
end)
```

Source: https://docs.asphyxia.dev/anticheat/events/index.mdx
