> For the complete documentation index, see [llms.txt](https://docs.kojascripts.eu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kojascripts.eu/koja-lib/api-reference/server-api/licenses.md).

# Licenses

Check whether a player holds a specific driving or skill license.

## HasLicense (Client)

The license check is initiated from the client using a server callback:

```lua
KOJA.Client.HasLicense(licenseName, callback)
```

| Parameter     | Type                        | Description                  |
| ------------- | --------------------------- | ---------------------------- |
| `licenseName` | `string`                    | Name of the license to check |
| `callback`    | `function(result: boolean)` | Called with the result       |

**Example**

```lua
KOJA.Client.HasLicense('driver', function(has)
    if not has then
        print('No driver license')
    end
end)
```

## License Names

| Framework | License Examples                                  |
| --------- | ------------------------------------------------- |
| ESX       | `"driver"`, `"weapon"`, `"pilot"`, `"boat"`       |
| QBCore    | `"driver"`, `"weapon"`, `"hunting"`, `"business"` |

The name you pass must match what is stored in the framework's database.

## How it Works

Internally, `KOJA.Client.HasLicense` triggers the server callback `koja-lib:HasLicense`. The server then queries the framework:

* **ESX** — triggers the `esx_license:checkLicense` event
* **QBCore** — reads `Player.PlayerData.metadata.licenses`
* **Custom** — returns `false` by default (implement in `CustomFramework.Server`)

## Implementing License Check for Custom Framework

In `editable/custom/framework_server.lua`, the license check is handled by the `koja-lib:HasLicense` callback. If you use a custom framework you can override this by registering the callback yourself before koja-lib loads, or by modifying `server/modules/licenses.lua`.

Example for a custom framework:

```lua
-- In your own server script
KOJA.Server.RegisterServerCallback('koja-lib:HasLicense', function(source, licenseName, cb)
    local player = MyFramework.GetPlayer(source)
    if not player then return cb(false) end
    cb(player.hasLicense(licenseName))
end)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kojascripts.eu/koja-lib/api-reference/server-api/licenses.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
