Ban System

Config

Config.BanSystem = {
    enable = true, -- Set to true if you want to use this Feature

    discordLog = true, -- Set true to enable DiscordLogs // Add Webhook Link in server/functions/bansystem.lua
    botColor = "6205745", -- https://www.mathsisfun.com/hexadecimal-decimal-colors.html
    botName = "MSK Scripts",
    botAvatar = "https://i.imgur.com/PizJGsh.png",

    commands = {
        enable = true,
        groups = {'superadmin', 'admin', 'god'},
        ban = 'banPlayer',
        unban = 'unbanPlayer'
    }
}

MSK.BanPlayer

This will ban a player

Parameters playerId - number - The ServerId of the player who banned someone - Optional targetId - number - The ServerId of the player who gets banned time - string - The Time until the player gets unbanned reason - string - The Reason why the player gets banned

Description For the Parameter time you can set different types.

  • 1M = 1 Minute

  • 1H = 1 Hour

  • 1D = 1 Day

  • 1W = 1 Week

  • P = Permanent

MSK.BanPlayer(playerId, targetId, time, reason)

-- Player gets banned for 2 days for reason cheating
MSK.BanPlayer(playerId, targetId, '2D', 'cheating')

-- Player gets permanetly banned for reason cheating
.BanPlayer(playerId, targetId, 'P', 'cheating')

-- If you execute this from the server
MSK.BanPlayer(0, targetId, '2D', 'cheating')

-- As an Export:
exports.msk_core:BanPlayer(playerId, targetId, time, reason)

MSK.UnbanPlayer

This will unban a player

Parameters banId - number - The BanId

Description The Parameter banId is the id in msk_bansystem database

MSK.UnbanPlayer(banId)

-- As an Export:
exports.msk_core:UnbanPlayer(banId)

MSK.IsPlayerBanned

This will check if the given player is banned

Parameters playerId - number - The ServerId of the player

Returns isBanned - boolean or table - If the player is banned or not isExpired - boolean or nil - If the Ban is expired or not

Description On a future update we implement that you can search for specific identifiers like license, discord, etc.

local isBanned, isExpired = MSK.IsPlayerBanned(playerId)

if isBanned and not isExpired then
    -- Player is banned
    print(isBanned.banId, isBanned.ids, isBanned.reason, isBanned.time, isBanned.from)
elseif isBanned and isExpired then
    -- Player was banned but the Ban is expired
    print(isBanned.banId, isBanned.ids, isBanned.reason, isBanned.time, isBanned.from)
else
    -- Player is not banned
end

-- As an Export:
local isBanned, isExpired = exports.msk_core:IsPlayerBanned(playerId)

Commands

/banPlayer

Parameters targetId - number - The ServerId of the player who gets banned time - string - The Time until the player gets unbanned reason - string - The Reason why the player gets banned - Optional, default: 'Unknown reason'

Description For the Parameter time you can set different types:

  • 1M = 1 Minute

  • 1H = 1 Hour

  • 1D = 1 Day

  • 1W = 1 Week

  • P = Permanent

/banPlayer playerId time reason

-- Example 1: Player with ID 1 gets banned for 2 days for cheating
/banPlayer 1 2D "Cheating"

-- Example 2: Player with ID 1 gets permanently banned for cheating
/banPlayer 1 P "Cheating"

/unbanPlayer

Parameters banId - number - The BanId

/unbanPlayer banId

-- Example: BanId 5 gets unbanned
/unbanPlayer 5

Last updated