BanPlayer
Jump to navigation
Jump to search
banPlayer
Persists a verified client-serial ban and disconnects the connected player.
Syntax
bool banPlayer(int playerId [, int minutes = 0 [, string reason = "Banned by a server resource"]])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
playerId |
int |
yes | The connected player identifier. |
minutes |
int |
no | Optional duration in whole minutes. Use 0 for a permanent ban; the maximum is 5,256,000 minutes (10 years).
|
reason |
string |
no | Optional non-empty reason of at most 160 bytes without control characters. |
Returns
Returns true only when the serial ban is persisted and the player's disconnect is accepted. Returns false for an invalid or unauthenticated player, invalid arguments, or a persistence failure.
Examples
Ban a player for one hour:
if not banPlayer(playerId, 60, "Repeated griefing") then
outputDebugString("The ban could not be persisted.", 1)
end
Notes
- Available only in server-side resource scripts.
- The ban is stored by verified client serial in the server's local
bans.json. It is distinct from global master-list bans and from any account-ban table maintained by a gamemode. - This function does not grant or check a gamemode permission such as
admin.ban. The calling resource must authorize the command or action before invoking it. - A successful call immediately revokes voice, ends the gameplay connection and closes the game client. The launcher displays the ban reason, and the normal
onPlayerQuitevent follows. There is no separateonPlayerBanevent. - Omitting
minutesor passing0creates a permanent ban.