diff --git a/modules/input/ox_lib/client.lua b/modules/input/ox_lib/client.lua index 926efeb..3919fdf 100644 --- a/modules/input/ox_lib/client.lua +++ b/modules/input/ox_lib/client.lua @@ -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 diff --git a/modules/input/qb-input/client.lua b/modules/input/qb-input/client.lua index b227315..3742d57 100644 --- a/modules/input/qb-input/client.lua +++ b/modules/input/qb-input/client.lua @@ -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 diff --git a/modules/menu/ox_lib/client.lua b/modules/menu/ox_lib/client.lua index 5899892..5e097f1 100644 --- a/modules/menu/ox_lib/client.lua +++ b/modules/menu/ox_lib/client.lua @@ -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 diff --git a/modules/target/ox_target/client.lua b/modules/target/ox_target/client.lua index 3437cac..7211e39 100644 --- a/modules/target/ox_target/client.lua +++ b/modules/target/ox_target/client.lua @@ -22,8 +22,13 @@ Target = Target or {} 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)) + 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 @@ -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 diff --git a/modules/target/qb-target/client.lua b/modules/target/qb-target/client.lua index 0851023..ed8fe1f 100644 --- a/modules/target/qb-target/client.lua +++ b/modules/target/qb-target/client.lua @@ -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