For the complete documentation index, see llms.txt. This page is also available as Markdown.

LGMods Licensing

LGMods Licensing

UK-style driving licence system for FiveM. Players apply at a front desk, receive a physical inventory item, and police can manage applications, points, bans, and revocations.


Features

  • Front desk offices (blips, optional NPCs, interact key) to apply for licences

  • Licence categories with auto-issue or police approval

  • Physical inventory item with metadata (where the inventory supports it)

  • Police management UI: applications, search, points, ban, revoke, add category

  • Penalty points with history and auto-expiry

  • DVLA-style licence number generation

  • ESX / QBCore frameworks

  • ox_inventory / qs-inventory / qb-inventory / ESX inventory


Requirements

Dependency
Required

ESX (es_extended) or QBCore (qb-core)

Yes (one of them)

Matching inventory for Config.InventorySystem

Yes

ox_lib

Optional (notifications / menus when enabled)


Installation

  1. Place the resource in your server resources folder as LGMods_Licensing.

  2. Ensure start order: framework → inventory → oxmysql → this resource.

  1. Open config.lua and set:

    • Config.Framework - 'auto', 'esx', or 'qbcore'

    • Config.InventorySystem - must match the inventory you actually use

  2. Import sql/install.sql into your database (or let the script auto-create tables on start).

  3. Register the item drivers_license in your inventory - see Inventory item setup. This is the most common cause of “exports / item not working”.

  4. Set front desk coords, police jobs, costs, and categories as needed.

  5. Restart the resource and test with /mylicense and the front desk.

Tables are created automatically on start if missing. Running sql/install.sql manually is still recommended for clean installs.


Configuration overview

All settings live in config.lua.

Framework & inventory

Licence rules

  • Config.License.DefaultType - 'full' or 'provisional'

  • Config.License.MaxPoints - default 12 (licence treated as suspended at this total)

  • Config.License.PointExpiryDays - default 84 (12 weeks)

  • Config.License.Categories - each category has a name and requiresApproval

If requiresApproval = false, the licence / category is issued immediately at the front desk. If true, police must approve the application.

Front desk

  • MinAge - default 17

  • Cost - cash cost (default 45)

  • Locations - coords, heading, blip

  • InteractionKey - default 38 (E)

  • ShowBlips / SpawnNPCs

Police

Add every job name that should access /licenses and police commands.

UI & exports


Inventory item setup

The script does not ship item definitions. You must add them to your inventory / framework yourself. If the item is missing, players can still get a DB licence but will not receive (or cannot use) the physical card.

Metadata the script writes

When a licence item is given, the script attaches:

Field
Description

license_number

Raw licence number

formatted_number

Spaced display form

name

Holder name

dob

Date of birth

type

full or provisional

categories

e.g. A,B

points

Current penalty points

is_valid

Validity flag

description

Short summary string

age

Calculated age (when available)

  • ox_inventory stores this on item.metadata

  • qs-inventory / qb-inventory store this on item.info

  • ESX has no rich metadata - viewing pulls live data from the database


ox_inventory

Set in config:

Add to ox_inventory/data/items.lua (or your items file):

Optional: buttons (view / show)

If your ox_inventory version supports item buttons, you can add:

The resource also listens for ox item-use / right-click events for drivers_license, so using the item should open the licence UI once the item exists.

Server export alternative

If you prefer a server use export on the item:

Both viewLicense and useDriversLicense are provided for inventory wiring.

Add an image as ox_inventory/web/images/drivers_license.png (optional but recommended).


qb-inventory (QBCore)

Set in config:

Add to qb-core/shared/items.lua (or your items shared file):

unique = true and useable = true are important. Metadata is stored in info.

Place drivers_license.png in your inventory images folder (commonly qb-inventory/html/images/).

The script listens for qb-inventory:client:UseItem when the item name is drivers_license.


qs-inventory

Set in config:

Register the item in your qs-inventory items list / database with spawn name:

Example shared-style definition (adjust to your qs-inventory format):

The script listens for qs-inventory:client:UseItem. Metadata is stored in info.

If qs-inventory fails to add the item, the script may fall back to ESX addInventoryItem - the item must still exist in both places if you rely on that fallback.


ESX default inventory

Set in config:

Add the item to your items table (SQL example):

Or via your items management resource - spawn name must still be drivers_license.

If you use a usable-item system that fires esx:useItem, the script will open the licence UI for drivers_license.


Quick checklist (item not working)

  1. Config InventorySystem matches the inventory that is actually running.

  2. Item name is exactly drivers_license.

  3. Resource folder is exactly LGMods_Licensing.

  4. Item is registered and the inventory was restarted after adding it.

  5. Player has space / can carry the item (especially ox_inventory).

  6. For ox: client.export / server.export points at LGMods_Licensing.viewLicense or LGMods_Licensing.useDriversLicense.

  7. For QB/QS: item is useable = true / unique = true.


How the system works

Getting a licence

  1. Go to a configured front desk location and press E (or your interaction key).

  2. Choose licence type and category.

  3. Age and cash are checked (MinAge, Cost).

  4. If the category does not require approval → licence is created and the drivers_license item is given.

  5. If it does require approval → an application is created and police are notified. On approval, the licence/category is granted and the item is given/updated.

Using the item

  • Use the item in inventory to open the licence UI.

  • Show to nearby players (within ~5m where supported).

  • Police can verify against the database.

Validity

A licence is treated as invalid if:

  • It is revoked

  • It is banned (banned_until still in the future)

  • Points are at or above Config.License.MaxPoints (default 12)

Points expire after PointExpiryDays and are cleaned up automatically.


Commands

Everyone

Command
Description

/mylicense

View your own licence status

/licensehelp

Show available commands

Police (jobs in Config.Police.RequiredJobs)

Command
Usage

/licenses

Open police licence management UI

/addpoints

/addpoints [id] [1-12] [reason]

/removepoints

/removepoints [id] [points]

/banlicense

/banlicense [id] [days] [reason]

/unbanlicense

/unbanlicense [id]

/revokelicense

/revokelicense [id] [reason]

/reinstatelicense

/reinstatelicense [id]

/grantlicense

/grantlicense [id] [full|provisional] [category]

[id] is the player’s server ID.


Exports (for other scripts)

For other resources, use the player ID (server source) exports below. Always call them with the resource name:

exports['LGMods_Licensing']:ExportName(...)

These are the exports you should use from other scripts.

GrantLicense

Creates a licence in the database and gives the inventory item.

  • playerId (number) - required

  • licenseType (string) - 'full' or 'provisional' (default 'full')

  • category (string) - e.g. 'B' (default 'B')

Fails if the player already has a licence.

RevokePlayerLicense

BanPlayerLicense

UnbanPlayerLicense

ReinstatePlayerLicense

AddPoints / RemovePoints

HasValidLicense

HasLicense

GetPlayerLicenseStatus

GetLicenseByNumber

GetPlayerPointsHistory

Inventory / item-use exports (server)

Used when wiring inventory items - not usually needed for gameplay scripts.

Inventory helpers (server)

Useful if you need to give/remove/update the physical item yourself:

Export
Purpose

GiveLicenseItem(playerId, licenseData)

Give the item with metadata

RemoveLicenseItem(playerId, licenseNumber)

Remove matching item

UpdateLicenseItemMetadata(playerId, licenseData)

Refresh item metadata

HasLicenseItem(playerId, licenseNumber)

Check if player has the card

RemoveAllLicenseItems(playerId)

Remove all licence items

GetLicenseMetadata(licenseData)

Build metadata table

Example:

Client exports (UI / item)

For ox_inventory item definitions, the usual string is:


Example integrations

Block driving without a valid licence

Add points from another script

Grant a licence from an admin menu


Database

Default tables (names configurable in Config.Database):

  • lgmods_licenses - main licence records (one per citizen)

  • lgmods_license_points - points history

  • lgmods_license_applications - pending / processed applications

SQL file: sql/install.sql.


Troubleshooting

“Exports don’t work”

  1. Resource name is LGMods_Licensing (exact).

  2. Resource is started before the script that calls the export.

  3. You are calling server exports from the server, and client exports from the client.

  4. Config.Exports.EnableAll is true.

  5. Use exports['LGMods_Licensing']:HasValidLicense(source) - not a made-up export name.

“Player got approved but no item”

  1. Item drivers_license is not registered in the inventory.

  2. Wrong Config.InventorySystem.

  3. Inventory inventory is full / cannot carry.

  4. Inventory resource was not restarted after adding the item.

  5. On ESX, confirm the row exists in the items table.

“Using the item does nothing”

  1. ox: missing client.export / server.export, or export string typo.

  2. QB/QS: item not marked useable.

  3. Item name is not exactly drivers_license.

  4. Metadata missing (old/admin-given item without metadata) - try /mylicense or re-grant via /grantlicense / police tools.

“Police commands say no permission”

Add the player’s exact job name to Config.Police.RequiredJobs (e.g. 'police', 'sheriff').

Categories missing in the menu

Any category you add under Config.License.Categories should appear after a resource restart. Make sure the key and name / requiresApproval fields are valid Lua.


Support notes

  • Keep config.lua edits only - that file is listed for escrow ignore.

  • Do not rename the item away from drivers_license unless you are prepared to edit the script itself.

  • Prefer the player-ID exports (GrantLicense, BanPlayerLicense, AddPoints, etc.) for third-party integrations.

Last updated