MDT
The mdt here are using is based on distritic mdt.
info
For other mdt, basically use the licenses
table instead of user_licenses
. Use license
instead
of type
for the license type column.
Replace:
mdt/sv_mdt.lua
for i = 1, #changes.licenses_removed do
local license = changes.licenses_removed[i]
MySQL.Async.execute('DELETE FROM `user_licenses` WHERE `type` = @type AND `owner` = @identifier', {
['@type'] = license.type,
['@identifier'] = identifier
})
end
With:
mdt/sv_mdt.lua
for i = 1, #changes.licenses_removed do
local license = changes.licenses_removed[i]
MySQL.Async.execute('DELETE FROM `licenses` WHERE `license` = @type AND `owner` = @identifier', {
['@type'] = license.type,
['@identifier'] = identifier
})
end
Then replace GetLicenses()
function in the sv_mdt.lua
with this:
mdt/sv_mdt.lua
function GetLicenses(identifier, cb)
MySQL.Async.fetchAll('SELECT * FROM licenses WHERE owner = @owner', {
['@owner'] = identifier
}, function(result)
local licenses = {}
local asyncTasks = {}
for i=1, #result, 1 do
local scope = function(type)
table.insert(asyncTasks, function(cb)
TriggerEvent('esx_license:getLicensesList', function(list)
for k,v in pairs(list) do
if v.type == type then
table.insert(licenses, {
type = type,
label = v.label
})
cb()
end
end
end)
end)
end
scope(result[i].license)
end
Async.parallel(asyncTasks, function(results)
if #licenses == 0 then licenses = false end
cb(licenses)
end)
end)
end