13 files changed
+171
-134
No files matched your search
+25
-25
@@ -4,13 +4,13 @@ lua54 'yes'
|
||||
use_experimental_fxv2_oal 'yes'
|
||||
author 'The Order of the Sacred Framework'
|
||||
description 'A bridge made for the community to use as a base for their own projects. This bridge will allow a single format to work with nearly all commonly used systems while still offering expandability.'
|
||||
version '0.1.3'
|
||||
version '0.1.4'
|
||||
|
||||
shared_scripts {
|
||||
'settings/sharedConfig.lua',
|
||||
'use/*.lua',
|
||||
'modules/Utility/shared/*.lua',
|
||||
'modules/Math/*.lua',
|
||||
'modules/utility/shared/*.lua',
|
||||
'modules/math/*.lua',
|
||||
'modules/locales/*.lua',
|
||||
}
|
||||
|
||||
@@ -18,34 +18,34 @@ server_scripts {
|
||||
'@oxmysql/lib/MySQL.lua',
|
||||
'settings/serverConfig.lua',
|
||||
'modules/locales/shared.lua',
|
||||
'modules/Utility/server/*.lua',
|
||||
'modules/Framework/**/server.lua',
|
||||
'modules/Inventory/**/server.lua',
|
||||
'modules/Doorlock/**/server.lua',
|
||||
'modules/Phone/**/server.lua',
|
||||
'modules/Notify/server.lua',
|
||||
'modules/Managment/**/server.lua',
|
||||
'modules/utility/server/*.lua',
|
||||
'modules/framework/**/server.lua',
|
||||
'modules/inventory/**/server.lua',
|
||||
'modules/doorlock/**/server.lua',
|
||||
'modules/phone/**/server.lua',
|
||||
'modules/notify/server.lua',
|
||||
'modules/managment/**/server.lua',
|
||||
'init.lua',
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'settings/clientConfig.lua',
|
||||
'modules/locales/shared.lua',
|
||||
'modules/Utility/client/*.lua',
|
||||
'modules/Framework/**/client.lua',
|
||||
'modules/Inventory/**/client.lua',
|
||||
'modules/Doorlock/**/client.lua',
|
||||
'modules/Phone/**/client.lua',
|
||||
'modules/Notify/client.lua',
|
||||
'modules/Weather/**/client.lua',
|
||||
'modules/VehicleKey/**/client.lua',
|
||||
'modules/Fuel/**/client.lua',
|
||||
'modules/Target/**/client.lua',
|
||||
'modules/Dispatch/**/client.lua',
|
||||
'modules/Progressbar/**/client.lua',
|
||||
'modules/Clothing/**/client.lua',
|
||||
'modules/Input/client.lua',
|
||||
'modules/menu/client.lua',
|
||||
'modules/utility/client/*.lua',
|
||||
'modules/framework/**/client.lua',
|
||||
'modules/inventory/**/client.lua',
|
||||
'modules/doorlock/**/client.lua',
|
||||
'modules/phone/**/client.lua',
|
||||
'modules/notify/client.lua',
|
||||
'modules/weather/**/client.lua',
|
||||
'modules/vehicleKey/**/client.lua',
|
||||
'modules/fuel/**/client.lua',
|
||||
'modules/target/**/client.lua',
|
||||
'modules/dispatch/**/client.lua',
|
||||
'modules/progressbar/**/client.lua',
|
||||
'modules/clothing/**/client.lua',
|
||||
'modules/input/*.lua',
|
||||
'modules/menu/*.lua',
|
||||
'init.lua',
|
||||
}
|
||||
|
||||
|
||||
@@ -25,14 +25,13 @@ Bridge.RegisterModule("Inventory", Inventory)
|
||||
Bridge.RegisterModule("Notify", Notify)
|
||||
Bridge.RegisterModule("Utility", Utility)
|
||||
Bridge.RegisterModule("Clothing", Clothing)
|
||||
Bridge.RegisterModule("Menu", Menu)
|
||||
Bridge.RegisterModule("Language", Language)
|
||||
Bridge.RegisterModule("Doorlock", Doorlock)
|
||||
Bridge.RegisterModule("Phone", Phone)
|
||||
Bridge.RegisterModule("Target", Target)
|
||||
Bridge.RegisterModule("Table", Table)
|
||||
Bridge.RegisterModule("Math", Math)
|
||||
Bridge.RegisterModule("Prints", Prints)
|
||||
Bridge.RegisterModule("Callback", Callback)
|
||||
|
||||
|
||||
CreateThread(function()
|
||||
@@ -60,6 +59,8 @@ Bridge.RegisterModule("Input", Input)
|
||||
Bridge.RegisterModule("Progressbar", Progressbar)
|
||||
Bridge.RegisterModule("VehicleKey", VehicleKey)
|
||||
Bridge.RegisterModule("Weather", Weather)
|
||||
Bridge.RegisterModule("Target", Target)
|
||||
Bridge.RegisterModule("Menu", Menu)
|
||||
|
||||
-- Fill the bridge tables with player data.
|
||||
function FillBridgeTables()
|
||||
|
||||
@@ -198,8 +198,13 @@ end
|
||||
|
||||
-- Framework.RegisterUsableItem(item, cb)
|
||||
-- Registers a usable item with a callback function.
|
||||
Framework.RegisterUsableItem = function(item, cb)
|
||||
ESX.RegisterUsableItem(item, cb)
|
||||
Framework.RegisterUsableItem = function(itemName, cb)
|
||||
local func = function(src, item, itemData)
|
||||
itemData = itemData or item
|
||||
itemData.metadata = itemData.metadata or itemData.info or {}
|
||||
cb(src, itemName, itemData)
|
||||
end
|
||||
ESX.RegisterUsableItem(itemName, func)
|
||||
end
|
||||
|
||||
Framework.Commands = {}
|
||||
@@ -210,4 +215,6 @@ Framework.Commands.Add = function(name, help, arguments, argsrequired, callback,
|
||||
help = help,
|
||||
arguments = arguments
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- test
|
||||
@@ -248,8 +248,13 @@ end
|
||||
|
||||
-- Framework.RegisterUsableItem(item, cb)
|
||||
-- Registers a usable item with a callback function.
|
||||
Framework.RegisterUsableItem = function(item, cb)
|
||||
QBCore.Functions.CreateUseableItem(item, cb)
|
||||
Framework.RegisterUsableItem = function(itemName, cb)
|
||||
local func = function(src, item, itemData)
|
||||
itemData = itemData or item
|
||||
itemData.metadata = itemData.metadata or itemData.info or {}
|
||||
cb(src, itemName, itemData)
|
||||
end
|
||||
QBCore.Functions.CreateUseableItem(itemName, func)
|
||||
end
|
||||
|
||||
Framework.Commands = {}
|
||||
|
||||
@@ -235,6 +235,11 @@ end
|
||||
|
||||
-- Framework.RegisterUsableItem(item, cb)
|
||||
-- Registers a usable item with a callback function.
|
||||
Framework.RegisterUsableItem = function(item, cb)
|
||||
return QBox:CreateUseableItem(item, cb)
|
||||
Framework.RegisterUsableItem = function(itemName, cb)
|
||||
local func = function(src, item, itemData)
|
||||
itemData = itemData or item
|
||||
itemData.metadata = itemData.metadata or itemData.info or {}
|
||||
cb(src, itemName, itemData)
|
||||
end
|
||||
return QBox:CreateUseableItem(itemName, cb)
|
||||
end
|
||||
@@ -1,11 +1,12 @@
|
||||
Inventory = Inventory or {}
|
||||
|
||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||
return Framework.AddItem(src, item, count, slot, metadata)
|
||||
end
|
||||
|
||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||
return Framework.RemoveItem(src, item.name, count, slot, metadata)
|
||||
item = type(item) == "table" and item.name or item
|
||||
return Framework.RemoveItem(src, item, count, slot, metadata)
|
||||
end
|
||||
|
||||
Inventory.GetItemInfo = function(item)
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
if GetResourceState('ox_lib') ~= 'started' and (BridgeClientConfig.MenuSystem ~= "ox" or BridgeClientConfig.MenuSystem ~= "auto") then return end
|
||||
Menus = Menus or {}
|
||||
--- 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
|
||||
if not Menus[id] then
|
||||
lib.registerContext(data)
|
||||
end
|
||||
lib.showContext(id)
|
||||
return data
|
||||
end
|
||||
@@ -0,0 +1,39 @@
|
||||
if GetResourceState('qb-menu') ~= 'started' and (BridgeClientConfig.MenuSystem ~= "qb" or BridgeClientConfig.MenuSystem ~= "auto") 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.
|
||||
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 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
|
||||
exports['qb-menu']:openMenu(data)
|
||||
return data
|
||||
end
|
||||
+3
-91
@@ -1,109 +1,21 @@
|
||||
local Menus = {}
|
||||
Menus = Menus or {}
|
||||
Menu = {}
|
||||
|
||||
if GetResourceState('ox_lib') ~= 'started' and GetResourceState('qb-menu') ~= '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.
|
||||
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
|
||||
|
||||
--- 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.
|
||||
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
|
||||
|
||||
--- Opens a menu based on the configuration.
|
||||
---@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 CreateUniqueId(Menus)
|
||||
local id = data.id or Ids.CreateUniqueId(Menus, nil, nil)
|
||||
local menuExists = Menus[id]
|
||||
if useQb then
|
||||
if BridgeClientConfig.MenuSystem == "ox" then
|
||||
if not menuExists then
|
||||
Menus[id] = QBToOxMenu(id, data)
|
||||
lib.registerContext(Menus[id])
|
||||
end
|
||||
return lib.showContext(id)
|
||||
elseif BridgeClientConfig.MenuSystem == "qb" then
|
||||
Menus[id] = data
|
||||
return exports['qb-menu']:openMenu(Menus[id])
|
||||
end
|
||||
else
|
||||
if BridgeClientConfig.MenuSystem == "ox" then
|
||||
if not menuExists then
|
||||
Menus[id] = data
|
||||
lib.registerContext(Menus[id])
|
||||
end
|
||||
return lib.showContext(id)
|
||||
elseif BridgeClientConfig.MenuSystem == "qb" then
|
||||
Menus[id] = OxToQBMenu(id, data)
|
||||
return exports['qb-menu']:openMenu(Menus[id])
|
||||
end
|
||||
end
|
||||
Menus[id] = OpenMenu(id, data, useQb)
|
||||
data.id = id
|
||||
return id
|
||||
end
|
||||
|
||||
|
||||
@@ -15,18 +15,30 @@ local targetZones = {}
|
||||
Target = {}
|
||||
|
||||
Target.AddGlobalPlayer = function(options)
|
||||
for k, v in pairs(options) do
|
||||
options[k].onSelect = v.onSelect or v.action
|
||||
end
|
||||
ox_target:addGlobalPlayer(options)
|
||||
end
|
||||
|
||||
Target.AddLocalEntity = function(entities, options)
|
||||
for k, v in pairs(options) do
|
||||
options[k].onSelect = v.onSelect or v.action
|
||||
end
|
||||
ox_target:addLocalEntity(entities, options)
|
||||
end
|
||||
|
||||
Target.AddModel = function(models, options)
|
||||
for k, v in pairs(options) do
|
||||
options[k].onSelect = v.onSelect or v.action
|
||||
end
|
||||
ox_target:addModel(models, options)
|
||||
end
|
||||
|
||||
Target.AddBoxZone = function(name, coords, size, heading, options)
|
||||
for k, v in pairs(options) do
|
||||
options[k].onSelect = v.onSelect or v.action
|
||||
end
|
||||
local target = ox_target:addBoxZone({
|
||||
coords = coords,
|
||||
size = size,
|
||||
|
||||
@@ -15,7 +15,7 @@ Target = {}
|
||||
|
||||
Target.AddGlobalPlayer = function(options)
|
||||
for k, v in pairs(options) do
|
||||
options[k].action = v.onSelect
|
||||
options[k].action = v.action or v.onSelect
|
||||
end
|
||||
exports['qb-target']:AddGlobalPlayer({
|
||||
options = options,
|
||||
@@ -25,7 +25,7 @@ end
|
||||
|
||||
Target.AddLocalEntity = function(entities, options)
|
||||
for k, v in pairs(options) do
|
||||
options[k].action = v.onSelect
|
||||
options[k].action = v.action or v.onSelect
|
||||
end
|
||||
exports['qb-target']:AddTargetEntity(entities, {
|
||||
options = options,
|
||||
@@ -35,7 +35,7 @@ end
|
||||
|
||||
Target.AddModel = function(models, options)
|
||||
for k, v in pairs(options) do
|
||||
options[k].action = v.onSelect
|
||||
options[k].action = v.action or v.onSelect
|
||||
end
|
||||
exports['qb-target']:AddTargetModel(models, {
|
||||
options = options,
|
||||
@@ -45,7 +45,7 @@ end
|
||||
|
||||
Target.AddBoxZone = function(name, coords, size, heading, options)
|
||||
for k, v in pairs(options) do
|
||||
options[k].action = v.onSelect
|
||||
options[k].action = v.action or v.onSelect
|
||||
end
|
||||
exports['qb-target']:AddBoxZone(name, coords, size.x, size.y, {
|
||||
name = name,
|
||||
|
||||
@@ -13,7 +13,7 @@ local placementText = {
|
||||
}
|
||||
|
||||
local function finishPlacing()
|
||||
Bridge.notify.HideHelpText()
|
||||
Bridge.Notify.HideHelpText()
|
||||
if activePlacementProp == nil then return end
|
||||
DeleteObject(activePlacementProp)
|
||||
activePlacementProp = nil
|
||||
@@ -37,7 +37,7 @@ Utility.PlaceObject = function(object, distance, snapToGround, allowedMats, offs
|
||||
SetEntityInvincible(activePlacementProp, true)
|
||||
FreezeEntityPosition(activePlacementProp, true)
|
||||
|
||||
Bridge.notify.ShowHelpText(type(placementText) == 'table' and table.concat(placementText) or placementText, {
|
||||
Bridge.Notify.ShowHelpText(type(placementText) == 'table' and table.concat(placementText) or placementText, {
|
||||
position = "left-center",
|
||||
})
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ BridgeClientConfig = {}
|
||||
BridgeClientConfig.NotifySystem = "ox" -- Change this to your notification system (ox/qb/esx?)
|
||||
BridgeClientConfig.ZoneSystem = "ox" -- Change this to your dialog system (ox/poly)
|
||||
BridgeClientConfig.InputSystem = "ox" -- Change this to your Input system (ox/qb)
|
||||
BridgeClientConfig.MenuSystem = "ox" -- Change this to your Menu system (ox/qb)
|
||||
BridgeClientConfig.MenuSystem = "auto" -- Change this to your Menu system (ox/qb)
|
||||
BridgeClientConfig.ProgressBar = "ox" -- Change this to your preferred progress bar (ox/qb)
|
||||
BridgeClientConfig.DebugLevel = 3 -- Change this to your Debug level, 1 for none, 2 for some, 3 for all data
|
||||
BridgeClientConfig.ShowHelpText = "ox" --
|
||||
|
||||
Reference in new issue
Block a user