License Manager
Dependencies
- oxmysql (opens in a new tab) (recommended) / mysql-async (opens in a new tab)
- screenshot-basic (opens in a new tab)
Optional
- mugshot (opens in a new tab)
- qtarget (opens in a new tab) / ox_target (opens in a new tab) / qb-target (opens in a new tab)
Installation
Import sql
Import sql file licensemanager.sql
Put bcs_licensemanager
Put bcs_licensemanager
inside your resources
Ensure/start
Ensure/start in your server.cfg
Configure
Configure the config.lua to your liking
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
['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'},
ESX LICENSE
If you have esx_license still in your resources folder, remove them as it will autostart as dependencies. This script will replace esx_license.
Discord Screenshot
If you want to use Discord Screenshot as the card picture instead of using mugshot
resource, copy and paste setr SCREENSHOT_WEBHOOK your_dsc_webhook
to your server.cfg. Then change the your_dsc_webhook
to your discord webhook.
Screenshot Upload Server
If you want to use the upload service to get high quality image you can choose one. Please see this to set it up.
For ox_inventory users
Further installation for ox_inventory here.
Converting from esx_license
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
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
disableBuy = false, -- set to true if you want the shop to only be for renewing and retrieving lost license
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)
},
Adding Badges
You can add your own badge in the config/badges.lua
Here is a template for it
-- If you use an item, by default you need to add the item name as `lspd_badge`
{
department = "LSPD",
ped = 's_m_y_hwaycop_01',
coords = {
vec4(390.5062, -1006.0359, 29.6896, 174.7202)
},
color = '#3693ed',
permissions = {
viewManager = {
['police'] = 2
['sheriff'] = 3
},
creator = {
['sheriff'] = 3
['police'] = 2
},
edit = {
['police'] = 3,
},
delete = {
['police'] = 3
}
}
}
Badge Image
You can also add the badge logo image in the html/images
for example in this case LPSDbadge.png
If you want to add another department for example SSPD
- add the item as
sspd_badge
- the image
SSPDbadge.png
Badge Background
We have provided the template within the badge.psd
file. This will be your background image for the
badge, an example is already provided in the html/images
folder called LSPDbackground.png
.
The format of the image is [departmentname]background.png
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?
Do follow step 7 for discord screenshot webhook. If you want to use mugshot instead please follow the guide in installing the mugshot. Make sure you are using the correct screenshot-basic from TasoOneAsia. Don't forget to create the Imgur API and paste the client ID to 'mugshot/client.js'.