Licenses
cobalt_core exports: licenses.
| Export | Side | What it does |
|---|---|---|
GetLicenseTypes | Client, Server | The licence types from licenses in config/shared.lua, by key. |
HasLicense | Server | False for an unknown type or character. |
GetLicenseRecords | Server | Every licence type's record for the character: whether it is held, who granted it and when, when it was revoked, and its points. |
GrantLicense | Server | Grants a licence, records when and by whom in metadata.licenceGrants, clears its revocation and points, saves an offline character, and fires cobalt_core:server:licenseChanged(citizenid, key, true, source?). |
RevokeLicense | Server | Revokes a licence and records when in metadata.licenceRevoked, saving an offline character, and fires cobalt_core:server:licenseChanged(citizenid, key, false, source?). |
AddLicensePoints | Server | Adds points to a held licence whose type has a pointsLimit, and revokes it once the total reaches that limit, firing licenseChanged. |
CardMetadata | Server | The metadata for a new ID or licence card item, from the player's loaded character and dated today. |
UseCard | Server | The id_card, driver_license and weapon_license items' server export. |
GetLicenseTypes
ClientThe licence types from licenses in config/shared.lua, by key. The ID card is not one.
exports.cobalt_core:GetLicenseTypes()| Returns | Description |
|---|---|
table<string, LicenseType> |
local licenseTypes = exports.cobalt_core:GetLicenseTypes()Server
The licence types from licenses in config/shared.lua, by key. The ID card is not one.
exports.cobalt_core:GetLicenseTypes()| Returns | Description |
|---|---|
table<string, LicenseType> |
local licenseTypes = exports.cobalt_core:GetLicenseTypes()HasLicense
ServerFalse for an unknown type or character.
exports.cobalt_core:HasLicense(target, key)| Parameter | Type | Optional | Description |
|---|---|---|---|
target | integer | string | No | server id or citizenid |
key | string | No |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_core:HasLicense(source, 'driver')GetLicenseRecords
ServerEvery licence type's record for the character: whether it is held, who granted it and when, when it was revoked, and its points. Nil when the character doesn't exist.
exports.cobalt_core:GetLicenseRecords(target)| Parameter | Type | Optional | Description |
|---|---|---|---|
target | integer | string | No | server id or citizenid |
| Returns | Description |
|---|---|
table<string, LicenseRecord>? |
local licenseRecords = exports.cobalt_core:GetLicenseRecords(source)GrantLicense
ServerGrants a licence, records when and by whom in metadata.licenceGrants, clears its revocation and points, saves an offline character, and fires cobalt_core:server:licenseChanged(citizenid, key, true, source?). False when the type is unknown, the character doesn't exist or already holds it.
exports.cobalt_core:GrantLicense(target, key, issuer)| Parameter | Type | Optional | Description |
|---|---|---|---|
target | integer | string | No | server id or citizenid |
key | string | No | |
issuer | string | Yes | shown on City Hall's card counter, such as LSPD or the DMV |
| Returns | Description |
|---|---|
boolean | changed |
local changed = exports.cobalt_core:GrantLicense(source, 'driver', 'ABC12345')RevokeLicense
ServerRevokes a licence and records when in metadata.licenceRevoked, saving an offline character, and fires cobalt_core:server:licenseChanged(citizenid, key, false, source?). False when the type is unknown, the character doesn't exist or doesn't hold it.
exports.cobalt_core:RevokeLicense(target, key)| Parameter | Type | Optional | Description |
|---|---|---|---|
target | integer | string | No | server id or citizenid |
key | string | No |
| Returns | Description |
|---|---|
boolean | changed |
local changed = exports.cobalt_core:RevokeLicense(source, 'driver')AddLicensePoints
ServerAdds points to a held licence whose type has a pointsLimit, and revokes it once the total reaches that limit, firing licenseChanged. Returns nil and false when the type has no limit, the amount isn't positive, or the character doesn't hold it.
exports.cobalt_core:AddLicensePoints(target, key, amount)| Parameter | Type | Optional | Description |
|---|---|---|---|
target | integer | string | No | server id or citizenid |
key | string | No | |
amount | integer | No |
| Returns | Description |
|---|---|
integer? | total |
boolean | revoked |
local total, revoked = exports.cobalt_core:AddLicensePoints(source, 'driver', 100)CardMetadata
ServerThe metadata for a new ID or licence card item, from the player's loaded character and dated today. Nil when the player has no character loaded.
exports.cobalt_core:CardMetadata(source, key)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No | |
key | string | Yes | the licence key for a licence card, such as driver or weapon; omit it for an ID card |
| Returns | Description |
|---|---|
CardItemMetadata? |
local itemMetadata = exports.cobalt_core:CardMetadata(source, 'driver')UseCard
ServerThe id_card, driver_license and weapon_license items' server export. On usedItem it shows the card to its holder and, when idCard.showNearby is set, to every player within idCard.nearbyDistance meters in the holder's routing bucket.
exports.cobalt_core:UseCard(event, item, inventory, slot)| Parameter | Type | Optional | Description |
|---|---|---|---|
event | 'usingItem' | 'usedItem' | No | |
item | table | No | |
inventory | table | No | |
slot | table | No |
exports.cobalt_core:UseCard(
'usingItem',
{ name = 'id_card' },
{ id = 'ABC12345', source = source },
{ id = '5f3c9a1e' }
)