made some changes to input and target

targets now accept event

fixed a check for .action passed to ox fix options

input will now return in qbs format if qb is used (passed as true).. this makes converting qb resources infinitely simpler
This commit is contained in:
Mr.Crowley committed 2025-07-29 05:22:55 -05:00
1 parent 6047c6d88c
commit a1e65a7dff
5 files changed
+33 -8

No files matched your search

+10 -1
View File
@@ -8,7 +8,16 @@ Input = {}
function Input.Open(title, data, isQBFormat, submitText) function Input.Open(title, data, isQBFormat, submitText)
local inputs = data.inputs local inputs = data.inputs
if isQBFormat then if isQBFormat then
return lib.inputDialog(title, QBToOxInput(inputs)) local convertedData = {}
local returnData = lib.inputDialog(title, QBToOxInput(inputs))
for i, v in pairs(inputs) do
for k, j in pairs(returnData or {}) do
if k == v.name then
convertedData[v.name] = j
end
end
end
return convertedData
else else
return lib.inputDialog(title, data) return lib.inputDialog(title, data)
end end
+1 -1
View File
@@ -24,7 +24,7 @@ function Input.Open(title, data, isQBFormat, submitText)
for i, v in pairs(input) do for i, v in pairs(input) do
for k, j in pairs(returnData) do for k, j in pairs(returnData) do
if k == v.name then if k == v.name then
convertedData[tonumber(i)] = j convertedData[v.name] = j
end end
end end
end end
+1 -1
View File
@@ -25,7 +25,7 @@ local function QBToOxMenu(id, menu)
description = v.txt, description = v.txt,
icon = v.icon, icon = v.icon,
args = v.params.args, args = v.params.args,
onSelect = function(selected, secondary, args) onSelect = v.action or function(selected, secondary, args)
local params = menu[id]?.options?[selected]?.params local params = menu[id]?.options?[selected]?.params
if not params then return end if not params then return end
local event = params.event local event = params.event
+10 -4
View File
@@ -22,8 +22,13 @@ Target = Target or {}
Target.FixOptions = function(options) Target.FixOptions = function(options)
for k, v in pairs(options) do for k, v in pairs(options) do
local action = v.onSelect or v.action local action = v.onSelect or v.action
if not action then if not action then
print(("Target option (%s) %s is missing an 'onSelect' or 'action' function."):format(k, v.label)) local _type = v.type
if _type and _type == "server" then
v.serverEvent = v.event
v.event = nil
end
else else
local select = function(entityOrData) local select = function(entityOrData)
if type(entityOrData) == 'table' then if type(entityOrData) == 'table' then
@@ -31,9 +36,10 @@ Target.FixOptions = function(options)
end end
return action(entityOrData) return action(entityOrData)
end end
options[k].onSelect = select v.onSelect = select
options[k].groups = v.job or v.groups
end end
v.groups = v.job or v.groups
end end
return options return options
end end
+11 -1
View File
@@ -24,14 +24,24 @@ local qb_target = exports['qb-target']
Target.FixOptions = function(options) Target.FixOptions = function(options)
for k, v in pairs(options) do for k, v in pairs(options) do
local action = v.onSelect or v.action local action = v.onSelect or v.action
local select = function(entityOrData) local select = action and function(entityOrData)
if type(entityOrData) == 'table' then if type(entityOrData) == 'table' then
return action(entityOrData.entity) return action(entityOrData.entity)
end end
return action(entityOrData) return action(entityOrData)
end end
if v.serverEvent then
v.type = "server"
v.event = v.serverEvent
elseif v.event then
v.type = "client"
v.event = v.event
print("Fixing options for target:", k, "with event:", v.event)
end
options[k].action = select options[k].action = select
options[k].job = v.job or v.groups options[k].job = v.job or v.groups
options[k].jobType = v.jobType
print("Fixing options for target:", k, "with job:", options[k].job, "and jobType:", options[k].jobType)
end end
return options return options
end end