Skip to content

Instantly share code, notes, and snippets.

@Mkeefeus
Created November 14, 2022 20:36
Show Gist options
  • Save Mkeefeus/c2e555becf733d818fe306bc4d2d363b to your computer and use it in GitHub Desktop.
Save Mkeefeus/c2e555becf733d818fe306bc4d2d363b to your computer and use it in GitHub Desktop.
QBMenu to ox_lib
local function convertToOx(data)
local oxData = {
id = 'qbmenu_convert',
title = nil,
onExit = function()
if curCB then
curCB(nil)
curCB = nil
end
end,
options = nil
}
local options = {}
for _, v in ipairs(data) do
-- Formmating conversion
if v.hidden then goto continue end
if v.isMenuHeader and not oxData.title and not v.txt then
oxData.title = v.header
elseif v.isMenuHeader then
options[#options + 1] = {
title = v.header,
description = v.txt,
}
else
options[#options + 1] = {
title = v.header,
icon = v.icon,
description = v.txt,
disabled = v.disabled,
onSelect = function()
return onSelect(v.params)
end
}
end
::continue::
end
if not oxData.title then
oxData.title = 'Menu'
end
oxData.options = options
return oxData
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment