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
+32 -7

No files matched your search

+10 -1
View File
@@ -8,7 +8,16 @@ Input = {}
function Input.Open(title, data, isQBFormat, submitText)
local inputs = data.inputs
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
return lib.inputDialog(title, data)
end
+1 -1
View File
@@ -24,7 +24,7 @@ function Input.Open(title, data, isQBFormat, submitText)
for i, v in pairs(input) do
for k, j in pairs(returnData) do
if k == v.name then
convertedData[tonumber(i)] = j
convertedData[v.name] = j
end
end
end
+1 -1
View File
@@ -25,7 +25,7 @@ local function QBToOxMenu(id, menu)
description = v.txt,
icon = v.icon,
args = v.params.args,
onSelect = function(selected, secondary, args)
onSelect = v.action or function(selected, secondary, args)
local params = menu[id]?.options?[selected]?.params
if not params then return end
local event = params.event
+9 -3
View File
@@ -23,7 +23,12 @@ Target.FixOptions = function(options)
for k, v in pairs(options) do
local action = v.onSelect or v.action
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
local select = function(entityOrData)
if type(entityOrData) == 'table' then
@@ -31,9 +36,10 @@ Target.FixOptions = function(options)
end
return action(entityOrData)
end
options[k].onSelect = select
options[k].groups = v.job or v.groups
v.onSelect = select
end
v.groups = v.job or v.groups
end
return options
end
+11 -1
View File
@@ -24,14 +24,24 @@ local qb_target = exports['qb-target']
Target.FixOptions = function(options)
for k, v in pairs(options) do
local action = v.onSelect or v.action
local select = function(entityOrData)
local select = action and function(entityOrData)
if type(entityOrData) == 'table' then
return action(entityOrData.entity)
end
return action(entityOrData)
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].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
return options
end