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.
This commit is contained in:
1 parent
45a98528b1
commit
664b397404
2 files changed
+19
-10
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
Reference in new issue
Block a user