Merge pull request #194 from TheOrderFivem/dev

Dev
This commit is contained in:
MrNewb authored and GitHub committed 2026-05-30 13:56:17 -04:00
commit d9d1a4af00
14 files changed
+583 -39

No files matched your search

+2 -2
View File
@@ -5,7 +5,7 @@ use_experimental_fxv2_oal 'yes'
author 'The Order of the Sacred Framework'
name 'community_bridge'
description 'A Universal Bridge for Our Community, created by a group of contributors with a shared vision to enhance both user and developer experiences. This bridge connects various frameworks, inventories, target systems, notification systems, and more, fostering compatibility and seamless integration.'
version '0.13.3'
version '0.13.4'
shared_scripts {
'@ox_lib/init.lua',
@@ -45,7 +45,7 @@ client_scripts {
'modules/doorlock/**/client.lua',
'modules/phone/**/client.lua',
'modules/weather/**/client.lua',
'modules/vehicleKey/**/client.lua',
'modules/vehiclekey/**/client.lua',
'modules/fuel/**/client.lua',
'modules/target/**/client.lua',
'modules/dispatch/**/client.lua',
+68
View File
@@ -0,0 +1,68 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('DHS-BankingSim') == 'missing' then return end
Banking = Banking or {}
local dhsBanking = exports['DHS-BankingSim']
--- Helper: resolve business account ID from a job/society name
---@param account string Job or society name (e.g. 'police', 'ambulance')
---@return number|nil businessId
local function ResolveBusinessId(account)
local row = MySQL.single.await(
'SELECT id FROM business_accounts WHERE job_name = ? AND status = ? LIMIT 1',
{ account, 'active' }
)
return row and row.id or nil
end
---This will get the name of the Managment system being being used.
---@return string
Banking.GetManagmentName = function()
return 'DHS-BankingSim'
end
---This will get the name of the in use resource.
---@return string
Banking.GetResourceName = function()
return 'DHS-BankingSim'
end
---This will return a number
---@param account string
---@return number
Banking.GetAccountMoney = function(account)
local businessId = ResolveBusinessId(account)
if not businessId then return 0 end
local balance = dhsBanking:GetBusinessBalance(businessId)
return balance or 0
end
---This will add money to the specified account of the passed amount
---@param account string
---@param amount number
---@param reason string
---@return boolean
Banking.AddAccountMoney = function(account, amount, reason)
local businessId = ResolveBusinessId(account)
if not businessId then return false end
reason = reason or 'Community Bridge deposit'
MySQL.update.await('UPDATE business_accounts SET balance = balance + ? WHERE id = ?', { amount, businessId })
return true
end
---This will remove money from the specified account of the passed amount
---@param account string
---@param amount number
---@param reason string
---@return boolean
Banking.RemoveAccountMoney = function(account, amount, reason)
local businessId = ResolveBusinessId(account)
if not businessId then return false end
reason = reason or 'Community Bridge withdrawal'
local row = MySQL.single.await('SELECT balance FROM business_accounts WHERE id = ?', { businessId })
if not row or (tonumber(row.balance) or 0) < amount then return false end
MySQL.update.await('UPDATE business_accounts SET balance = balance - ? WHERE id = ?', { amount, businessId })
return true
end
return Banking
+4
View File
@@ -18,6 +18,10 @@ RegisterNetEvent('community_bridge:client:OpenBossMenu', function(jobName, jobTy
end, {wash = false})
elseif BossMenu.GetResourceName() == "qbx_management" then
exports.qbx_management:OpenBossMenu(jobType)
elseif BossMenu.GetResourceName() == "tk_bosstablet" then
exports.tk_bosstablet:openBossMenu()
elseif BossMenu.GetResourceName() == "zat-bossmenu" then
exports['zat-bossmenu']:OpenBossMenu(jobType or 'job')
end
end)
+12
View File
@@ -0,0 +1,12 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('tk_bosstablet') ~= 'started' then return end
BossMenu = BossMenu or {}
---This will get the name of the module being used.
---@return string
BossMenu.GetResourceName = function()
return "tk_bosstablet"
end
return BossMenu
+16
View File
@@ -0,0 +1,16 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('tk_bosstablet') ~= 'started' then return end
BossMenu = BossMenu or {}
---This will get the name of the module being used.
---@return string
BossMenu.GetResourceName = function()
return "tk_bosstablet"
end
BossMenu.OpenBossMenu = function(src, jobName, jobType)
TriggerClientEvent("community_bridge:client:OpenBossMenu", src, jobName, jobType)
end
return BossMenu
+12
View File
@@ -0,0 +1,12 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('zat-bossmenu') ~= 'started' then return end
BossMenu = BossMenu or {}
---This will get the name of the module being used.
---@return string
BossMenu.GetResourceName = function()
return "zat-bossmenu"
end
return BossMenu
+16
View File
@@ -0,0 +1,16 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('zat-bossmenu') ~= 'started' then return end
BossMenu = BossMenu or {}
---This will get the name of the module being used.
---@return string
BossMenu.GetResourceName = function()
return "zat-bossmenu"
end
BossMenu.OpenBossMenu = function(src, jobName, jobType)
TriggerClientEvent("community_bridge:client:OpenBossMenu", src, jobName, jobType)
end
return BossMenu
+38 -1
View File
@@ -8,4 +8,41 @@ Dispatch.GetResourceName = function()
return 'fd_dispatch'
end
return Dispatch
Dispatch.SendAlert = function(data)
local metadata = {}
if data.vehicle then
table.insert(metadata, {
type = 'vehicle',
model = data.vehicle or locale('unknown_vehicle_model'),
plate = data.plate or nil,
color = data.colorHex or nil
})
end
if type(data.job) == "string" then
data.job = {data.job}
end
local coords = data.coords or GetEntityCoords(GetPlayerPed(data.source))
local alertData = {
source = data.source,
title = data.title or "No message provided",
description = data.message or "",
groups = data.jobs or data.job or {"police"},
code = data.code or '10-80',
priority = data.priority or 2,
metadata = metadata,
blip = {
title = data.title or "No message provided",
coords = coords,
radius = data.blip and data.blip.radius or nil,
sprite = data.blip and data.blip.sprite or 161,
color = data.blip and data.blip.color or 1,
scale = data.blip and data.blip.scale or 1.2,
flashes = data.blip.flash or false,
time = data.time or (6 * 60000),
category = data.category or nil,
},
}
exports.fd_dispatch:addAlert(alertData)
end
return Dispatch
+11 -15
View File
@@ -1,8 +1,6 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('core_inventory') == 'missing' then return end
local core = exports.core_inventory
-- Core inventory docs available at https://docs.c8re.store/core-inventory/api/server#getitemslist
Callback = Callback or Require("lib/callback/shared/callback.lua")
Inventory = Inventory or {}
@@ -14,7 +12,7 @@ end
local cachedItemList = nil
--- Return the item info in oxs format, {name, label, stack, weight, description, image}
--- https://docs.c8re.store/core-inventory/api/server#getitemslist
--- https://docs.c8re.store/core-inventory/exports#client-exports-%E2%80%94-inventory-ui
--- @param item string
--- @return table
Inventory.GetItemInfo = function(item)
@@ -22,24 +20,22 @@ Inventory.GetItemInfo = function(item)
return itemList[item] or {}
end
---This will return the entire items table from the inventory.
---This will return the entire items table from the inventory in the ox format.
---@return table
Inventory.Items = function()
local frameworkName = Framework.GetFrameworkName()
if not frameworkName then return {} end
if cachedItemList then return cachedItemList end
local allItems = core:getItemsList()
if not allItems then return {} end
local dataRepack = {}
if frameworkName == 'es_extended' then
if not cachedItemList then cachedItemList = Callback.Trigger('community_bridge:Callback:core_inventory', false) end
dataRepack = cachedItemList or {}
elseif frameworkName == 'qb-core' then
dataRepack = Framework.Shared.Items or {}
end
for itemName, itemData in pairs(dataRepack) do
for itemName, itemData in pairs(allItems) do
if itemData and itemData.name then
dataRepack[itemName].image = Inventory.GetImagePath(itemData.name)
dataRepack[itemName].stack = dataRepack[itemName].unique or false
dataRepack[itemName] = {
image = Inventory.GetImagePath(itemData.name),
stack = itemData.unique or false
}
end
end
cachedItemList = dataRepack
return dataRepack
end
+3 -19
View File
@@ -3,7 +3,6 @@ if GetResourceState('core_inventory') == 'missing' then return end
Inventory = Inventory or {}
Inventory.Stashes = Inventory.Stashes or {}
Callback = Callback or Require("lib/callback/shared/callback.lua")
local core = exports.core_inventory
---This will get the name of the in use resource.
@@ -20,8 +19,7 @@ end
---@param metadata table
---@return boolean
Inventory.AddItem = function(src, item, count, slot, metadata)
-- docs specify a table returned on success, on failure it returns false.
-- https://docs.c8re.store/core-inventory/api/server#additem
-- https://docs.c8re.store/core-inventory/exports#server-exports-%E2%80%94-items
local success = core:addItem(src, item, count, metadata)
if not success then return false end
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
@@ -48,16 +46,8 @@ Inventory.RemoveItem = function(src, item, count, slot, metadata)
end
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata})
if slot then
local identifier = Framework.GetPlayerIdentifier(src)
if not identifier then return false end
local framework = Bridge.Framework.GetFrameworkName()
if framework == 'es_extended' then
identifier = string.gsub(identifier, ":", "")
end
local weirdInventoryName = 'content-' .. identifier
-- No return value specified in docs, so we assume none.
-- https://docs.c8re.store/core-inventory/api/server#removeitemexact
return core:removeItemExact(weirdInventoryName, slot, count)
-- https://docs.c8re.store/core-inventory/exports#server-exports-%E2%80%94-items
return core:removeItemExact(src, slot, count)
end
core:removeItem(src, item, count)
return true
@@ -249,12 +239,6 @@ Inventory.GetImagePath = function(item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
---This is used for the esx users, documentation doesnt show a client side available option for the inventory so we use jank callbacks to get this.
Callback.Register('community_bridge:Callback:core_inventory', function(source)
local items = core:getItemsList()
return items or {}
end)
---This will return the entire items table from the inventory.
---@return table
Inventory.Items = function()
@@ -0,0 +1,72 @@
--[[
Get this inventory here https://onestudios.gg/
]]--
---@diagnostic disable: duplicate-set-field
if GetResourceState('one_inventory') == 'missing' then return end
local inv = exports['one_inventory']
Inventory = Inventory or {}
---@description This will get the name of the in use resource.
---@return string
Inventory.GetResourceName = function()
return "one_inventory"
end
---@description Return the item info in oxs format, {name, label, stack, weight, description, image}
---@param item string
---@return table
Inventory.GetItemInfo = function(item)
local itemData = inv:GetItemDefinition(item)
if not itemData then return {} end
return {
name = itemData.name,
label = itemData.label,
stack = itemData.unique,
weight = itemData.weight,
description = itemData.description,
image = Inventory.GetImagePath(itemData.image or itemData.name)
}
end
---@description This will return the entire items table from the inventory.
---@return table
Inventory.Items = function()
return inv:GetAllItemDefinitions()
end
---@description Will return boolean if the player has the item.
---@param item string
---@param requiredCount number (optional)
---@return boolean
Inventory.HasItem = function(item, requiredCount)
return inv:HasItem(item, requiredCount or 1)
end
---@description This will return their count of the item in the players inventory, if not found will return 0.
---@param item string
---@return number
Inventory.GetItemCount = function(item)
return inv:GetItemCount(item, nil)
end
---@description This will get the image path for this item, if not found will return placeholder.
---@param item string
---@return string
Inventory.GetImagePath = function(item)
item = Inventory.StripPNG(item)
local file = LoadResourceFile("one_inventory", string.format("web/images/%s.png", item))
local imagePath = file and string.format("nui://one_inventory/web/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
---@description This will return the players inventory in the format of {name, label, count, slot, metadata}
---@return table
Inventory.GetPlayerInventory = function()
return inv:GetInventoryItems()
end
return Inventory
+247
View File
@@ -0,0 +1,247 @@
--[[
Get this inventory here https://onestudios.gg/
]]--
---@diagnostic disable: duplicate-set-field
if GetResourceState('one_inventory') == 'missing' then return end
local inv = exports['one_inventory']
Inventory = Inventory or {}
Inventory.Stashes = Inventory.Stashes or {}
Inventory.Version = nil
Inventory.ShopData = {}
---@description This will get the name of the in use resource.
---@return string
Inventory.GetResourceName = function()
return "one_inventory"
end
---@description This will add an item, and return true or false based on success
---@param src number
---@param item string
---@param count number
---@param slot number (optional)
---@param metadata table (optional)
---@return boolean
Inventory.AddItem = function(src, item, count, slot, metadata)
local success = inv:AddItem(src, item, count, metadata, slot)
if not success then return false end
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
return success or false
end
---@description This will remove an item, and return true or false based on success
---@param src number
---@param item string
---@param count number
---@param slot number (optional)
---@param metadata table (optional)
---@return boolean
Inventory.RemoveItem = function(src, item, count, slot, metadata)
local success = inv:RemoveItem(src, item, count, metadata, slot)
if not success then return false end
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata})
return success or false
end
---@description This will return a table with the item info, {name, label, stack, weight, description, image}
---@param item string
---@return table
Inventory.GetItemInfo = function(item)
local itemData = inv:GetItemDefinition(item)
if not itemData then return {} end
return {
name = itemData.name,
label = itemData.label,
stack = itemData.unique,
weight = itemData.weight,
description = itemData.description,
image = Inventory.GetImagePath(itemData.image or itemData.name)
}
end
---@description This will return the entire items table from the inventory.
---@return table
Inventory.Items = function()
return inv:GetAllItemDefinitions()
end
---@description This will return the count of the item in the players inventory, if not found will return 0.
---@param src number
---@param item string
---@param metadata table (optional)
---@return number
Inventory.GetItemCount = function(src, item, metadata)
return inv:GetItemCount(src, item, metadata)
end
---@description This wil return the players inventory.
---@param src number
---@return table
Inventory.GetPlayerInventory = function(src)
return inv:GetInventoryItems(src)
end
---@description Returns the specified slot data as a table.
---@param src number
---@param slot number
---@return table {weight, name, metadata, slot, label, count}
Inventory.GetItemBySlot = function(src, slot)
local slotData = inv:GetSlot(src, slot)
print("GetItemBySlot".. json.encode(slotData), {indent = true})
if not slotData then return {} end
return {
name = slotData.name,
label = slotData.name,
weight = slotData.weight,
slot = slotData.slot,
count = slotData.amount or slotData.count,
metadata = slotData.info or slotData.metadata,
stack = slotData.unique,
description = slotData.description
}
end
---@description This will set the metadata of an item in the inventory.
---@param src number
---@param item string
---@param slot number
---@param metadata table
---@return nil
Inventory.SetMetadata = function(src, item, slot, metadata)
inv:SetItemMetadata(src, slot, metadata)
end
---@description This will open the specified stash for the src passed.
---@param src number
---@param _type string "stash", "trunk", "glovebox"
---@param id string
---@return nil
Inventory.OpenStash = function(src, _type, id)
_type = _type or "stash:"
if _type == "trunk" then
_type = "vehicle:trunk:"
elseif _type == "glovebox" then
_type = "vehicle:glovebox:"
elseif _type ~= "stash" then
_type = "stash:"
end
return inv:OpenInventory(src, _type, {id = id})
end
---@description This will add items to a stash, and return true or false based on success
---@param id string
---@param items table {item, count, metadata}
---@return boolean
Inventory.AddStashItems = function(id, items)
if type(items) ~= "table" then return false end
local success = false
for _, item in pairs(items) do
success = inv:AddItem(id, item.item, item.amount or item.count, item.metadata or item.info or {}, nil)
end
return success
end
---@description This will add items to a trunk, and return true or false based on success
---@param identifier string
---@param items table
---@return boolean
Inventory.AddTrunkItems = function(identifier, items)
if type(items) ~= "table" then return false end
local fullTrunkId = "vehicle:trunk:"..identifier
Wait(1000)
for i = 1, #items do
inv:AddItem(fullTrunkId, items[i].name, items[i].amount or items[i].count, items[i].metadata or items[i].info or {}, nil)
end
return true
end
---@description This will clear the specified inventory, will always return true unless a value isnt passed correctly.
---@param id string
---@return boolean
Inventory.ClearStash = function(id, _type)
if type(id) ~= "string" then return false end
if Inventory.Stashes[id] then Inventory.Stashes[id] = nil end
if _type == "trunk" then
id = "vehicle:trunk:"..id
elseif _type == "glovebox" then
id = "vehicle:glovebox:"..id
elseif _type ~= "stash" then
id = "stash:"..id
end
inv:ClearInventory(id, false, false)
return true
end
---@description This will return a boolean if the player has the item.
---@param src number
---@param item string
---@param requiredCount number (optional)
---@return boolean
Inventory.HasItem = function(src, item, requiredCount)
return inv:HasItem(src, item, requiredCount or 1, nil)
end
---@description This is to get if there is available space in the inventory, will return boolean.
---@param src number
---@param item string
---@param count number
---@return boolean
Inventory.CanCarryItem = function(src, item, count)
return inv:CanCarryItem(src, item, count)
end
---@description This will get the image path for an item, it is an alternate option to GetItemInfo. If a image isnt found will revert to community_bridge logo (useful for menus)
---@param item string
---@return string
Inventory.GetImagePath = function(item)
item = Inventory.StripPNG(item)
local file = LoadResourceFile("one_inventory", string.format("web/images/%s.png", item))
local imagePath = file and string.format("nui://one_inventory/web/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
---@description This will update the plate to the vehicle inside the inventory. (It will also update with jg-mechanic if using it)
---@param oldplate string
---@param newplate string
---@return boolean
Inventory.UpdatePlate = function(oldplate, newplate)
inv:UpdateVehiclePlate(oldplate, newplate)
if GetResourceState('jg-mechanic') == 'missing' then return true end
return true, exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate)
end
---@description This will open the specified shop for the src passed.
---@param src number
---@param shopTitle string
Inventory.OpenShop = function(src, shopTitle)
return inv:OpenInventory(src, "shop", shopTitle)
end
---@description This will register a shop, if it already exists it will return true.
---@param shopTitle string
---@param inventory table
---@param shopCoords table
---@param shopGroups table
Inventory.RegisterShop = function(shopTitle, inventory, shopCoords, shopGroups)
return false, print(shopTitle.." is not a valid shop type for one_inventory, please use the shop types defined in the documentation.")
end
---@description This will open a players inventory, used for admin purposes and stuff.
---@param src number
---@param target number
Inventory.OpenPlayerInventory = function(src, target)
assert(src, "OpenPlayerInventory: src is required")
assert(target, "OpenPlayerInventory: target is required")
inv:OpenInventory(src, "player:", target)
end
return Inventory
+47
View File
@@ -0,0 +1,47 @@
---@diagnostic disable: duplicate-set-field
Notify = Notify or {}
local resourceName = "solaire_notify"
local configValue = BridgeSharedConfig.Notify
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
Notify.SendNotify = function(message, _type, time)
time = time or 3000
return exports.solaire_notify:Notify({ type = _type or "info", message = message, duration = time })
end
---This will send a notify message of the type and time passed
---@param title string
---@param message string
---@param _type string
---@param time number
---@param props table | nil
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title or title == "" then title = placeHolderText end
props = props or {}
return exports.solaire_notify:Notify({
type = _type or "info",
title = title,
message = message,
duration = time,
position = props.position or "top-right",
sound = props.sound,
item = props.item,
volume = props.volume
})
end
return Notify
+35 -2
View File
@@ -7,6 +7,11 @@ local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or
local ox_target = exports.ox_target
local targetZones = {}
local resourceTargets = {}
resourceTargets.models = {}
resourceTargets.entities = {}
resourceTargets.networkedEntities = {}
Target.GetResourceName = function()
return "ox_target"
end
@@ -99,6 +104,9 @@ end
function Target.AddLocalEntity(entities, options)
options = Target.FixOptions(options)
ox_target:addLocalEntity(entities, options)
local resource = GetInvokingResource()
resourceTargets.entities[resource] = resourceTargets.entities[resource] or {}
table.insert(resourceTargets.entities[resource], { entities = entities})
end
---This will remove the target options from a local entity. This is useful for when you want to remove target options from a specific entity.
@@ -114,6 +122,9 @@ end
function Target.AddNetworkedEntity(netids, options)
options = Target.FixOptions(options)
ox_target:addEntity(netids, options)
local resource = GetInvokingResource()
resourceTargets.networkedEntities[resource] = resourceTargets.networkedEntities[resource] or {}
table.insert(resourceTargets.networkedEntities[resource], { netids = netids})
end
---This will remove a networked entity from the target system.
@@ -129,6 +140,9 @@ end
function Target.AddModel(models, options)
options = Target.FixOptions(options)
ox_target:addModel(models, options)
local resource = GetInvokingResource()
resourceTargets.models[resource] = resourceTargets.models[resource] or {}
table.insert(resourceTargets.models[resource], { models = models})
end
---This will remove target options from all specified models.
@@ -189,13 +203,32 @@ function Target.RemoveZone(name)
end
AddEventHandler('onResourceStop', function(resource)
if resource ~= GetCurrentResourceName() then return end
for _, target in pairs(targetZones) do
if target.creator == resource then
ox_target:removeZone(target.id)
end
end
targetZones = {}
if resourceTargets.entities[resource] and #resourceTargets.entities[resource] > 0 then
for _, data in pairs(resourceTargets.entities[resource]) do
Target.RemoveLocalEntity(data.entities)
end
end
resourceTargets.entities[resource] = nil
if resourceTargets.networkedEntities[resource] and #resourceTargets.networkedEntities[resource] > 0 then
for _, data in pairs(resourceTargets.networkedEntities[resource]) do
Target.RemoveNetworkedEntity(data.netids)
end
end
resourceTargets.networkedEntities[resource] = nil
if resourceTargets.models[resource] and #resourceTargets.models[resource] > 0 then
for _, data in pairs(resourceTargets.models[resource]) do
for _, model in pairs(data.models) do
ox_target:removeModel(model)
end
end
end
resourceTargets.models[resource] = nil
end)
return Target
return Target