Full View config.server.lua
Preview File Updated: v1.0.9 - 11.01.2024
-- ▄▀▄ █▄ █ █ ▀▄▀ █▀ ▄▀▄ █▀▄ ██▀ ▄▀▀ ▀▄▀
-- ▀▄▀ █ ▀█ █▄▄ █ █▀ ▀▄▀ █▀▄ █▄▄ ▄██ █ █
if Config.Core == "ESX" then
RegisterNetEvent('vms_driveschoolv2:sv:loadLicensesWithRestartScript', function()
local src = source
local xPlayer = ESX.GetPlayerFromId(src)
if xPlayer then
TriggerEvent('esx_license:getLicenses', src, function(licenses)
TriggerClientEvent('vms_driveschoolv2:cl:getLicenses', src, licenses)
end)
end
end)
AddEventHandler(Config.PlayerLoaded, function(source)
local src = source
Citizen.Wait(8000)
TriggerEvent('esx_license:getLicenses', src, function(licenses)
TriggerClientEvent('vms_driveschoolv2:cl:getLicenses', src, licenses)
end)
end)
end
-- ▄▀▄ █▀▄ █▀▄ █ █ ▄▀▀ ██▀ █▄ █ ▄▀▀ ██▀
-- █▀█ █▄▀ █▄▀ █▄▄ █ ▀▄▄ █▄▄ █ ▀█ ▄██ █▄▄
RegisterNetEvent('vms_driveschoolv2:sv:addLicense', function(passed, type)
local src = source
if passed then
if Config.Core == "ESX" then
TriggerEvent('esx_license:addLicense', src, type, function()
TriggerEvent('esx_license:getLicenses', src, function(licenses)
TriggerClientEvent('vms_driveschoolv2:cl:getLicenses', src, licenses)
if Config.AddLicenseItem and (type == Config.Licenses.Practical["A"].name or type == Config.Licenses.Practical["B"].name or type == Config.Licenses.Practical["C"].name) then
local xPlayer = ESX.GetPlayerFromId(src)
if xPlayer.getInventoryItem(Config.LicenseItem).count < 1 then
xPlayer.addInventoryItem(Config.LicenseItem, 1)
end
end
TriggerClientEvent('vms_driveschoolv2:notification', src, Config.Translate['success_practical'], 'success')
end)
end)
elseif Config.Core == "QB-Core" then
local Player = QBCore.Functions.GetPlayer(src)
local licenses = Player.PlayerData.metadata['licences']
licenses[type] = true
Player.Functions.SetMetaData('licences', licenses)
if Config.AddLicenseItem and (type == Config.Licenses.Practical["A"].name or type == Config.Licenses.Practical["B"].name or type == Config.Licenses.Practical["C"].name) then
if Player.Functions.GetItemByName(Config.LicenseItem) then
Player.Functions.RemoveItem(Config.LicenseItem, 1)
end
Player.Functions.AddItem(Config.LicenseItem, 1, false, {
firstname = Player.PlayerData.charinfo.firstname,
lastname = Player.PlayerData.charinfo.lastname,
birthdate = Player.PlayerData.charinfo.birthdate,
type = (licenses[Config.Licenses.Practical["A"].name] and "A" or "") .. (licenses[Config.Licenses.Practical["B"].name] and "B" or "") .. (licenses[Config.Licenses.Practical["C"].name] and "C" or "")
})
end
TriggerClientEvent('vms_driveschoolv2:cl:getLicenses', src)
TriggerClientEvent('vms_driveschoolv2:notification', src, Config.Translate['success_practical'], 'success')
end
else
TriggerClientEvent('vms_driveschoolv2:notification', src, Config.Translate['failed_practical'], 'error')
end
end)
Last updated