# 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)
```

## Related pages

- [Police](/koja-lib/api-reference/server-api/police) — Functions for checking how many police officers are online.
- [Callbacks](/koja-lib/api-reference/server-api/callbacks) — The callback system allows server scripts to handle requests from clients and vice versa.
- [Money](/koja-lib/api-reference/server-api/money) — Functions for reading and modifying a player's money on the server.
- [Inventory](/koja-lib/api-reference/server-api/inventory) — Server-side inventory functions.
- [Notifications](/koja-lib/api-reference/server-api/notifications) — Send notifications to a player from the server side.
- [Player](/koja-lib/api-reference/server-api/player) — Functions for reading player information on the server.
- [Server API](/koja-lib/api-reference/server-api) — back to the section overview
