Skip to main content

License Manager

Dependencies

Installation

  1. Import sql file licensemanager.sql
  2. Put bcs_licensemanager inside your resources
  3. Ensure/start in your server.cfg
  4. Configure the config.lua to your liking
  5. Optionally if you want to use licenses as items you can take example from license_items.sql For QBCore users may want to add these examples in your shared/items.lua
    qb-core/shared/items.lua
    ['identification']               = {['name'] = 'identification',                ['label'] = 'ID Card',                  ['weight'] = 0,         ['type'] = 'item',      ['image'] = 'id_card.png',              ['unique'] = true,      ['useable'] = true,     ['shouldClose'] = false,   ['combinable'] = nil,   ['description'] = 'A card containing all your information to identify yourself'},
    ['weapon'] = {['name'] = 'weapon', ['label'] = 'Weapon License', ['weight'] = 0, ['type'] = 'item', ['image'] = 'weapon_license.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'A card containing all your information to identify yourself'},
    ['dmv'] = {['name'] = 'dmv', ['label'] = 'Drivers License', ['weight'] = 0, ['type'] = 'item', ['image'] = 'driver_license.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'A card containing all your information to identify yourself'},
    ['driver_car'] = {['name'] = 'driver_car', ['label'] = 'Car License', ['weight'] = 0, ['type'] = 'item', ['image'] = 'driver_license.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'Permit to show you can drive a vehicle'},
    ['driver_truck'] = {['name'] = 'driver_truck', ['label'] = 'Truck License', ['weight'] = 0, ['type'] = 'item', ['image'] = 'driver_license.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'Permit to show you can drive a vehicle'},
    ['driver_bike'] = {['name'] = 'driver_bike', ['label'] = 'Truck License', ['weight'] = 0, ['type'] = 'item', ['image'] = 'driver_license.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'Permit to show you can drive a vehicle'},
  6. If you have esx_license still in your resources folder, remove them as it will autostart as dependencies. This script will replace esx_license.

For ox_inventory users

For ox_inventory compability with licensemanager go to ox_inventory/modules/mysql/server.lua Replace

ox_inventory/modules/mysql/server.lua
function db.selectLicense(name, owner)
return MySQL.scalar.await('SELECT 1 FROM user_licenses WHERE type = ? AND owner = ?', { name, owner })
end

With

ox_inventory/modules/mysql/server.lua
function db.selectLicense(name, owner)
return MySQL.scalar.await('SELECT 1 FROM licenses WHERE type = ? AND owner = ?', { name, owner })
end

Further installation for ox_inventory here.

Converting from esx_license

Data removal

Enabling this will remove the old data from user_licenses table to the new licenses table. Make sure to make backup of user_licenses if you want to be safe.

If you want to convert the old data of user_licenses you can use Config.ConvertMode = true. You also need to rename es_extended to your database name in bcs_licensemanager/server/convert.lua

bcs_licensemanager/server/convert.lua
SELECT * FROM information_schema.tables WHERE table_schema = 'es_extended' AND table_name = 'old_licenses' LIMIT 1

This will convert the data once the user logs in. It will delete the data from user_licenses for that user and make a new one in licenses table. This ConvertMode will also rename the table of licenses to old_licenses and create a new table of licenses.

Adding images

You can add more images for licenses in the html/images folder. It is also images for background of license managers.

Adding more locations

You can add more locations for managing the license or for the license shop in config/manager.lua.

There are two types of manager locations, shop and job.

To create a shop manager use this template:

   shopname = { -- This is an example of a shop type
type = 'shop', -- type either shop or job this is for non-qtarget server
ped = "s_m_y_hwaycop_01", -- if you use ped
coord = {
vector4(383.3286, -1612.733, 29.29193, 225.1938),
-- vector4(383.3286, -1612.733, 29.29193, 225.1938) -- you can use multiple locations
},
target = { -- if you are using qtarget and the type is shop
{
event = "LicenseManager:openLicenseShop",
icon = "fas fa-box-circle-check",
label = "License Request",
name = 'shopname',
}
}
},

To create a job manager use this template:

    managername = {
type = 'job',
job = {
['ambulance'] = 0,
},
ped = "s_m_m_paramedic_01",
background = 'lsfd',
coord = {
vector4(340.7231, -590.1428, 43.28407, 76.19474),
-- vector4(450.2244, -978.7199, 30.68951, 261.2998),
-- vector4(450.2244, -978.7199, 30.68951, 261.2998)
},
options = {
creation = true,
management = true,
history = true,
},
target = {
{
event = "LicenseManager:openManagerMenu",
icon = "fas fa-box-circle-check",
label = "Manage Licenses",
name = 'managername',
background = 'lsfd',
job = {
['ambulance'] = 0,
},
},
}
},

Adding Licenses

You can add your own licenses in the config/licenses.lua. This is the template for adding licenses

    licensename = {
id_length = 8, -- The ID length generated e.g. 51286293
label = "Car Driving License", -- Label can be anything
manager = 'dmv', -- must belong to one of Config.Manager list
job = 'police', -- the job that manages the license
validFor = 31, -- expiry date
price = 2500, -- The price of the license on creation
lostPrice = 1000 -- the price when retrieving lost license (item)
},

Backwards Compability with esx_license

  • 'esx_license:removeLicense' (server event)
  • 'esx_license:getLicense', function(table) (client & server callback)
  • 'esx_license:getLicenses', function(table) (client & server callback)
  • 'esx_license:checkLicense', function(boolean) (client & server callback)
  • 'esx_license:getLicensesList', function(table) (client & server callback)

Troubleshooting

The mugshot/photo does not appear in the card?

Please follow the guide in installing the mugshot. Make sure you are using the correct screenshot-basic from project-error. Don't forget to create the Imgur API and paste the client ID to 'mugshot/client.js'.