ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. banPlayer

Function

banPlayer

Bans a player (their Client ID and IP address) and kicks them right away.

Syntax

ban banPlayer(player player [, player/string responsible = nil, string reason = "", int seconds = 0])

Arguments

playerplayer
The player to ban.
responsibleplayer/string, optional = nil
Who issued the ban: a player or a name.Different type in MTA:SA: bool IP = true
reasonstring, optional = ""
Reason shown to the player.Different type in MTA:SA: bool username = false
secondsint, optional = 0
Ban length in seconds, 0 means permanent.Different type in MTA:SA: bool serial = false

Differences from MTA:SA

  • Arguments in a different colour differ from MTA:SA.
  • These MTA:SA arguments are not here: player/string responsibleElement = "Console", string reason = "", int seconds = 0

In MTA:SA

banPlayer(player bannedPlayer, bool IP = true, bool username = false, bool serial = false, player/string responsibleElement = "Console", string reason = "", int seconds = 0)

Returns

A ban handle or false.

Example

addCommandHandler("ban", function(admin, cmd, name, hours, ...)
    local target = name and getPlayerFromName(name)
    if not target then
        outputChatBox("Nie ma takiego gracza.", admin, 255, 0, 0)
        return
    end
    local seconds = (tonumber(hours) or 0) * 3600
    banPlayer(target, admin, table.concat({...}, " "), seconds)
end, true)

See also