From 664b39740419df4ca6f3ccbd8c222287ab243aa1 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Sun, 19 Oct 2025 22:59:18 -0400 Subject: [PATCH] Refactor Target resource name function placement Moved the GetResourceName function definition to the top of both ox_target and qb-target client modules for consistency and clarity. Also performed minor code cleanup and reordering for improved readability. --- modules/target/ox_target/client.lua | 16 ++++++++++------ modules/target/qb-target/client.lua | 13 +++++++++---- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/modules/target/ox_target/client.lua b/modules/target/ox_target/client.lua index 3f7d90d..639c18c 100644 --- a/modules/target/ox_target/client.lua +++ b/modules/target/ox_target/client.lua @@ -4,8 +4,15 @@ if GetResourceState(resourceName) == 'missing' then return end Target = Target or {} local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or false -local targetZones = {} + local ox_target = exports.ox_target +local targetZones = {} + +Target = Target or {} + +Target.GetResourceName = function() + return "ox_target" +end ---This is an internal function that is used to fix the options passed to fit alternative target systems, for example qb-ox or ox-qb etc. ---@param options table @@ -13,12 +20,13 @@ local ox_target = exports.ox_target Target.FixOptions = function(options) for _, v in pairs(options) do local action = v.onSelect or v.action - if not action then + if not action then local _type = v.type if _type and _type == "server" then v.serverEvent = v.event v.event = nil end + else local select = function(entityOrData) if type(entityOrData) == 'table' then @@ -193,8 +201,4 @@ AddEventHandler('onResourceStop', function(resource) targetZones = {} end) -Target.GetResourceName = function() - return "ox_target" -end - return Target \ No newline at end of file diff --git a/modules/target/qb-target/client.lua b/modules/target/qb-target/client.lua index c153977..4a8fa90 100644 --- a/modules/target/qb-target/client.lua +++ b/modules/target/qb-target/client.lua @@ -5,9 +5,17 @@ if GetResourceState("ox_target") ~= 'missing' then return end Target = Target or {} local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or false + local targetZones = {} + +Target = Target or {} + local qb_target = exports['qb-target'] +Target.GetResourceName = function() + return "qb-target" +end + function GetLargestDistance(data) local largestDistance = -1 for _, v in pairs(data) do @@ -18,6 +26,7 @@ function GetLargestDistance(data) return largestDistance ~= -1 and largestDistance or 2.0 end + ---This is an internal function that is used to fix the options passed to fit alternative target systems, for example qb-ox or ox-qb etc. ---@param options table ---@return table @@ -222,8 +231,4 @@ AddEventHandler('onResourceStop', function(resource) targetZones = {} end) -Target.GetResourceName = function() - return "qb-target" -end - return Target \ No newline at end of file