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,36 @@
|
||||
if GetResourceState('qb-menu') ~= 'started' then return end
|
||||
--- Converts an Ox menu to a QB menu.
|
||||
---@param id string The menu ID.
|
||||
---@param menu table The Ox menu data.
|
||||
---@return table The QB menu data.
|
||||
local function OxToQBMenu(id, menu)
|
||||
local qbMenu = {
|
||||
{
|
||||
header = menu.title,
|
||||
isMenuHeader = true,
|
||||
}
|
||||
}
|
||||
for i, v in pairs(menu.options) do
|
||||
local button = {
|
||||
header = v.title,
|
||||
txt = v.description,
|
||||
icon = v.icon,
|
||||
}
|
||||
|
||||
if v.onSelect and type(v.onSelect) == 'function' then
|
||||
button.params = {
|
||||
event = "community_bridge:client:MenuCallback",
|
||||
args = {id = id, selected = i, args = v.args, onSelect = v.onSelect},
|
||||
}
|
||||
end
|
||||
table.insert(qbMenu, button)
|
||||
end
|
||||
return qbMenu
|
||||
end
|
||||
|
||||
OpenMenu = function(id, data, useQBinput)
|
||||
if not useQBinput then
|
||||
data = OxToQBMenu(id, data)
|
||||
end
|
||||
return exports['qb-menu']:openMenu(data)
|
||||
end
|
||||
Reference in new issue
Block a user