-
Notifications
You must be signed in to change notification settings - Fork 0
Hooks
MilkGames edited this page Feb 27, 2021
·
7 revisions
These are all the hooks included:
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.
Desc: Ran whenever a warning is deleted.
Arguments | Type |
---|---|
warnid | string |
admin | ply |
Desc: Ran whenever an automatic warning is added due to a ban.
Arguments | Type |
---|---|
target | string |
targetname | string |
time | number |
archiveEntryId | number |
Desc: Used to block a warning from being deleted.
Arguments | Type |
---|---|
admin | ply |
warn | table |
Returns:
Arguments | Type |
---|---|
canDelete | boolean |
msg | string or nil |