Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.6 #16

Merged
merged 10 commits into from
Dec 18, 2024
16 changes: 14 additions & 2 deletions sonorancad/configuration/forcereg_config.dist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sonorancad/configuration/locations_config.dist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 26 additions & 2 deletions sonorancad/core/plugin_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions sonorancad/core/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
6 changes: 3 additions & 3 deletions sonorancad/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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'
}
Expand Down
58 changes: 55 additions & 3 deletions sonorancad/submodules/forcereg/sv_forcereg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,69 @@ if pluginConfig.enabled then
end)
end



RegisterNetEvent("SonoranCAD::forcereg:CheckPlayer")
AddEventHandler("SonoranCAD::forcereg:CheckPlayer", function()
TriggerEvent("SonoranCAD::apicheck:CheckPlayerLinked", source)
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
8 changes: 4 additions & 4 deletions sonorancad/version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"resource": "3.0.5",
"resource": "3.0.6",
"testedFxServerVersion": "5932",
"submoduleConfigs": {
"callcommands": {
Expand Down Expand Up @@ -37,7 +37,7 @@
"requiresPlugins": []
},
"forcereg": {
"version": "1.0",
"version": "1.1",
"requiresPlugins": []
},
"frameworksupport": {
Expand All @@ -49,7 +49,7 @@
"requiresPlugins": []
},
"locations": {
"version": "1.0",
"version": "1.1",
"requiresPlugins": []
},
"lookups": {
Expand Down Expand Up @@ -99,7 +99,7 @@
"requiresPlugins": []
},
"wraithv2": {
"version": "1.5",
"version": "1.6",
"requiresPlugins": [
{
"name": "lookups",
Expand Down
Loading