diff --git a/sonorancad/configuration/forcereg_config.dist.lua b/sonorancad/configuration/forcereg_config.dist.lua index ac36b2b..86c90e2 100644 --- a/sonorancad/configuration/forcereg_config.dist.lua +++ b/sonorancad/configuration/forcereg_config.dist.lua @@ -8,7 +8,7 @@ ]] local config = { enabled = true, - configVersion = "1.0", + configVersion = "1.1", pluginName = "forcereg", -- name your plugin here pluginAuthor = "SonoranCAD", -- author requiresPlugins = {}, -- required plugins for this plugin to work, separated by commas @@ -32,7 +32,19 @@ local config = { verifyMessage = "Type ~r~/verifycad~s~ in chat when finished.", -- What does the user do once they log in? - instructionalMessage = "Head over to settings once logged in, and enter the ~g~API ID~w~ given below in the API ID field." + instructionalMessage = "Head over to settings once logged in, and enter the ~g~API ID~w~ given below in the API ID field.", + + -- Would you like to only show this message to players who are whitelisted? + whitelist = { + enabled = false, + mode = "qb-core", -- qb-core, esx, ace + aces = { -- ace permissions will see the message + "forcereg.whitelist" + }, + jobs = { -- QB or ESX jobs will see the message + "police" + } + } } if config.enabled then diff --git a/sonorancad/configuration/locations_config.dist.lua b/sonorancad/configuration/locations_config.dist.lua index d78aaeb..ee1e7b4 100644 --- a/sonorancad/configuration/locations_config.dist.lua +++ b/sonorancad/configuration/locations_config.dist.lua @@ -9,7 +9,7 @@ local config = { enabled = true, pluginName = "locations", -- name your plugin here pluginAuthor = "SonoranCAD", -- author - pluginVersion = "1.0", -- version of your plugin + configVersion = "1.1", -- version of your plugin requiresPlugins = {}, -- put your configuration options below checkTime = 5000, -- how frequently to send locations to the server diff --git a/sonorancad/core/plugin_loader.lua b/sonorancad/core/plugin_loader.lua index b990ea3..c03bbfb 100644 --- a/sonorancad/core/plugin_loader.lua +++ b/sonorancad/core/plugin_loader.lua @@ -34,11 +34,11 @@ function CheckForPluginUpdate(name) warnLog(("Failed to get a valid response for %s. Skipping."):format(k)) debugLog(("Raw output for %s: %s"):format(k, data)) end - elseif remote.submoduleConfigs[name].version ~= nil and plugin.configVersion ~= nil then + elseif (remote.submoduleConfigs[name].version ~= nil and plugin.configVersion ~= nil) then local configCompare = compareVersions(remote.submoduleConfigs[name].version, plugin.configVersion) if configCompare.result and not Config.debugMode then if plugin.enabled then - errorLog(("Submodule Updater: %s has a new configuration version. You should look at the template configuration file (%s_config.dist.lua) and update your configuration before using this submodule."):format(name, name)) + errorLog(("Submodule Updater: %s has a new configuration version. You should look at the template configuration file (%s_config.dist.lua) and update your configuration before using this submodule. Guide: https://sonoran.link/config-update"):format(name, name)) Config.plugins[name].enabled = false Config.plugins[name].disableReason = "outdated config file" end @@ -56,6 +56,30 @@ function CheckForPluginUpdate(name) debugLog(("Submodule %s configuration file is up to date. Backup saved."):format(name)) end end + elseif name == 'locations' then + if (remote.submoduleConfigs[name].version ~= nil and plugin.pluginVersion ~= nil) then + local configCompare = compareVersions(remote.submoduleConfigs[name].version, plugin.pluginVersion) + if configCompare.result and not Config.debugMode then + if plugin.enabled then + errorLog(("Submodule Updater: %s has a new configuration version. You should look at the template configuration file (%s_config.dist.lua) and update your configuration before using this submodule."):format(name, name)) + Config.plugins[name].enabled = false + Config.plugins[name].disableReason = "outdated config file" + end + else + debugLog(("Submodule %s has the same configuration version."):format(name)) + local distConfig = LoadResourceFile(GetCurrentResourceName(), ("/configuration/%s_config.dist.lua"):format(name)) + local normalConfig = LoadResourceFile(GetCurrentResourceName(), ("/configuration/%s_config.lua"):format(name)) + if distConfig and normalConfig then + local filePath = ("%s/configuration/config-backup"):format(GetResourcePath(GetCurrentResourceName())) + exports['sonorancad']:CreateFolderIfNotExisting(filePath) + local backupFile = io.open(("%s/configuration/config-backup/%s_config.lua"):format(GetResourcePath(GetCurrentResourceName()), name), "w") + backupFile:write(distConfig) + backupFile:close() + os.remove(("%s/configuration/%s_config.dist.lua"):format(GetResourcePath(GetCurrentResourceName()), name)) + debugLog(("Submodule %s configuration file is up to date. Backup saved."):format(name)) + end + end + end end elseif plugin.enabled then warnLog(("Failed to check submodule config updates for %s: %s %s"):format(name, code, data)) diff --git a/sonorancad/core/server.lua b/sonorancad/core/server.lua index cf1c8a7..581ad51 100644 --- a/sonorancad/core/server.lua +++ b/sonorancad/core/server.lua @@ -126,6 +126,9 @@ function performApiRequest(postData, type, cb) else return warnLog(("API request failed: endpoint %s is not registered. Use the registerApiType function to register this endpoint with the appropriate type."):format(type)) end + if not cb then + cb = function() end + end local url = "" if endpoint == "support" then apiUrl = "https://api.sonoransoftware.com/" diff --git a/sonorancad/fxmanifest.lua b/sonorancad/fxmanifest.lua index eeda55a..5bc639f 100644 --- a/sonorancad/fxmanifest.lua +++ b/sonorancad/fxmanifest.lua @@ -3,7 +3,7 @@ games {'gta5'} author 'Sonoran CAD' description 'Sonoran CAD FiveM Integration' -version '3.0.5' +version '3.0.6' server_scripts { 'core/http.js' @@ -18,7 +18,7 @@ server_scripts { ,'core/unittracking.lua' ,'core/updater.lua' ,'core/apicheck.lua' - ,'configuration/**/*_config.lua' + ,'configuration/*_config.lua' ,'core/plugin_loader.lua' ,'submodules/**/sv_*.lua' ,'submodules/**/sv_*.js' @@ -30,7 +30,7 @@ client_scripts { ,'core/shared_functions.lua' ,'core/client.lua' ,'core/lighting.lua' - ,'configuration/**/*_config.lua' + ,'configuration/*_config.lua' ,'submodules/**/cl_*.lua' ,'submodules/**/cl_*.js' } diff --git a/sonorancad/submodules/forcereg/sv_forcereg.lua b/sonorancad/submodules/forcereg/sv_forcereg.lua index 45eaee4..906fce3 100644 --- a/sonorancad/submodules/forcereg/sv_forcereg.lua +++ b/sonorancad/submodules/forcereg/sv_forcereg.lua @@ -35,7 +35,7 @@ if pluginConfig.enabled then end) end - + RegisterNetEvent("SonoranCAD::forcereg:CheckPlayer") AddEventHandler("SonoranCAD::forcereg:CheckPlayer", function() @@ -43,9 +43,61 @@ if pluginConfig.enabled then end) AddEventHandler("SonoranCAD::apicheck:CheckPlayerLinkedResponse", function(player, identifier, exists) - TriggerClientEvent("SonoranCAD::forcereg:PlayerReg", player, identifier, exists) + if not pluginConfig.whitelist then + pluginConfig.whitelist = { + enabled = false, + mode = "qb-core", -- qb-core, esx, ace + aces = { -- ace permissions will see the message + "forcereg.whitelist" + }, + jobs = { -- QB or ESX jobs will see the message + "police" + } + } + print("Forcereg: Whitelist configuration not found, using defaults. Please update your configuration.") + end + if pluginConfig.whitelist.enabled then + if pluginConfig.whitelist.mode == "ace" then + local aceAllowed = false + for i=1, #pluginConfig.whitelist.aces do + if IsPlayerAceAllowed(player, pluginConfig.whitelist.aces[i]) then + aceAllowed = true + break + end + end + if aceAllowed then + TriggerClientEvent("SonoranCAD::forcereg:PlayerReg", player, identifier, exists) + end + elseif pluginConfig.whitelist.mode == "qb-core" then + local QBCore = exports['qb-core']:GetCoreObject() + local Player = QBCore.Functions.GetPlayer(player) + local job = Player.PlayerData.job.name + if job ~= nil then + for i=1, #pluginConfig.whitelist.jobs do + if job == pluginConfig.whitelist.jobs[i] then + TriggerClientEvent("SonoranCAD::forcereg:PlayerReg", player, identifier, exists) + break + end + end + end + elseif pluginConfig.whitelist.mode == "esx" then + local ESX = exports['es_extended']:getSharedObject() + local xPlayer = ESX.GetPlayerFromId(player) + local job = xPlayer.job.name + if job ~= nil then + for i=1, #pluginConfig.whitelist.jobs do + if job == pluginConfig.whitelist.jobs[i] then + TriggerClientEvent("SonoranCAD::forcereg:PlayerReg", player, identifier, exists) + break + end + end + end + end + else + TriggerClientEvent("SonoranCAD::forcereg:PlayerReg", player, identifier, exists) + end end) - + end \ No newline at end of file diff --git a/sonorancad/version.json b/sonorancad/version.json index 21bb780..9a283f5 100644 --- a/sonorancad/version.json +++ b/sonorancad/version.json @@ -1,5 +1,5 @@ { - "resource": "3.0.5", + "resource": "3.0.6", "testedFxServerVersion": "5932", "submoduleConfigs": { "callcommands": { @@ -37,7 +37,7 @@ "requiresPlugins": [] }, "forcereg": { - "version": "1.0", + "version": "1.1", "requiresPlugins": [] }, "frameworksupport": { @@ -49,7 +49,7 @@ "requiresPlugins": [] }, "locations": { - "version": "1.0", + "version": "1.1", "requiresPlugins": [] }, "lookups": { @@ -99,7 +99,7 @@ "requiresPlugins": [] }, "wraithv2": { - "version": "1.5", + "version": "1.6", "requiresPlugins": [ { "name": "lookups",