Skip to content
MilkGames edited this page Feb 27, 2021 · 7 revisions

These are all the hooks included:

xWarnPlayerWarned

Desc: Ran whenever a player is warned. Can be used for automatic cooldown bans.

Arguments Type
warned string
warnedply ply
admin ply
reason string

Example:

hook.Add("xWarnPlayerWarned", "xWarnTest", function(warned, admin, reason) 
	xWarn.Database.GetWarns(warned:SteamID64(), function(warns)
		local onedayago = 0
		for k, v in pairs(warns) do
			if os.time() - v.time < 86400 then
				onedayago = onedayago + 1
			end
		end
		if onedayago >= 5 then
			xAdmin.Database.CreateBan(warned:SteamID64(), (IsValid(warned) and warned:Name()) or "Unknown", 0, "xWarn", "Cooldown ban", 21600)
			warned:Kick(string.format(xAdmin.Config.BanFormat, "xWarn", string.NiceTime(21600), "Cooldown ban"))
		end
	end)
end)

This example automatically bans any player (for 6 hours) that has >= 5 warnings in 24 hours.

xWarnWarningDeleted

Desc: Ran whenever a warning is deleted.

Arguments Type
warnid string
admin ply

xWarnWarnOnBan

Desc: Ran whenever an automatic warning is added due to a ban.

Arguments Type
target string
targetname string
time number
archiveEntryId number

Blockers

xWarnCanDeleteWarning

Desc: Used to block a warning from being deleted.

Arguments Type
admin ply
warn table

Returns:

Arguments Type
canDelete boolean
msg string or nil
Clone this wiki locally