Skip to content

Events

Server events fired by Asphyxia on bans, strikes, detections, risk score changes and whitelist changes.

Updated View as Markdown

Asphyxia fires a server event whenever a ban, strike, detection, risk score change or whitelist change happens. Use them to post to Discord, alert staff in-game, sync punishments to another system or keep your own records.

All events are server-side and meant for your own resources, not for clients.

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

Event index

Event Fires when
asphyxia:server:playerBanned A player is banned.
asphyxia:server:playerUnbanned One ban is lifted.
asphyxia:server:playerRebanned An existing ban is reissued.
asphyxia:server:allPlayersUnbanned Every ban is lifted at once.
asphyxia:server:playerStriked A player receives a strike.
asphyxia:server:detectionTriggered A detection is confirmed.
asphyxia:server:testModeDetection A detection triggers while test mode is on.
asphyxia:server:riskScoreChanged A player’s risk score changes.
asphyxia:server:playerWhitelisted A detection whitelist is added.
asphyxia:server:whitelistRemoved A detection whitelist is lifted.

Bans

playerBanned

asphyxia:server:playerBanned

Fires on every ban, whether it comes from a detection, an admin, the console or one of your own scripts.

Field Type Description
banId string Unique ID of the ban.
playerId number Server ID of the banned player.
playerName string Name of the banned player.
license string License identifier of the banned player.
identifiers table All identifiers stored with the ban.
reason string Reason for the ban.
details table Extra context attached to the ban.
bannedBy string Who issued the ban.

playerUnbanned

asphyxia:server:playerUnbanned

Fires when a single ban is lifted.

Field Type Description
banId string ID of the ban that was lifted.
reason string Reason given for lifting it. Defaults to "No reason provided".
revokedBy string Who lifted the ban.

playerRebanned

asphyxia:server:playerRebanned

Fires when an existing ban is reissued. TODO: confirm what triggers a reban.

Field Type Description
banId string ID of the ban.
reason string Reason for the reban. Defaults to "No reason provided".
rebannedBy string Who issued the reban. Defaults to "System".
removed TODO TODO: what this holds.

allPlayersUnbanned

asphyxia:server:allPlayersUnbanned

Fires when every ban is lifted at once through asphyxia unbanall.

Field Type Description
lifted number Number of bans lifted.
reason string Reason given for lifting them. Defaults to "Mass unban".
revokedBy string Who ran the command.

Strikes and detections

playerStriked

asphyxia:server:playerStriked

Fires on every strike, before any ban the strike causes.

Field Type Description
strikeId string Unique ID of the strike.
playerId number Server ID of the player.
playerName string Name of the player.
license string License identifier of the player.
reason string Short reason for the strike.
description string Longer description of what was detected.
severity string low, medium or high.
sessionCount number How many strikes of this severity the player has this session.

Use sessionCount to warn staff before a ban happens.

detectionTriggered

asphyxia:server:detectionTriggered

Fires when a detection is confirmed, before the resulting ban or strike. Whitelisted players never trigger it.

Field Type Description
playerId number Server ID of the player.
playerName string Name of the player.
detection string Name of the detection.
detail string Detection-specific detail.
strikeOnly boolean true if the detection issues a strike, false if it bans outright.

testModeDetection

asphyxia:server:testModeDetection

Fires when a detection triggers while test mode is on.

Field Type Description
playerId number Server ID of the player.
playerName string Name of the player, or "Unknown" if it can’t be resolved.
reason string Reason for the ban. Defaults to "No Reason.
banDetails table string

riskScoreChanged

asphyxia:server:riskScoreChanged

Fires when a player’s risk score changes.

Field Type Description
playerId number Server ID of the player.
playerName string Name of the player.
license string License identifier of the player.
previous number Score before the change.
current number Score after the change.

Whitelists

Whitelist events pass positional arguments instead of a table.

playerWhitelisted

asphyxia:server:playerWhitelisted

Fires when a detection whitelist is added.

AddEventHandler("asphyxia:server:playerWhitelisted", function(license, detection, expiresAt, grantedBy)
end)
Argument Type Description
license string License identifier of the whitelisted player.
detection string Detection the whitelist applies to.
expiresAt number or nil Unix timestamp when the whitelist ends. nil means it lasts until restart.
grantedBy string Who added the whitelist.

whitelistRemoved

asphyxia:server:whitelistRemoved

Fires when a whitelist is lifted.

AddEventHandler("asphyxia:server:whitelistRemoved", function(license, detection)
end)
Argument Type Description
license string License identifier of the player.
detection string or nil Detection that was lifted. nil when all whitelists were cleared at once.

Example: mirroring punishments to Discord

This posts every ban and every high-severity strike to a Discord webhook.

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

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

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

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

Type to search…

↑↓ navigate↵ selectEsc close