Skip to content

Bans

Bans live in data/bans.json beside the player records: a plain list an admin can read and edit by hand, read at startup. A banned player’s hello is refused with the reason text.

Function
Kick(pid, reason) out now; OnPlayerDisconnect reads "kicked: <reason>"
Ban(pid, reason [, seconds]) kicks the player and bans their name and address; seconds nil or 0 = for good
BanName(name, reason [, seconds]) whoever is on under it is kicked
BanAddress(ip, reason [, seconds]) same, by address
Unban(nameOrAddress)bool
IsBanned(nameOrAddress)"banned: reason (N min left)" | nil
function OnPlayerCommandText(pid, cmd, args)
if cmd == "kickban" and IsPlayerAdmin(pid) then
local name, minutes = args:match("^(%S+)%s*(%d*)$")
for _, id in ipairs(GetPlayers()) do
if GetPlayerName(id):lower() == (name or ""):lower() then
Ban(id, "by " .. GetPlayerName(pid), (tonumber(minutes) or 0) * 60)
return true
end
end
SendClientMessage(pid, COLOUR_RED, "no player called " .. tostring(name))
return true
end
return false
end

The server’s own /kick, /kickban and /unban do the same for admins in every mode — see Chat commands. A mode that handles those names itself takes them over.