Skip to Content
Cobalt

Permissions and bans

cobalt_core exports: permissions and bans.

ExportSideWhat it does
HasPermissionServerWhether the player holds the rank, or any of the ranks listed.
GetPermissionServerEvery rank the player holds.
AddPermissionServerGives the player a rank (staff, admin or owner) for this session.
RemovePermissionServerTakes a rank from the player for this session.
IsWhitelistedServerWhether the player may join while the whitelist is on.
IsOptinServerWhether an admin has opted in to admin reports.
ToggleOptinServerFlips an admin's opt-in to admin reports.
IsPlayerBannedServerWhether a ban matches the player by license, Discord or Steam, with the kick message.
IsLicenseInUseServerWhether a connected player already has that Rockstar license.
KickServerDrops the player with a reason.
ExploitBanServerBans the player for an exploit and drops them.
BanServerBans an online player by the chosen identifiers, which IsPlayerBanned then matches on connect.
UnbanServerLifts bans matching a ban id or a license, Discord or Steam identifier.

HasPermission

Server

Whether the player holds the rank, or any of the ranks listed. Higher ranks pass too.

exports.cobalt_core:HasPermission(source, permission)
ParameterTypeOptionalDescription
sourceintegerNo
permissionstring | string[]No
ReturnsDescription
boolean
Example
local ok = exports.cobalt_core:HasPermission(source, 'manage_employees')

GetPermission

Server

Every rank the player holds.

exports.cobalt_core:GetPermission(source)
ParameterTypeOptionalDescription
sourceintegerNo
ReturnsDescription
table<string, boolean>
Example
local permission = exports.cobalt_core:GetPermission(source)

AddPermission

Server

Gives the player a rank (staff, admin or owner) for this session.

exports.cobalt_core:AddPermission(source, permission)
ParameterTypeOptionalDescription
sourceintegerNo
permissionstringNo
Example
exports.cobalt_core:AddPermission(source, 'manage_employees')

RemovePermission

Server

Takes a rank from the player for this session.

exports.cobalt_core:RemovePermission(source, permission)
ParameterTypeOptionalDescription
sourceintegerNo
permissionstringNo
Example
exports.cobalt_core:RemovePermission(source, 'manage_employees')

IsWhitelisted

Server

Whether the player may join while the whitelist is on. Always true when it is off.

exports.cobalt_core:IsWhitelisted(source)
ParameterTypeOptionalDescription
sourceintegerNo
ReturnsDescription
boolean
Example
local ok = exports.cobalt_core:IsWhitelisted(source)

IsOptin

Server

Whether an admin has opted in to admin reports. False for non-admins.

exports.cobalt_core:IsOptin(source)
ParameterTypeOptionalDescription
sourceintegerNo
ReturnsDescription
boolean
Example
local ok = exports.cobalt_core:IsOptin(source)

ToggleOptin

Server

Flips an admin's opt-in to admin reports.

exports.cobalt_core:ToggleOptin(source)
ParameterTypeOptionalDescription
sourceintegerNo
Example
exports.cobalt_core:ToggleOptin(source)

IsPlayerBanned

Server

Whether a ban matches the player by license, Discord or Steam, with the kick message. Removes expired bans first.

exports.cobalt_core:IsPlayerBanned(source)
ParameterTypeOptionalDescription
sourceintegerNo
ReturnsDescription
booleanbanned
string?message
Example
local banned, message = exports.cobalt_core:IsPlayerBanned(source)

IsLicenseInUse

Server

Whether a connected player already has that Rockstar license.

exports.cobalt_core:IsLicenseInUse(license)
ParameterTypeOptionalDescription
licensestringNo
ReturnsDescription
boolean
Example
local ok = exports.cobalt_core:IsLicenseInUse('license:0123456789abcdef')

Kick

Server

Drops the player with a reason. During connection, pass setKickReason and deferrals from playerConnecting.

exports.cobalt_core:Kick(source, reason, setKickReason, deferrals)
ParameterTypeOptionalDescription
sourceintegerNo
reasonstringNo
setKickReasonfunctionYes
deferralstableYes
Example
exports.cobalt_core:Kick(source, 'Parking in a red zone', function(reason) end, deferrals)

ExploitBan

Server

Bans the player for an exploit and drops them.

exports.cobalt_core:ExploitBan(playerId, origin)
ParameterTypeOptionalDescription
playerIdintegerNo
originstringNoban reason
Example
exports.cobalt_core:ExploitBan(source, 'cobalt_banking:server:withdraw')

Ban

Server

Bans an online player by the chosen identifiers, which IsPlayerBanned then matches on connect. Doesn't drop them.

exports.cobalt_core:Ban(playerId, options)
ParameterTypeOptionalDescription
playerIdintegerNo
optionsBanOptionsNo
ReturnsDescription
integer?banId nil when the player has none of the chosen identifiers
Example
local banId = exports.cobalt_core:Ban(
    source,
    { reason = 'Parking in a red zone', bannedBy = 'bannedBy' }
)

Unban

Server

Lifts bans matching a ban id or a license, Discord or Steam identifier.

exports.cobalt_core:Unban(term, expiresBefore)
ParameterTypeOptionalDescription
termstringNo
expiresBeforeintegerYeslifts only bans that end before this unix time. Pass the permanent-ban time to leave permanent bans in place
ReturnsDescription
integerremoved
Example
local removed = exports.cobalt_core:Unban('term', 1)

On this page