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:
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
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:checkLicenseevent - QBCore — reads
Player.PlayerData.metadata.licenses - Custom — returns
falseby default (implement inCustomFramework.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:
-- 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 — Functions for checking how many police officers are online.
- Callbacks — The callback system allows server scripts to handle requests from clients and vice versa.
- Money — Functions for reading and modifying a player's money on the server.
- Inventory — Server-side inventory functions.
- Notifications — Send notifications to a player from the server side.
- Player — Functions for reading player information on the server.
- Server API — back to the section overview