2025-01-16 00:58:49 -06:00
|
|
|
Menus = Menus or {}
|
2025-01-08 06:33:31 -05:00
|
|
|
Menu = {}
|
|
|
|
|
|
2025-06-07 22:50:13 -04:00
|
|
|
---Opens a menu based on the configuration.
|
2025-01-08 06:33:31 -05:00
|
|
|
---@param data table The menu data.
|
|
|
|
|
---@param useQb boolean Whether to use QB menu syntax.
|
|
|
|
|
---@return id string The menu ID.
|
|
|
|
|
function Menu.Open(data, useQb)
|
|
|
|
|
local id = data.id or Ids.CreateUniqueId(Menus, nil, nil)
|
2025-01-14 12:30:29 -06:00
|
|
|
Menus[id] = OpenMenu(id, data, useQb)
|
|
|
|
|
data.id = id
|
2025-01-08 06:33:31 -05:00
|
|
|
return id
|
|
|
|
|
end
|
|
|
|
|
|
2025-07-08 09:44:53 -04:00
|
|
|
function Menu.GetResourceName()
|
|
|
|
|
return GetMenuResourceName()
|
|
|
|
|
end
|
|
|
|
|
|
2025-06-07 22:50:13 -04:00
|
|
|
---Event to handle callback from menu selection.
|
|
|
|
|
---@param _args table The arguments passed to the callback.
|
|
|
|
|
---@return nil
|
2025-01-08 06:33:31 -05:00
|
|
|
RegisterNetEvent('community_bridge:client:MenuCallback', function(_args)
|
|
|
|
|
local id = _args.id
|
|
|
|
|
local onSelect = _args.onSelect
|
|
|
|
|
local args = _args.args
|
2025-02-19 04:05:40 -06:00
|
|
|
Menus[id] = nil
|
|
|
|
|
onSelect(args)
|
2025-01-08 06:33:31 -05:00
|
|
|
end)
|
|
|
|
|
|
2025-06-07 22:50:13 -04:00
|
|
|
return Menu
|