24 files changed
+925
-64
No files matched your search
@@ -4,17 +4,16 @@ on:
|
|||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
send-webhook:
|
send-webhook:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
# Reads only the release event payload, so no checkout is needed and jq
|
||||||
uses: actions/checkout@v3
|
# is already present on the runner image.
|
||||||
|
|
||||||
- name: Install jq
|
|
||||||
run: sudo apt-get update && sudo apt-get install -y jq
|
|
||||||
|
|
||||||
- name: Send webhook notification
|
- name: Send webhook notification
|
||||||
env:
|
env:
|
||||||
WEBHOOK_URL: ${{ secrets.RELEASE_WEBHOOK_URL }}
|
WEBHOOK_URL: ${{ secrets.RELEASE_WEBHOOK_URL }}
|
||||||
@@ -57,7 +56,7 @@ jobs:
|
|||||||
"type": 2,
|
"type": 2,
|
||||||
"style": 5,
|
"style": 5,
|
||||||
"label": "Get The Latest Community Bridge Release",
|
"label": "Get The Latest Community Bridge Release",
|
||||||
"url": "https://github.com/The-Order-Of-The-Sacred-Framework/community_bridge/tree/main"
|
"url": "https://github.com/TheOrderFivem/community_bridge/releases/latest"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
# Publishes a release when a push to main bumps the fxmanifest.lua version.
|
||||||
|
# Tags/titles are bare versions (0.13.4) to match this repo's existing releases.
|
||||||
|
#
|
||||||
|
# The "Update Webhook Notification" workflow listens for release:published, and
|
||||||
|
# GitHub suppresses workflow triggers for events raised by GITHUB_TOKEN. Add a
|
||||||
|
# classic PAT with repo scope as the RELEASE_PAT secret to keep the Discord
|
||||||
|
# announcement firing; without it the release still publishes, silently.
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'fxmanifest.lua'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-version:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
should_release: ${{ steps.meta.outputs.should_release }}
|
||||||
|
version: ${{ steps.meta.outputs.version }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Detect fxmanifest version change
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
CURRENT=$(grep -E '^version ' fxmanifest.lua | sed -E "s/^version[[:space:]]+['\"]([^'\"]+)['\"].*/\1/")
|
||||||
|
echo "version=$CURRENT" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
if [ -z "$CURRENT" ]; then
|
||||||
|
echo "::error::No version found in fxmanifest.lua"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Never re-release an existing version: a duplicate release would
|
||||||
|
# announce itself to Discord as if it were new.
|
||||||
|
if git rev-parse "refs/tags/$CURRENT" >/dev/null 2>&1; then
|
||||||
|
echo "should_release=false" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Tag $CURRENT already exists; skipping release."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
echo "should_release=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Manual run; releasing version $CURRENT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
BEFORE="${{ github.event.before }}"
|
||||||
|
if [ "$BEFORE" = "0000000000000000000000000000000000000000" ] || [ -z "$BEFORE" ]; then
|
||||||
|
echo "should_release=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Initial or force push; releasing version $CURRENT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
PREVIOUS=$(git show "$BEFORE:fxmanifest.lua" 2>/dev/null | grep -E '^version ' | sed -E "s/^version[[:space:]]+['\"]([^'\"]+)['\"].*/\1/" || true)
|
||||||
|
if [ "$CURRENT" = "$PREVIOUS" ]; then
|
||||||
|
echo "should_release=false" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "fxmanifest changed but version is still $CURRENT; skipping release."
|
||||||
|
else
|
||||||
|
echo "should_release=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Version updated: ${PREVIOUS:-unknown} -> $CURRENT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: check-version
|
||||||
|
if: needs.check-version.outputs.should_release == 'true'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Prepare release package
|
||||||
|
run: |
|
||||||
|
RELEASE_ROOT="release/community_bridge"
|
||||||
|
mkdir -p "$RELEASE_ROOT/web"
|
||||||
|
|
||||||
|
rsync -a \
|
||||||
|
--exclude '.git' \
|
||||||
|
--exclude '.gitattributes' \
|
||||||
|
--exclude '.gitignore' \
|
||||||
|
--exclude '.github' \
|
||||||
|
--exclude 'release' \
|
||||||
|
--exclude 'node_modules' \
|
||||||
|
--exclude 'web' \
|
||||||
|
./ "$RELEASE_ROOT/"
|
||||||
|
|
||||||
|
# Pre-built web/dist/ is committed; ship the built UI only and leave
|
||||||
|
# the vite source and tooling (src/, package.json, configs) behind.
|
||||||
|
rsync -a web/dist/ "$RELEASE_ROOT/web/dist/"
|
||||||
|
rsync -a web/public/ "$RELEASE_ROOT/web/public/"
|
||||||
|
|
||||||
|
- name: Create zip archive
|
||||||
|
run: |
|
||||||
|
cd release
|
||||||
|
zip -r "../community_bridge.zip" community_bridge
|
||||||
|
|
||||||
|
- name: Upload workflow artifact
|
||||||
|
uses: actions/upload-artifact@v5
|
||||||
|
with:
|
||||||
|
name: community_bridge
|
||||||
|
path: community_bridge.zip
|
||||||
|
|
||||||
|
- name: Publish GitHub Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.RELEASE_PAT || github.token }}
|
||||||
|
tag_name: ${{ needs.check-version.outputs.version }}
|
||||||
|
name: ${{ needs.check-version.outputs.version }}
|
||||||
|
files: community_bridge.zip
|
||||||
|
generate_release_notes: true
|
||||||
@@ -56,7 +56,7 @@ By bridging core game systems including inventory, dispatch, targeting, door loc
|
|||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Complete developer documentation is available at:
|
Complete developer documentation is available at:
|
||||||
[Community Bridge Documentation](https://theorderfivem.github.io/public_docs/)
|
[Community Bridge Documentation](https://theorderfivem.github.io/docs)
|
||||||
---
|
---
|
||||||
|
|
||||||
## Community and Support
|
## Community and Support
|
||||||
@@ -69,7 +69,6 @@ Join the Community Bridge Discord server for support, discussion, and contributi
|
|||||||
## About Community Bridge
|
## About Community Bridge
|
||||||
|
|
||||||
community_bridge is developed by The Order of the Sacred Framework, a collaborative team focused on improving interoperability and reducing development friction in the FiveM ecosystem. The project is open source and licensed under GPLv3.
|
community_bridge is developed by The Order of the Sacred Framework, a collaborative team focused on improving interoperability and reducing development friction in the FiveM ecosystem. The project is open source and licensed under GPLv3.
|
||||||
We also have a vscode extension located at https://marketplace.visualstudio.com/items?itemName=TheOrderOfTheSacredFramework.fivem-community-bridge-lua
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -5,7 +5,7 @@ use_experimental_fxv2_oal 'yes'
|
|||||||
author 'The Order of the Sacred Framework'
|
author 'The Order of the Sacred Framework'
|
||||||
name 'community_bridge'
|
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.'
|
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.5'
|
||||||
|
|
||||||
shared_scripts {
|
shared_scripts {
|
||||||
'@ox_lib/init.lua',
|
'@ox_lib/init.lua',
|
||||||
@@ -45,7 +45,7 @@ client_scripts {
|
|||||||
'modules/doorlock/**/client.lua',
|
'modules/doorlock/**/client.lua',
|
||||||
'modules/phone/**/client.lua',
|
'modules/phone/**/client.lua',
|
||||||
'modules/weather/**/client.lua',
|
'modules/weather/**/client.lua',
|
||||||
'modules/vehicleKey/**/client.lua',
|
'modules/vehiclekey/**/client.lua',
|
||||||
'modules/fuel/**/client.lua',
|
'modules/fuel/**/client.lua',
|
||||||
'modules/target/**/client.lua',
|
'modules/target/**/client.lua',
|
||||||
'modules/dispatch/**/client.lua',
|
'modules/dispatch/**/client.lua',
|
||||||
|
|||||||
@@ -1,21 +1,67 @@
|
|||||||
|
--[[
|
||||||
|
DEPRECATED: the SQL helper module is deprecated in its entirety and will be
|
||||||
|
REMOVED on 2026-08-22. Migrate to oxmysql directly — MySQL.query.await(query,
|
||||||
|
params) with ? placeholders — which is safer and more flexible than these
|
||||||
|
wrappers ever were.
|
||||||
|
]]
|
||||||
|
|
||||||
SQL = {}
|
SQL = {}
|
||||||
|
|
||||||
Require("lib/MySQL.lua", "oxmysql")
|
Require("lib/MySQL.lua", "oxmysql")
|
||||||
|
|
||||||
|
local warnedResources = {}
|
||||||
|
|
||||||
|
local function warnDeprecated()
|
||||||
|
local caller = GetInvokingResource() or GetCurrentResourceName()
|
||||||
|
if warnedResources[caller] then return end
|
||||||
|
warnedResources[caller] = true
|
||||||
|
print(("^3[community_bridge] SQL helpers are deprecated and will be REMOVED on 2026-08-22. '%s' should migrate to oxmysql directly (MySQL.query.await with ? placeholders).^0"):format(caller))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Identifiers (table/column names) cannot be parameterized, so they are
|
||||||
|
-- validated against a strict pattern and backtick-quoted instead. Values are
|
||||||
|
-- never concatenated into queries - they always go through ? placeholders.
|
||||||
|
local function quoteIdentifier(name)
|
||||||
|
assert(type(name) == "string" and name:match("^[%a_][%w_]*$"),
|
||||||
|
("SQL: unsafe identifier '%s' - table/column names may only contain letters, digits and underscores"):format(tostring(name)))
|
||||||
|
return "`" .. name .. "`"
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Builds a parameterized WHERE clause from a table of column = value pairs.
|
||||||
|
-- Raw WHERE strings are intentionally rejected: they made SQL injection
|
||||||
|
-- unavoidable whenever a player-influenced value reached these helpers.
|
||||||
|
local function buildWhere(where)
|
||||||
|
assert(type(where) == "table" and next(where) ~= nil,
|
||||||
|
"SQL: where must be a non-empty table of column = value pairs (raw WHERE strings are no longer accepted)")
|
||||||
|
|
||||||
|
local conditions = {}
|
||||||
|
local params = {}
|
||||||
|
|
||||||
|
for column, value in pairs(where) do
|
||||||
|
table.insert(conditions, quoteIdentifier(column) .. " = ?")
|
||||||
|
table.insert(params, value)
|
||||||
|
end
|
||||||
|
|
||||||
|
return table.concat(conditions, " AND "), params
|
||||||
|
end
|
||||||
|
|
||||||
--- Creates a table in the database if it does not exist.
|
--- Creates a table in the database if it does not exist.
|
||||||
-- @param tableName The name of the table to create. Example: {{ name = "identifier", type = "VARCHAR(50)", primary = true }}
|
-- @param tableName The name of the table to create. Example: {{ name = "identifier", type = "VARCHAR(50)", primary = true }}
|
||||||
-- @param columns A table containing column definitions, where each column is a table with 'name' and 'type'.
|
-- @param columns A table containing column definitions, where each column is a table with 'name' and 'type'.
|
||||||
---@return nil
|
---@return nil
|
||||||
|
|
||||||
|
---@deprecated Removed on 2026-08-22 — use oxmysql directly.
|
||||||
function SQL.Create(tableName, columns)
|
function SQL.Create(tableName, columns)
|
||||||
|
warnDeprecated()
|
||||||
assert(MySQL, "Tried using module SQL without MySQL being loaded")
|
assert(MySQL, "Tried using module SQL without MySQL being loaded")
|
||||||
local columnsList = {}
|
local columnsList = {}
|
||||||
for i, column in pairs(columns) do
|
for i, column in pairs(columns) do
|
||||||
table.insert(columnsList, string.format("%s %s", column.name, column.type))
|
assert(type(column.type) == "string", "SQL: column type must be a string")
|
||||||
|
table.insert(columnsList, string.format("%s %s", quoteIdentifier(column.name), column.type))
|
||||||
end
|
end
|
||||||
|
|
||||||
local query = string.format("CREATE TABLE IF NOT EXISTS %s (%s);",
|
local query = string.format("CREATE TABLE IF NOT EXISTS %s (%s);",
|
||||||
tableName,
|
quoteIdentifier(tableName),
|
||||||
table.concat(columnsList, ", ")
|
table.concat(columnsList, ", ")
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,50 +69,70 @@ function SQL.Create(tableName, columns)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- insert if not exist otherwise update
|
-- insert if not exist otherwise update
|
||||||
|
---@deprecated Removed on 2026-08-22 — use oxmysql directly.
|
||||||
function SQL.InsertOrUpdate(tableName, data)
|
function SQL.InsertOrUpdate(tableName, data)
|
||||||
|
warnDeprecated()
|
||||||
assert(MySQL, "Tried using module SQL without MySQL being loaded")
|
assert(MySQL, "Tried using module SQL without MySQL being loaded")
|
||||||
local columns = {}
|
local columns = {}
|
||||||
local values = {}
|
local placeholders = {}
|
||||||
local updates = {}
|
local updates = {}
|
||||||
|
local params = {}
|
||||||
|
|
||||||
for column, value in pairs(data) do
|
for column, value in pairs(data) do
|
||||||
table.insert(columns, column)
|
local quoted = quoteIdentifier(column)
|
||||||
table.insert(values, "'" .. value .. "'") -- Ensure values are properly quoted
|
table.insert(columns, quoted)
|
||||||
table.insert(updates, column .. " = VALUES(" .. column .. ")") -- Use VALUES() for update
|
table.insert(placeholders, "?")
|
||||||
|
table.insert(updates, quoted .. " = VALUES(" .. quoted .. ")") -- Use VALUES() for update
|
||||||
|
table.insert(params, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
local query = string.format(
|
local query = string.format(
|
||||||
"INSERT INTO %s (%s) VALUES (%s) ON DUPLICATE KEY UPDATE %s;",
|
"INSERT INTO %s (%s) VALUES (%s) ON DUPLICATE KEY UPDATE %s;",
|
||||||
tableName,
|
quoteIdentifier(tableName),
|
||||||
table.concat(columns, ", "),
|
table.concat(columns, ", "),
|
||||||
table.concat(values, ", "),
|
table.concat(placeholders, ", "),
|
||||||
table.concat(updates, ", ")
|
table.concat(updates, ", ")
|
||||||
)
|
)
|
||||||
|
|
||||||
MySQL.query.await(query)
|
MySQL.query.await(query, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Selects rows matching the given filters.
|
||||||
|
-- @param tableName The table to query.
|
||||||
|
-- @param where Table of column = value pairs, joined with AND. Example: { citizenid = cid }
|
||||||
|
---@deprecated Removed on 2026-08-22 — use oxmysql directly.
|
||||||
function SQL.Get(tableName, where)
|
function SQL.Get(tableName, where)
|
||||||
|
warnDeprecated()
|
||||||
assert(MySQL, "Tried using module SQL without MySQL being loaded")
|
assert(MySQL, "Tried using module SQL without MySQL being loaded")
|
||||||
local query = string.format("SELECT * FROM %s WHERE %s;", tableName, where)
|
local conditions, params = buildWhere(where)
|
||||||
local result = MySQL.query.await(query)
|
local query = string.format("SELECT * FROM %s WHERE %s;", quoteIdentifier(tableName), conditions)
|
||||||
|
local result = MySQL.query.await(query, params)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@deprecated Removed on 2026-08-22 — use oxmysql directly.
|
||||||
function SQL.GetAll(tableName)
|
function SQL.GetAll(tableName)
|
||||||
|
warnDeprecated()
|
||||||
assert(MySQL, "Tried using module SQL without MySQL being loaded")
|
assert(MySQL, "Tried using module SQL without MySQL being loaded")
|
||||||
local query = string.format("SELECT * FROM %s;", tableName)
|
local query = string.format("SELECT * FROM %s;", quoteIdentifier(tableName))
|
||||||
local result = MySQL.query.await(query)
|
local result = MySQL.query.await(query)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Deletes rows matching the given filters.
|
||||||
|
-- @param tableName The table to delete from.
|
||||||
|
-- @param where Table of column = value pairs, joined with AND. Example: { citizenid = cid }
|
||||||
|
---@deprecated Removed on 2026-08-22 — use oxmysql directly.
|
||||||
function SQL.Delete(tableName, where)
|
function SQL.Delete(tableName, where)
|
||||||
|
warnDeprecated()
|
||||||
assert(MySQL, "Tried using module SQL without MySQL being loaded")
|
assert(MySQL, "Tried using module SQL without MySQL being loaded")
|
||||||
local query = string.format("DELETE FROM %s WHERE %s;", tableName, where)
|
local conditions, params = buildWhere(where)
|
||||||
MySQL.query.await(query)
|
local query = string.format("DELETE FROM %s WHERE %s;", quoteIdentifier(tableName), conditions)
|
||||||
|
MySQL.query.await(query, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
exports('SQL', function()
|
exports('SQL', function()
|
||||||
|
warnDeprecated()
|
||||||
return SQL
|
return SQL
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -18,6 +18,10 @@ RegisterNetEvent('community_bridge:client:OpenBossMenu', function(jobName, jobTy
|
|||||||
end, {wash = false})
|
end, {wash = false})
|
||||||
elseif BossMenu.GetResourceName() == "qbx_management" then
|
elseif BossMenu.GetResourceName() == "qbx_management" then
|
||||||
exports.qbx_management:OpenBossMenu(jobType)
|
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
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -8,4 +8,41 @@ Dispatch.GetResourceName = function()
|
|||||||
return 'fd_dispatch'
|
return 'fd_dispatch'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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
|
return Dispatch
|
||||||
@@ -547,4 +547,30 @@ AddEventHandler("playerDropped", function()
|
|||||||
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Framework.Commands = Framework.Commands or {}
|
||||||
|
|
||||||
|
---@description Adds a command to the Qbox framework
|
||||||
|
---@param name string
|
||||||
|
---@param help string
|
||||||
|
---@param arguments table
|
||||||
|
---@param argsrequired boolean
|
||||||
|
---@param callback function
|
||||||
|
---@param permission string
|
||||||
|
---@param ... any
|
||||||
|
Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...)
|
||||||
|
lib.addCommand(name, {
|
||||||
|
help = help or "",
|
||||||
|
params = arguments or {},
|
||||||
|
restricted = false
|
||||||
|
}, function(source, args, raw)
|
||||||
|
if permission and permission ~= "user" then
|
||||||
|
if not Framework.GetIsFrameworkAdmin(source) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
callback(source, args or {}, raw)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
return Framework
|
return Framework
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
---@diagnostic disable: duplicate-set-field
|
---@diagnostic disable: duplicate-set-field
|
||||||
if GetResourceState('core_inventory') == 'missing' then return end
|
if GetResourceState('core_inventory') == 'missing' then return end
|
||||||
local core = exports.core_inventory
|
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 {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
@@ -14,7 +12,7 @@ end
|
|||||||
|
|
||||||
local cachedItemList = nil
|
local cachedItemList = nil
|
||||||
--- Return the item info in oxs format, {name, label, stack, weight, description, image}
|
--- 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
|
--- @param item string
|
||||||
--- @return table
|
--- @return table
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
@@ -22,24 +20,22 @@ Inventory.GetItemInfo = function(item)
|
|||||||
return itemList[item] or {}
|
return itemList[item] or {}
|
||||||
end
|
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
|
---@return table
|
||||||
Inventory.Items = function()
|
Inventory.Items = function()
|
||||||
local frameworkName = Framework.GetFrameworkName()
|
if cachedItemList then return cachedItemList end
|
||||||
if not frameworkName then return {} end
|
local allItems = core:getItemsList()
|
||||||
|
if not allItems then return {} end
|
||||||
local dataRepack = {}
|
local dataRepack = {}
|
||||||
if frameworkName == 'es_extended' then
|
for itemName, itemData in pairs(allItems) do
|
||||||
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
|
|
||||||
if itemData and itemData.name then
|
if itemData and itemData.name then
|
||||||
dataRepack[itemName].image = Inventory.GetImagePath(itemData.name)
|
dataRepack[itemName] = {
|
||||||
dataRepack[itemName].stack = dataRepack[itemName].unique or false
|
image = Inventory.GetImagePath(itemData.name),
|
||||||
|
stack = itemData.unique or false
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
cachedItemList = dataRepack
|
||||||
return dataRepack
|
return dataRepack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ if GetResourceState('core_inventory') == 'missing' then return end
|
|||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
Inventory.Stashes = Inventory.Stashes or {}
|
Inventory.Stashes = Inventory.Stashes or {}
|
||||||
Callback = Callback or Require("lib/callback/shared/callback.lua")
|
|
||||||
local core = exports.core_inventory
|
local core = exports.core_inventory
|
||||||
|
|
||||||
---This will get the name of the in use resource.
|
---This will get the name of the in use resource.
|
||||||
@@ -20,8 +19,7 @@ end
|
|||||||
---@param metadata table
|
---@param metadata table
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
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/exports#server-exports-%E2%80%94-items
|
||||||
-- https://docs.c8re.store/core-inventory/api/server#additem
|
|
||||||
local success = core:addItem(src, item, count, metadata)
|
local success = core:addItem(src, item, count, metadata)
|
||||||
if not success then return false end
|
if not success then return false end
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
|
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
|
end
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata})
|
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata})
|
||||||
if slot then
|
if slot then
|
||||||
local identifier = Framework.GetPlayerIdentifier(src)
|
-- https://docs.c8re.store/core-inventory/exports#server-exports-%E2%80%94-items
|
||||||
if not identifier then return false end
|
return core:removeItemExact(src, slot, count)
|
||||||
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)
|
|
||||||
end
|
end
|
||||||
core:removeItem(src, item, count)
|
core:removeItem(src, item, count)
|
||||||
return true
|
return true
|
||||||
@@ -249,12 +239,6 @@ Inventory.GetImagePath = function(item)
|
|||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
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.
|
---This will return the entire items table from the inventory.
|
||||||
---@return table
|
---@return table
|
||||||
Inventory.Items = function()
|
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
|
||||||
@@ -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
|
||||||
@@ -129,9 +129,10 @@ end
|
|||||||
---@description This will return a boolean if the player has the item.
|
---@description This will return a boolean if the player has the item.
|
||||||
---@param src number
|
---@param src number
|
||||||
---@param item string
|
---@param item string
|
||||||
|
---@param requiredCount number (optional)
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Inventory.HasItem = function(src, item)
|
Inventory.HasItem = function(src, item, requiredCount)
|
||||||
return tgiann:HasItem(src, item, 1)
|
return tgiann:HasItem(src, item, requiredCount or 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@description This is to get if there is available space in the inventory, will return boolean.
|
---@description This is to get if there is available space in the inventory, will return boolean.
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
---@diagnostic disable: duplicate-set-field
|
||||||
|
Notify = Notify or {}
|
||||||
|
local resourceName = "msk_core"
|
||||||
|
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")
|
||||||
|
|
||||||
|
---DEPRICATED: PLEASE SWITCH TO Notify.SendNotification
|
||||||
|
---@param message string
|
||||||
|
---@param _type string
|
||||||
|
---@param time number
|
||||||
|
---@return nil
|
||||||
|
Notify.SendNotify = function(message, _type, time)
|
||||||
|
time = time or 3000
|
||||||
|
return exports.msk_core:Notify(nil, message, _type, 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 optional
|
||||||
|
---@return nil
|
||||||
|
Notify.SendNotification = function(title, message, _type, time, props)
|
||||||
|
time = time or 3000
|
||||||
|
if not title then title = placeHolderText end
|
||||||
|
return exports.msk_core:Notify(title, message, _type or "success", time)
|
||||||
|
end
|
||||||
|
|
||||||
|
return Notify
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
---@diagnostic disable: duplicate-set-field
|
||||||
|
local resourceName = "msk_core"
|
||||||
|
local configValue = BridgeClientConfig.ProgressBarSystem
|
||||||
|
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
|
||||||
|
|
||||||
|
ProgressBar = ProgressBar or {}
|
||||||
|
|
||||||
|
---Converts bridge/ox-style progress options into the msk_core Progress.Start format.
|
||||||
|
---@param options table
|
||||||
|
---@return table
|
||||||
|
local function convertToMsk(options)
|
||||||
|
options = options or {}
|
||||||
|
|
||||||
|
-- QB exposes animation under .animation.animDict/.anim and disables under .controlDisables
|
||||||
|
local anim = options.anim or options.animation
|
||||||
|
local animation
|
||||||
|
if anim then
|
||||||
|
animation = {
|
||||||
|
dict = anim.dict or anim.animDict,
|
||||||
|
anim = anim.clip or anim.anim,
|
||||||
|
flag = anim.flag or anim.flags or 49,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ox uses options.disable.{move,car,combat,mouse}, QB uses options.controlDisables.*
|
||||||
|
local d = options.disable or options.controlDisables or {}
|
||||||
|
local disable = {
|
||||||
|
move = d.move or d.disableMovement,
|
||||||
|
vehicle = d.car or d.disableCarMovement,
|
||||||
|
combat = d.combat or d.disableCombat,
|
||||||
|
mouse = d.mouse or d.disableMouse,
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
duration = options.duration,
|
||||||
|
text = options.label or options.text or '',
|
||||||
|
disable = disable,
|
||||||
|
animation = animation,
|
||||||
|
forceOverride = options.forceOverride,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
---This will open a progress bar (blocking until it completes).
|
||||||
|
---@param options table
|
||||||
|
---@param cb any optional callback receiving the success boolean
|
||||||
|
---@param isQBInput boolean optional
|
||||||
|
---@return boolean success true if the progress completed without being cancelled
|
||||||
|
function ProgressBar.Open(options, cb, isQBInput)
|
||||||
|
local data = convertToMsk(options)
|
||||||
|
|
||||||
|
-- msk_core Progress.Start blocks for the full duration; if it is interrupted
|
||||||
|
-- it stops early. We treat a fully elapsed bar as success.
|
||||||
|
exports.msk_core:Progressbar(data)
|
||||||
|
|
||||||
|
local active = exports.msk_core:ProgressActive()
|
||||||
|
local success = not active
|
||||||
|
|
||||||
|
if cb then cb(success) end
|
||||||
|
return success
|
||||||
|
end
|
||||||
|
|
||||||
|
ProgressBar.GetResourceName = function()
|
||||||
|
return resourceName
|
||||||
|
end
|
||||||
|
|
||||||
|
return ProgressBar
|
||||||
@@ -7,6 +7,11 @@ local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or
|
|||||||
local ox_target = exports.ox_target
|
local ox_target = exports.ox_target
|
||||||
local targetZones = {}
|
local targetZones = {}
|
||||||
|
|
||||||
|
local resourceTargets = {}
|
||||||
|
resourceTargets.models = {}
|
||||||
|
resourceTargets.entities = {}
|
||||||
|
resourceTargets.networkedEntities = {}
|
||||||
|
|
||||||
Target.GetResourceName = function()
|
Target.GetResourceName = function()
|
||||||
return "ox_target"
|
return "ox_target"
|
||||||
end
|
end
|
||||||
@@ -99,6 +104,9 @@ end
|
|||||||
function Target.AddLocalEntity(entities, options)
|
function Target.AddLocalEntity(entities, options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
ox_target:addLocalEntity(entities, options)
|
ox_target:addLocalEntity(entities, options)
|
||||||
|
local resource = GetInvokingResource()
|
||||||
|
resourceTargets.entities[resource] = resourceTargets.entities[resource] or {}
|
||||||
|
table.insert(resourceTargets.entities[resource], { entities = entities})
|
||||||
end
|
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.
|
---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)
|
function Target.AddNetworkedEntity(netids, options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
ox_target:addEntity(netids, options)
|
ox_target:addEntity(netids, options)
|
||||||
|
local resource = GetInvokingResource()
|
||||||
|
resourceTargets.networkedEntities[resource] = resourceTargets.networkedEntities[resource] or {}
|
||||||
|
table.insert(resourceTargets.networkedEntities[resource], { netids = netids})
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove a networked entity from the target system.
|
---This will remove a networked entity from the target system.
|
||||||
@@ -129,6 +140,9 @@ end
|
|||||||
function Target.AddModel(models, options)
|
function Target.AddModel(models, options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
ox_target:addModel(models, options)
|
ox_target:addModel(models, options)
|
||||||
|
local resource = GetInvokingResource()
|
||||||
|
resourceTargets.models[resource] = resourceTargets.models[resource] or {}
|
||||||
|
table.insert(resourceTargets.models[resource], { models = models})
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove target options from all specified models.
|
---This will remove target options from all specified models.
|
||||||
@@ -189,13 +203,32 @@ function Target.RemoveZone(name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(resource)
|
AddEventHandler('onResourceStop', function(resource)
|
||||||
if resource ~= GetCurrentResourceName() then return end
|
|
||||||
for _, target in pairs(targetZones) do
|
for _, target in pairs(targetZones) do
|
||||||
if target.creator == resource then
|
if target.creator == resource then
|
||||||
ox_target:removeZone(target.id)
|
ox_target:removeZone(target.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
targetZones = {}
|
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)
|
end)
|
||||||
|
|
||||||
return Target
|
return Target
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
BridgeClientConfig = {}
|
BridgeClientConfig = {}
|
||||||
BridgeClientConfig.InputSystem = "auto" -- [ auto | ox_lib | lation_ui | qb-input ]
|
BridgeClientConfig.InputSystem = "auto" -- [ auto | ox_lib | lation_ui | qb-input ]
|
||||||
BridgeClientConfig.MenuSystem = "auto" -- [ auto | ox_lib | wasabi_uikit | lation_ui | qb-menu ]
|
BridgeClientConfig.MenuSystem = "auto" -- [ auto | ox_lib | wasabi_uikit | lation_ui | qb-menu ]
|
||||||
BridgeClientConfig.ProgressBarSystem = "auto" -- [ auto | ox_lib | wasabi_uikit | lation_ui | ZSX_UIV2 | keep-progressbar | progressbar ]
|
BridgeClientConfig.ProgressBarSystem = "auto" -- [ auto | ox_lib | wasabi_uikit | lation_ui | ZSX_UIV2 | keep-progressbar | progressbar | msk_core ]
|
||||||
BridgeClientConfig.VehicleKey = "auto" -- [ auto | qb-vehiclekeys | MrNewbVehicleKeys | jaksams_VehiclesKeys | wasabi_carlock | mk_vehiclekeys | qbx_vehiclekeys | qs-vehiclekeys | t1ger_keys | Renewed-Vehiclekeys | mono_carkeys| cd_garage | okokGarage | F_RealCarKeysSystem
|
BridgeClientConfig.VehicleKey = "auto" -- [ auto | qb-vehiclekeys | MrNewbVehicleKeys | jaksams_VehiclesKeys | wasabi_carlock | mk_vehiclekeys | qbx_vehiclekeys | qs-vehiclekeys | t1ger_keys | Renewed-Vehiclekeys | mono_carkeys| cd_garage | okokGarage | F_RealCarKeysSystem
|
||||||
BridgeClientConfig.Fuel = "auto" -- [ auto | LegacyFuel | ox_fuel | ps-fuel | qs-fuelstations | Renewed-Fuel | ti_fuel | lc_fuel | x-fuel | cdn-fuel | esx-sna-fuel | BigDaddy-Fuel | okokGasStation ]
|
BridgeClientConfig.Fuel = "auto" -- [ auto | LegacyFuel | ox_fuel | ps-fuel | qs-fuelstations | Renewed-Fuel | ti_fuel | lc_fuel | x-fuel | cdn-fuel | esx-sna-fuel | BigDaddy-Fuel | okokGasStation ]
|
||||||
BridgeClientConfig.TargetSystem = "auto" -- [ auto | ox_target | qb-target | sleepless_interact ] -- sleepless is only partially supported and would need another system in place
|
BridgeClientConfig.TargetSystem = "auto" -- [ auto | ox_target | qb-target | sleepless_interact ] -- sleepless is only partially supported and would need another system in place
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
BridgeSharedConfig = {}
|
BridgeSharedConfig = {}
|
||||||
BridgeSharedConfig.Lang = "auto" -- Change this to your preferred language (must match the locale file name ex. en or fr etc)
|
BridgeSharedConfig.Lang = "auto" -- Change this to your preferred language (must match the locale file name ex. en or fr etc)
|
||||||
BridgeSharedConfig.DebugLevel = 0 -- Change this to your Debug level, 0 for none, 1 for some, 2 for all data
|
BridgeSharedConfig.DebugLevel = 0 -- Change this to your Debug level, 0 for none, 1 for some, 2 for all data
|
||||||
BridgeSharedConfig.Notify = "auto" -- [ auto | ox_lib | r_notify | wasabi_notify | lation_ui | ZSX_UIV2 | okokNotify | mythic_notify | pNotify | t-notify | brutal_notify | FL-Notify]
|
BridgeSharedConfig.Notify = "auto" -- [ auto | ox_lib | r_notify | wasabi_notify | lation_ui | ZSX_UIV2 | okokNotify | mythic_notify | pNotify | t-notify | brutal_notify | FL-Notify | msk_core]
|
||||||
BridgeSharedConfig.HelpText = "auto" -- [ auto | ox_lib | jg-textui | lation_ui | ZSX_UIV2 | cd_drawtextui | lab-HintUI | okokTextUI]
|
BridgeSharedConfig.HelpText = "auto" -- [ auto | ox_lib | jg-textui | lation_ui | ZSX_UIV2 | cd_drawtextui | lab-HintUI | okokTextUI]
|
||||||
BridgeSharedConfig.Phone = "auto" -- [ auto | qs-smartphone | lb-phone | gksphone]
|
BridgeSharedConfig.Phone = "auto" -- [ auto | qs-smartphone | lb-phone | gksphone]
|
||||||
BridgeSharedConfig.Skills = "auto" -- [ auto | OT_skills | evolent_skills | pickle_xp]
|
BridgeSharedConfig.Skills = "auto" -- [ auto | OT_skills | evolent_skills | pickle_xp]
|
||||||
|
|||||||
Reference in new issue
Block a user