From ff2012ac9f9e10bde2a83243bace43f719c36677 Mon Sep 17 00:00:00 2001 From: "Jordan.#2139" Date: Tue, 18 Jun 2024 15:55:32 -0400 Subject: [PATCH 1/6] Fix string literal declaration and ak garage declaration --- sonorancms/server/pushEvents.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sonorancms/server/pushEvents.lua b/sonorancms/server/pushEvents.lua index f6224b1..6d7a182 100644 --- a/sonorancms/server/pushEvents.lua +++ b/sonorancms/server/pushEvents.lua @@ -608,7 +608,7 @@ CreateThread(function() } table.insert(lines, 'QBShared.Gangs = {') for gangName, gangData in pairs(gangsTable) do - if tableType.gangName == 'string' then + if tableType.gangName == 'plain' then local gangLine = '\t[\'' .. gangName .. '\'] = {' table.insert(lines, gangLine) else @@ -697,7 +697,7 @@ CreateThread(function() } table.insert(lines, 'QBShared.Gangs = {') for gangName, gangData in pairs(gangsTable) do - if tableType.gangName == 'string' then + if tableType.gangName == 'plain' then local gangLine = '\t[\'' .. gangName .. '\'] = {' table.insert(lines, gangLine) else @@ -790,7 +790,7 @@ CreateThread(function() } table.insert(lines, 'QBShared.Gangs = {') for gangName, gangData in pairs(gangsTable) do - if tableType.gangName == 'string' then + if tableType.gangName == 'plain' then local gangLine = '\t[\'' .. gangName .. '\'] = {' table.insert(lines, gangLine) else @@ -864,7 +864,7 @@ CreateThread(function() table.insert(lines, 'QBShared.ForceJobDefaultDutyAtLogin = true -- true: Force duty state to jobdefaultDuty | false: set duty state from database last saved') table.insert(lines, 'QBShared.Jobs = {') for jobName, jobData in pairs(jobTable) do - if tableType.jobName == 'string' then + if tableType.jobName == 'plain' then local gangLine = '\t[\'' .. jobName .. '\'] = {' table.insert(lines, gangLine) else @@ -971,7 +971,7 @@ CreateThread(function() table.insert(lines, 'QBShared.ForceJobDefaultDutyAtLogin = true -- true: Force duty state to jobdefaultDuty | false: set duty state from database last saved') table.insert(lines, 'QBShared.Jobs = {') for jobName, jobData in pairs(jobTable) do - if tableType.jobName == 'string' then + if tableType.jobName == 'plain' then local gangLine = '\t[\'' .. jobName .. '\'] = {' table.insert(lines, gangLine) else @@ -1084,7 +1084,7 @@ CreateThread(function() table.insert(lines, 'QBShared.ForceJobDefaultDutyAtLogin = true -- true: Force duty state to jobdefaultDuty | false: set duty state from database last saved') table.insert(lines, 'QBShared.Jobs = {') for jobName, jobData in pairs(jobTable) do - if tableType.jobName == 'string' then + if tableType.jobName == 'plain' then local gangLine = '\t[\'' .. jobName .. '\'] = {' table.insert(lines, gangLine) else @@ -2369,7 +2369,7 @@ function handleDataRequest(data) return end if GetResourceState('qb-garages') ~= 'started' and GetResourceState('cd_garage') ~= 'started' and GetResourceState('qs-advancedgarages') ~= 'started' and GetResourceState('jg-advancedgarages') - ~= 'started' then + ~= 'started' and GetResourceState('ak47_gb_garage') then TriggerEvent('SonoranCMS::core:writeLog', 'warn', 'qb-garages, qs-advancedgarages, jg-advancedgarages and cd_garage are not started. The garage data will be sent as empty currently. If you do not use the SonoranCMS Game Panel you can ignore this.') table.insert(errors, { From 93e7201110bd5964755a92fed0a8b19e7466dc6b Mon Sep 17 00:00:00 2001 From: "Jordan.#2139" Date: Tue, 18 Jun 2024 16:11:55 -0400 Subject: [PATCH 2/6] Fix --- sonorancms/server/pushEvents.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonorancms/server/pushEvents.lua b/sonorancms/server/pushEvents.lua index 6d7a182..df21ec4 100644 --- a/sonorancms/server/pushEvents.lua +++ b/sonorancms/server/pushEvents.lua @@ -2369,7 +2369,7 @@ function handleDataRequest(data) return end if GetResourceState('qb-garages') ~= 'started' and GetResourceState('cd_garage') ~= 'started' and GetResourceState('qs-advancedgarages') ~= 'started' and GetResourceState('jg-advancedgarages') - ~= 'started' and GetResourceState('ak47_gb_garage') then + ~= 'started' and GetResourceState('ak47_gb_garage') ~= 'started' then TriggerEvent('SonoranCMS::core:writeLog', 'warn', 'qb-garages, qs-advancedgarages, jg-advancedgarages and cd_garage are not started. The garage data will be sent as empty currently. If you do not use the SonoranCMS Game Panel you can ignore this.') table.insert(errors, { From bbe111ec6a218850c0fa482cdd600fff27571f96 Mon Sep 17 00:00:00 2001 From: "Jordan.#2139" Date: Tue, 18 Jun 2024 16:39:53 -0400 Subject: [PATCH 3/6] Fix typo --- sonorancms/server/pushEvents.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sonorancms/server/pushEvents.lua b/sonorancms/server/pushEvents.lua index df21ec4..e92acf7 100644 --- a/sonorancms/server/pushEvents.lua +++ b/sonorancms/server/pushEvents.lua @@ -2369,9 +2369,9 @@ function handleDataRequest(data) return end if GetResourceState('qb-garages') ~= 'started' and GetResourceState('cd_garage') ~= 'started' and GetResourceState('qs-advancedgarages') ~= 'started' and GetResourceState('jg-advancedgarages') - ~= 'started' and GetResourceState('ak47_gb_garage') ~= 'started' then + ~= 'started' and GetResourceState('ak47_qb_garage') ~= 'started' then TriggerEvent('SonoranCMS::core:writeLog', 'warn', - 'qb-garages, qs-advancedgarages, jg-advancedgarages and cd_garage are not started. The garage data will be sent as empty currently. If you do not use the SonoranCMS Game Panel you can ignore this.') + 'qb-garages, qs-advancedgarages, jg-advancedgarages, ak47_qb_garage and cd_garage are not started. The garage data will be sent as empty currently. If you do not use the SonoranCMS Game Panel you can ignore this.') table.insert(errors, { code = 'ERR_GARAGE_NOT_STARTED', message = 'qb-garages, qs-advancedgarages, jg-advancedgarages and cd_garage are not started. The garage data will be sent as empty currently.' From 8ff6345d3a85042dfc4341bb1c97ddc838bc01fe Mon Sep 17 00:00:00 2001 From: "Jordan.#2139" Date: Wed, 19 Jun 2024 17:42:44 -0400 Subject: [PATCH 4/6] Fix typo and string literal declaration in AK garage support --- sonorancms/server/pushEvents.lua | 97 +++++++++++++++++++------------- 1 file changed, 59 insertions(+), 38 deletions(-) diff --git a/sonorancms/server/pushEvents.lua b/sonorancms/server/pushEvents.lua index e92acf7..d15e7b7 100644 --- a/sonorancms/server/pushEvents.lua +++ b/sonorancms/server/pushEvents.lua @@ -118,18 +118,18 @@ end ---@param inputString string ---@return string local function escapeQuotes(inputString) - inputString = inputString.gsub(inputString, "([%c%z\\\"'])", { - ["\\"] = "\\\\", - ["\""] = "\\\"", - ["'"] = "\\'", - ["\b"] = "\\b", - ["\f"] = "\\f", - ["\n"] = "\\n", - ["\r"] = "\\r", - ["\t"] = "\\t", - ["\0"] = "\\0", + inputString = inputString.gsub(inputString, '([%c%z\\"\'])', { + ['\\'] = '\\\\', + ['"'] = '\\"', + ['\''] = '\\\'', + ['\b'] = '\\b', + ['\f'] = '\\f', + ['\n'] = '\\n', + ['\r'] = '\\r', + ['\t'] = '\\t', + ['\0'] = '\\0' }) -return inputString + return inputString end --- Encodes the combinale array for items to be correct @@ -234,16 +234,17 @@ local function shiftToHour(hour) end -- Function to determine whether a table is a string_literal_key table or a plain_identifier_key table -function checkKeyTypes(tbl) - local keyTypes = {} - for key, _ in pairs(tbl) do - if type(key) == "string" and key:match("^[%a_][%w_]*$") then - keyTypes[key] = "plain" - else - keyTypes[key] = "string" - end - end - return keyTypes +local function checkObjType(data) + local jobs = {}; + local quoted_pattern = '%[\'(.-)\'%]' + local unquoted_pattern = '%s(%a[%w_]*)%s*=%s*{' + for job_id in data:gmatch(quoted_pattern) do + jobs[job_id] = 'quoted' + end + for job_id in data:gmatch(unquoted_pattern) do + jobs[job_id] = 'unquoted' + end + return jobs end CreateThread(function() @@ -595,7 +596,7 @@ CreateThread(function() print('Error: QBShared.Gangs table is missing or empty.') return end - local tableType = checkKeyTypes(loadedGangs) + local jobTypes = checkObjType(originalData) validGangs = filterGangs(loadedGangs) if not validGangs[data.data.gangId] then TriggerEvent('SonoranCMS::core:writeLog', 'debug', 'Error: Gang ' .. data.data.gangId .. ' does not exist.') @@ -608,7 +609,7 @@ CreateThread(function() } table.insert(lines, 'QBShared.Gangs = {') for gangName, gangData in pairs(gangsTable) do - if tableType.gangName == 'plain' then + if jobTypes[gangName] == 'quoted' then local gangLine = '\t[\'' .. gangName .. '\'] = {' table.insert(lines, gangLine) else @@ -668,7 +669,7 @@ CreateThread(function() print('Error: QBShared.Gangs table is missing or empty.') return end - local tableType = checkKeyTypes(loadedGangs) + local jobTypes = checkObjType(originalData) validGangs = filterGangs(loadedGangs) if not validGangs[data.data.id] then TriggerEvent('SonoranCMS::core:writeLog', 'debug', 'Error: Gang ' .. data.data.id .. ' does not exist.') @@ -697,7 +698,7 @@ CreateThread(function() } table.insert(lines, 'QBShared.Gangs = {') for gangName, gangData in pairs(gangsTable) do - if tableType.gangName == 'plain' then + if jobTypes[gangName] == 'quoted' then local gangLine = '\t[\'' .. gangName .. '\'] = {' table.insert(lines, gangLine) else @@ -757,7 +758,7 @@ CreateThread(function() print('Error: QBShared.Gangs table is missing or empty.') return end - local tableType = checkKeyTypes(loadedGangs) + local jobTypes = checkObjType(originalData) validGangs = filterGangs(loadedGangs) if validGangs[data.data.id] then TriggerEvent('SonoranCMS::core:writeLog', 'debug', 'Error: Gang ' .. data.data.id .. ' already exists.') @@ -790,7 +791,7 @@ CreateThread(function() } table.insert(lines, 'QBShared.Gangs = {') for gangName, gangData in pairs(gangsTable) do - if tableType.gangName == 'plain' then + if jobTypes[gangName] == 'quoted' then local gangLine = '\t[\'' .. gangName .. '\'] = {' table.insert(lines, gangLine) else @@ -850,7 +851,7 @@ CreateThread(function() print('Error: QBShared.Jobs table is missing or empty.') return end - local tableType = checkKeyTypes(loadedJobs) + local jobTypes = checkObjType(originalData) validJobs = filterJobs(loadedJobs) if not validJobs[data.data.jobId] then TriggerEvent('SonoranCMS::core:writeLog', 'debug', 'Error: Job ' .. data.data.jobId .. ' does not exist.') @@ -864,7 +865,7 @@ CreateThread(function() table.insert(lines, 'QBShared.ForceJobDefaultDutyAtLogin = true -- true: Force duty state to jobdefaultDuty | false: set duty state from database last saved') table.insert(lines, 'QBShared.Jobs = {') for jobName, jobData in pairs(jobTable) do - if tableType.jobName == 'plain' then + if jobTypes[jobName] == 'quoted' then local gangLine = '\t[\'' .. jobName .. '\'] = {' table.insert(lines, gangLine) else @@ -931,12 +932,12 @@ CreateThread(function() return end func() + local jobTypes = checkObjType(originalData) local loadedJobs = tempEnv.QBShared and tempEnv.QBShared.Jobs if not loadedJobs or next(loadedJobs) == nil then print('Error: QBShared.Jobs table is missing or empty.') return end - local tableType = checkKeyTypes(loadedJobs) validJobs = filterJobs(loadedJobs) if not validJobs[data.data.id] then TriggerEvent('SonoranCMS::core:writeLog', 'debug', 'Error: Job ' .. data.data.id .. ' does not exist.') @@ -971,7 +972,7 @@ CreateThread(function() table.insert(lines, 'QBShared.ForceJobDefaultDutyAtLogin = true -- true: Force duty state to jobdefaultDuty | false: set duty state from database last saved') table.insert(lines, 'QBShared.Jobs = {') for jobName, jobData in pairs(jobTable) do - if tableType.jobName == 'plain' then + if jobTypes[jobName] == 'quoted' then local gangLine = '\t[\'' .. jobName .. '\'] = {' table.insert(lines, gangLine) else @@ -1043,7 +1044,7 @@ CreateThread(function() print('Error: QBShared.Jobs table is missing or empty.') return end - local tableType = checkKeyTypes(loadedJobs) + local jobTypes = checkObjType(originalData) validJobs = filterJobs(loadedJobs) if validJobs[data.data.id] then TriggerEvent('SonoranCMS::core:writeLog', 'debug', 'Error: Job ' .. data.data.id .. ' already exist.') @@ -1084,7 +1085,7 @@ CreateThread(function() table.insert(lines, 'QBShared.ForceJobDefaultDutyAtLogin = true -- true: Force duty state to jobdefaultDuty | false: set duty state from database last saved') table.insert(lines, 'QBShared.Jobs = {') for jobName, jobData in pairs(jobTable) do - if tableType.jobName == 'plain' then + if jobTypes[jobName] == 'quoted' then local gangLine = '\t[\'' .. jobName .. '\'] = {' table.insert(lines, gangLine) else @@ -1172,6 +1173,7 @@ CreateThread(function() print('Error: QBShared.Items table is missing or empty.') return end + local itemTypes = checkObjType(originalData) validItems = filterJobs(loadedItems) if validItems[data.data.name] then TriggerEvent('SonoranCMS::core:writeLog', 'debug', 'Error: Item ' .. data.data.name .. ' already exist.') @@ -1196,8 +1198,13 @@ CreateThread(function() } table.insert(lines, 'QBShared.Items = {') for itemName, itemData in pairs(itemTable) do - local itemLine = '\t[\'' .. itemName .. '\'] = {' - table.insert(lines, itemLine) + if itemTypes[itemName] == 'quoted' then + local itemLine = '\t[\'' .. itemName .. '\'] = {' + table.insert(lines, itemLine) + else + local itemLine = '\t' .. itemName .. ' = {' + table.insert(lines, itemLine) + end local labelLine = '\t\tlabel = ' .. string.format('\'%s\',', itemData.label) table.insert(lines, labelLine) if itemData.type and itemData.type ~= nil then @@ -1275,6 +1282,7 @@ CreateThread(function() print('Error: QBShared.Items table is missing or empty.') return end + local itemTypes = checkObjType(originalData) validItems = filterJobs(loadedItems) if not validItems[data.data.name] then TriggerEvent('SonoranCMS::core:writeLog', 'debug', 'Error: Item ' .. data.data.name .. ' does not exist.') @@ -1299,7 +1307,13 @@ CreateThread(function() } table.insert(lines, 'QBShared.Items = {') for itemName, itemData in pairs(itemTable) do - local itemLine = '\t[\'' .. itemName .. '\'] = {' + if itemTypes[itemName] == 'quoted' then + local itemLine = '\t[\'' .. itemName .. '\'] = {' + table.insert(lines, itemLine) + else + local itemLine = '\t' .. itemName .. ' = {' + table.insert(lines, itemLine) + end table.insert(lines, itemLine) local labelLine = '\t\tlabel = ' .. string.format('\'%s\',', itemData.label) table.insert(lines, labelLine) @@ -1379,6 +1393,7 @@ CreateThread(function() print('Error: QBShared.Items table is missing or empty.') return end + local itemTypes = checkObjType(originalData) validItems = filterJobs(loadedItems) if not validItems[data.data.itemName] then TriggerEvent('SonoranCMS::core:writeLog', 'debug', 'Error: Item ' .. data.data.itemName .. ' does not exist.') @@ -1391,7 +1406,13 @@ CreateThread(function() } table.insert(lines, 'QBShared.Items = {') for itemName, itemData in pairs(itemTable) do - local itemLine = '\t[\'' .. itemName .. '\'] = {' + if itemTypes[itemName] == 'quoted' then + local itemLine = '\t[\'' .. itemName .. '\'] = {' + table.insert(lines, itemLine) + else + local itemLine = '\t' .. itemName .. ' = {' + table.insert(lines, itemLine) + end table.insert(lines, itemLine) local labelLine = '\t\tlabel = ' .. string.format('\'%s\',', itemData.label) table.insert(lines, labelLine) @@ -2182,7 +2203,7 @@ local function requestGarageData() spawnPoint = { spawns[1].x, spawns[1].y, - spawns[1].z, + spawns[1].z }, putVehicle = { spawns[1].x, From 1b01b62496c90caf2fcde0fddc06a6885f912daf Mon Sep 17 00:00:00 2001 From: "Jordan.#2139" <65438497+Jordan2139@users.noreply.github.com> Date: Mon, 24 Jun 2024 14:06:38 -0400 Subject: [PATCH 5/6] fix: typo --- sonorancms/server/pushEvents.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonorancms/server/pushEvents.lua b/sonorancms/server/pushEvents.lua index d15e7b7..b3dced9 100644 --- a/sonorancms/server/pushEvents.lua +++ b/sonorancms/server/pushEvents.lua @@ -2186,7 +2186,7 @@ local function requestGarageData() TriggerEvent('SonoranCMS::core:writeLog', 'error', 'Error getting garage data from jg-advancedgarages, the export getAllGarages() is not available. Please update your jg-advancedgarages resource.') end elseif GetResourceState('ak47_qb_garage') == 'started' then - local sqlData = MySQL.query('SELECT * FROM `ak47_qb_garage', function(row) + local sqlData = MySQL.query('SELECT * FROM `ak47_qb_garage`', function(row) if not row then TriggerEvent('SonoranCMS::core:writeLog', 'debug', 'No garages found in ak47_qb_garage') else From ec90ab4f85cb6f22f66c637d438806d667cafcf2 Mon Sep 17 00:00:00 2001 From: El Gato da Great Date: Wed, 26 Jun 2024 14:57:14 -0500 Subject: [PATCH 6/6] version bump --- sonorancms/fxmanifest.lua | 2 +- sonorancms/version.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sonorancms/fxmanifest.lua b/sonorancms/fxmanifest.lua index bc0bcca..7409cd3 100644 --- a/sonorancms/fxmanifest.lua +++ b/sonorancms/fxmanifest.lua @@ -4,7 +4,7 @@ games {'gta5'} author 'Sonoran Software Systems' real_name 'Sonoran CMS FiveM Integration' description 'Sonoran CMS to FiveM translation layer' -version '1.5.8' +version '1.5.9' lua54 'yes' server_scripts {'server/*.lua', 'config.lua', 'server/util/unzip.js', 'server/util/http.js', 'server/util/sonoran.js', 'server/util/utils.js', '@oxmysql/lib/MySQL.lua', 'server/util/imageHandler.js', 'server/modules/**/*_sv.js', 'server/modules/**/*_sv.lua'} diff --git a/sonorancms/version.json b/sonorancms/version.json index 579622c..5e2a805 100644 --- a/sonorancms/version.json +++ b/sonorancms/version.json @@ -1,4 +1,4 @@ { - "resource": "1.5.8", + "resource": "1.5.9", "testedFxServerVersion": "7290" }