DRX MDT
ESX​
server/bridge/framework/license
if GetResourceState('bcs_licensemanager') ~= 'started' then return end
Licence = {
Licences = { -- These are the standard licences, if you've got more on your server, then simply add them here, for them to show in the MDT
{ value = "driver_truck", label = "Commercial Drivers License", enabled = true, grant = true, revoke = true },
{ value = "driver_car", label = "Drivers License", enabled = true, grant = true, revoke = true },
{ value = "driver_bike", label = "Motorcycle License", enabled = true, grant = true, revoke = true },
{ value = "weapon", label = "Weapon Licence", enabled = true, grant = true, revoke = true },
{ value = "dmv", label = "Driving Permit", enabled = true, grant = true, revoke = false }
},
---Get all licences for a player
---@param stateid string The stateid of the player
getLicences = function(stateid)
local query = [[
SELECT
CONCAT(
'{',
GROUP_CONCAT(
JSON_QUOTE(l.license),
': ',
CASE WHEN l.license IS NOT NULL THEN 'true' ELSE 'false' END SEPARATOR ', '
),
'}'
) AS licences
FROM
`drx_mdt_player_link` player_link
JOIN users p ON player_link.`identifier` = p.identifier
CROSS JOIN licenses l
WHERE
player_link.`stateid` = ?
AND l.owner = p.identifier
]]
return MySQL.single.await(query, { stateid })
end,
---@param identifier string The player framework identifier
---@param type string The licence type
---@param licence string The licence to manage
---@param executor number The player id who executed the action
manageLicence = function(identifier, type, licence, executor)
if type == 'revoke' then
MySQL.update.await('DELETE FROM licenses WHERE license = ? AND owner = ?', { licence, identifier })
else
local xPlayer = ESX.GetPlayerFromIdentifier(identifier)
if xPlayer then
TriggerClientEvent('LicenseManager:addLicense', xPlayer.source, licence, 'police')
else
ESX.ShowNotification("Citizen is offline")
end
end
end,
}
QB Core​
server/bridge/framework/license
if GetResourceState('bcs_licensemanager') ~= 'started' then return end
Licence = {
Licences = { -- These are the standard licences, if you've got more on your server, then simply add them here, for them to show in the MDT
{ value = "driver_truck", label = "Commercial Drivers License", enabled = true, grant = true, revoke = true },
{ value = "driver_car", label = "Drivers License", enabled = true, grant = true, revoke = true },
{ value = "driver_bike", label = "Motorcycle License", enabled = true, grant = true, revoke = true },
{ value = "weapon", label = "Weapon Licence", enabled = true, grant = true, revoke = true },
{ value = "dmv", label = "Driving Permit", enabled = true, grant = true, revoke = false }
},
---Get all licences for a player
---@param stateid string The stateid of the player
getLicences = function(stateid)
local query = [[
SELECT
CONCAT(
'{',
GROUP_CONCAT(
JSON_QUOTE(l.license),
': ',
CASE WHEN l.license IS NOT NULL THEN 'true' ELSE 'false' END SEPARATOR ', '
),
'}'
) AS licences
FROM
`drx_mdt_player_link` player_link
JOIN players p ON player_link.`identifier` = p.citizenid
CROSS JOIN licenses l
WHERE
player_link.`stateid` = ?
AND l.owner = p.citizenid
]]
return MySQL.single.await(query, { stateid })
end,
---@param identifier string The player framework identifier
---@param type string The licence type
---@param licence string The licence to manage
---@param executor number The player id who executed the action
manageLicence = function(identifier, type, licence, executor)
if type == 'revoke' then
MySQL.update.await('DELETE FROM licenses WHERE license = ? AND owner = ?', { licence, identifier })
else
local xPlayer = QBCore.Functions.GetPlayerByCitizenId(identifier)
if xPlayer then
TriggerClientEvent('LicenseManager:addLicense', xPlayer.source, licence, 'police')
else
TriggerClientEvent('QBCore:Notify', executor, "Citizen is offline", "error", 4000)
end
end
end,
}