Files
MrNewb 444040dd39 This was crowleys commit and work - Refactor entity behaviors and improve particle handling
Refactored entity behavior triggers to simplify argument passing and added OnSet handler for particle behaviors. Improved particle effect management and event handling, updated locale and lib initialization in several modules, and fixed skill metadata access. Also streamlined point zone logic and menu/zone system initialization for better reliability.
2025-10-26 16:20:27 -04:00

80 lines
2.2 KiB
Lua

local resourceName = "ox_lib"
local configValue = BridgeClientConfig.MenuSystem
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
Menus = Menus or {}
if not lib then Require('init.lua', 'ox_lib') 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 = v.action or 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
function OpenMenu(id, data, useQBinput)
if useQBinput then
data = QBToOxMenu(id, data)
end
lib.registerContext(data)
lib.showContext(id)
return data
end
GetMenuResourceName = function()
return resourceName
end
-- RegisterCommand('menutest', function()
-- local test1 = function()
-- print("Test 1 executed")
-- end
-- Bridge.Menu.Open({
-- title = "test",
-- description = "test",
-- options = {
-- {
-- title = "test",
-- description = "test",
-- icon = "fas fa-box-open",
-- onSelect = test1
-- },
-- }
-- })
-- end)