Permissions and bans
cobalt_core exports: permissions and bans.
| Export | Side | What it does |
|---|---|---|
HasPermission | Server | Whether the player holds the rank, or any of the ranks listed. |
GetPermission | Server | Every rank the player holds. |
AddPermission | Server | Gives the player a rank (staff, admin or owner) for this session. |
RemovePermission | Server | Takes a rank from the player for this session. |
IsWhitelisted | Server | Whether the player may join while the whitelist is on. |
IsOptin | Server | Whether an admin has opted in to admin reports. |
ToggleOptin | Server | Flips an admin's opt-in to admin reports. |
IsPlayerBanned | Server | Whether a ban matches the player by license, Discord or Steam, with the kick message. |
IsLicenseInUse | Server | Whether a connected player already has that Rockstar license. |
Kick | Server | Drops the player with a reason. |
ExploitBan | Server | Bans the player for an exploit and drops them. |
Ban | Server | Bans an online player by the chosen identifiers, which IsPlayerBanned then matches on connect. |
Unban | Server | Lifts bans matching a ban id or a license, Discord or Steam identifier. |
HasPermission
ServerWhether the player holds the rank, or any of the ranks listed. Higher ranks pass too.
exports.cobalt_core:HasPermission(source, permission)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No | |
permission | string | string[] | No |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_core:HasPermission(source, 'manage_employees')GetPermission
ServerEvery rank the player holds.
exports.cobalt_core:GetPermission(source)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No |
| Returns | Description |
|---|---|
table<string, boolean> |
local permission = exports.cobalt_core:GetPermission(source)AddPermission
ServerGives the player a rank (staff, admin or owner) for this session.
exports.cobalt_core:AddPermission(source, permission)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No | |
permission | string | No |
exports.cobalt_core:AddPermission(source, 'manage_employees')RemovePermission
ServerTakes a rank from the player for this session.
exports.cobalt_core:RemovePermission(source, permission)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No | |
permission | string | No |
exports.cobalt_core:RemovePermission(source, 'manage_employees')IsWhitelisted
ServerWhether the player may join while the whitelist is on. Always true when it is off.
exports.cobalt_core:IsWhitelisted(source)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_core:IsWhitelisted(source)IsOptin
ServerWhether an admin has opted in to admin reports. False for non-admins.
exports.cobalt_core:IsOptin(source)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_core:IsOptin(source)ToggleOptin
ServerFlips an admin's opt-in to admin reports.
exports.cobalt_core:ToggleOptin(source)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No |
exports.cobalt_core:ToggleOptin(source)IsPlayerBanned
ServerWhether a ban matches the player by license, Discord or Steam, with the kick message. Removes expired bans first.
exports.cobalt_core:IsPlayerBanned(source)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No |
| Returns | Description |
|---|---|
boolean | banned |
string? | message |
local banned, message = exports.cobalt_core:IsPlayerBanned(source)IsLicenseInUse
ServerWhether a connected player already has that Rockstar license.
exports.cobalt_core:IsLicenseInUse(license)| Parameter | Type | Optional | Description |
|---|---|---|---|
license | string | No |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_core:IsLicenseInUse('license:0123456789abcdef')Kick
ServerDrops the player with a reason. During connection, pass setKickReason and deferrals from playerConnecting.
exports.cobalt_core:Kick(source, reason, setKickReason, deferrals)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No | |
reason | string | No | |
setKickReason | function | Yes | |
deferrals | table | Yes |
exports.cobalt_core:Kick(source, 'Parking in a red zone', function(reason) end, deferrals)ExploitBan
ServerBans the player for an exploit and drops them.
exports.cobalt_core:ExploitBan(playerId, origin)| Parameter | Type | Optional | Description |
|---|---|---|---|
playerId | integer | No | |
origin | string | No | ban reason |
exports.cobalt_core:ExploitBan(source, 'cobalt_banking:server:withdraw')Ban
ServerBans an online player by the chosen identifiers, which IsPlayerBanned then matches on connect. Doesn't drop them.
exports.cobalt_core:Ban(playerId, options)| Parameter | Type | Optional | Description |
|---|---|---|---|
playerId | integer | No | |
options | BanOptions | No |
| Returns | Description |
|---|---|
integer? | banId nil when the player has none of the chosen identifiers |
local banId = exports.cobalt_core:Ban(
source,
{ reason = 'Parking in a red zone', bannedBy = 'bannedBy' }
)Unban
ServerLifts bans matching a ban id or a license, Discord or Steam identifier.
exports.cobalt_core:Unban(term, expiresBefore)| Parameter | Type | Optional | Description |
|---|---|---|---|
term | string | No | |
expiresBefore | integer | Yes | lifts only bans that end before this unix time. Pass the permanent-ban time to leave permanent bans in place |
| Returns | Description |
|---|---|
integer | removed |
local removed = exports.cobalt_core:Unban('term', 1)