> For the complete documentation index, see [llms.txt](https://sbscripts.gitbook.io/sb-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sbscripts.gitbook.io/sb-scripts/sb-city-hall/licences.md).

# Licences

Licences are always read from the player's QBCore metadata (`metadata.licences`). Granting or revoking through the exports or commands updates the metadata and saves it to the database straight away.

### Exports

Use the player's server ID or citizen ID as the target. Offline players are edited in the database.

```lua
exports.sbcityhall:RevokeLicense(target, 'driver')            -- ok, message
exports.sbcityhall:RevokeLicense(target, 'weapon', { removeItems = false, notify = false })
exports.sbcityhall:GrantLicense(target, 'weapon')              -- ok, message
exports.sbcityhall:HasLicense(target, 'driver')                -- true or false
exports.sbcityhall:GetLicenses(target)                         -- { driver = true, weapon = false }
```

Revoking also removes matching documents, which are any `Config.Documents` entries with that `license`, unless `Config.Licenses.RemoveItemsOnRevoke = false`. Online players are notified. Revoked licences show as Revoked on the Document Desk and My Record, with a note to contact the police department.

Listen for changes with:

```lua
AddEventHandler('sbcityhall:server:licenseChanged', function(citizenid, license, value) end)
```

### Commands

* `/revokelicense [id] [license]`
* `/grantlicense [id] [license]`

These are for admins and the jobs and grades in `Config.Licenses.Commands`. By default that's police at grade 2 and above, on duty.
