0.1.4
0.1.4:
Manifest change to reflect file name changes
Separated menu for future compatibility (other menu systems)
New features:
- Callbacks:
- From client to server back to client
- From server to specific client and back.
This commit is contained in:
1 parent
385df1f969
commit
4a70083bf6
5 files changed
+114
-114
No files matched your search
@@ -0,0 +1,51 @@
|
||||
if GetResourceState('ox_lib') ~= 'started' then return end
|
||||
|
||||
--- Converts a QB menu to an Ox menu.
|
||||
---@param id string The menu ID.
|
||||
---@param menu table The QB menu data.
|
||||
---@return table The Ox menu data.
|
||||
local function QBToOxMenu(id, menu)
|
||||
local oxMenu = {
|
||||
id = id,
|
||||
title = "",
|
||||
canClose = true,
|
||||
options = {},
|
||||
}
|
||||
for i, v in pairs(menu) do
|
||||
if v.isMenuHeader then
|
||||
if oxMenu.title == "" then
|
||||
oxMenu.title = v.header
|
||||
end
|
||||
else
|
||||
local option = {
|
||||
title = v.header,
|
||||
description = v.txt,
|
||||
icon = v.icon,
|
||||
args = v.params.args,
|
||||
onSelect = function(selected, secondary, args)
|
||||
local params = menu[id]?.options?[selected]?.params
|
||||
if not params then return end
|
||||
local event = params.event
|
||||
local isServer = params.isServer
|
||||
if not event then return end
|
||||
if isServer then
|
||||
return TriggerServerEvent(event, args)
|
||||
end
|
||||
return TriggerEvent(event, args)
|
||||
end
|
||||
|
||||
}
|
||||
table.insert(oxMenu.options, option)
|
||||
end
|
||||
end
|
||||
return oxMenu
|
||||
end
|
||||
|
||||
|
||||
|
||||
OpenMenu = function(id, data, useQBinput)
|
||||
if useQBinput then
|
||||
data = QBToOxMenu(id, data)
|
||||
end
|
||||
return exports['qb-menu']:openMenu(data)
|
||||
end
|
||||
Reference in new issue
Block a user