From 6fbeece181654f47efd39a6e285dd0a358b490fe Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Mon, 5 May 2025 17:05:29 -0500 Subject: [PATCH 01/38] Fix to callbacks for return data Was only passing 1 value back, allowed for n --- lib/utility/shared/callbacks.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/utility/shared/callbacks.lua b/lib/utility/shared/callbacks.lua index 97cab1e..196c86b 100644 --- a/lib/utility/shared/callbacks.lua +++ b/lib/utility/shared/callbacks.lua @@ -49,7 +49,8 @@ local function triggerCallback(eventName, target, name, args, callback) if not callback then local result = Citizen.Await(promise) - return #result == 1 and result[1] or table.unpack(result) + local returnResults = (result and type(result) == 'table' ) and result or {result} + return table.unpack(returnResults) end end From c0662e10690c99f9bdcf7cf970d824ad8cbf0c71 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Fri, 9 May 2025 01:59:36 -0400 Subject: [PATCH 02/38] version checker tweak --- modules/version/server/VersionChecker.lua | 40 +++++++++-------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/modules/version/server/VersionChecker.lua b/modules/version/server/VersionChecker.lua index acf583c..6d5fe2a 100644 --- a/modules/version/server/VersionChecker.lua +++ b/modules/version/server/VersionChecker.lua @@ -1,40 +1,30 @@ Version = Version or {} ---Pass a github username and repo name to check for the latest version of the resource. +--- ---Tebex is a optional boolean to determine if the message should be for a escrowed resource or not. ----Example Version.VersionChecker("The-Order-Of-The-Sacred-Framework/community_bridge") +--- +---Example Version.VersionChecker("The-Order-Of-The-Sacred-Framework/community_bridge", false) ---@param repoPath string ---@param tebex boolean | nil ---@return nil function Version.VersionChecker(repoPath, tebex) - local resource = repoPath:match("([^/]+)$") - if not resource then return Prints.Error('^1Invalid repository format. Expected format: "username/reponame"^0') end - - local version = GetResourceMetadata(resource, "version", 0) - if not version then return Prints.Error(('^1Unable to determine current resource version for %s ^0'):format(resource)) end - - version = version:match('%d+%.%d+%.%d+') - if not version then return Prints.Error(('^1Invalid version format for %s ^0'):format(resource)) end - local username, reponame = repoPath:match("([^/]+)/([^/]+)") - if not username or not reponame then return Prints.Error('^1Invalid repository format. Expected format: "username/reponame"^0') end + local resource = reponame and repoPath:match("([^/]+)$") + if not username or not reponame or not resource then + return Prints.Error('^1Invalid repository format. Expected format: "username/reponame"^0') + end + + local version = GetResourceMetadata(resource, "version", 0):match('%d+%.%d+%.%d+') + if not version then return end + PerformHttpRequest(('https://api.github.com/repos/%s/%s/releases/latest'):format(username, reponame), function(status, response) - if status ~= 200 then return end - response = json.decode(response) + local latest = json.decode(response).tag_name:match('%d+%.%d+%.%d+') + if not latest or latest == version or version:gsub('%D', '') >= latest:gsub('%D', '') then return end - local latest = response.tag_name:match('%d+%.%d+%.%d+') - if not latest then return end - - if latest == version then return end - local currentVersion, latestVersion = version:gsub('%D', ''), latest:gsub('%D', '') - - if currentVersion < latestVersion then - if tebex then - return print(('^1An update is available for %s (current version: %s)\r\n - ^5Please download the latest version from the portal/keymaster.^7\r\n%s'):format(resource, version, "https://portal.cfx.re/assets/granted-assets")) - end - return print(('^1An update is available for %s (current version: %s)\r\n - ^5Please download the latest version from the GitHub release page.^7\r\n%s'):format(resource, version, response.html_url)) - end + local url = tebex and "https://portal.cfx.re/assets/granted-assets" or json.decode(response).html_url + print(('^1An update is available for %s (current version: %s)\r\n - ^5Please download the latest version from %s^7'):format(resource, version, url)) end, 'GET') end From 485c2d3460c86fafc2cce277c8aedb1d9350e1a2 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Fri, 9 May 2025 02:00:02 -0400 Subject: [PATCH 03/38] inv diagnostics + repacked tables --- modules/inventory/_default/client.lua | 1 + modules/inventory/_default/server.lua | 1 + modules/inventory/codem-inventory/client.lua | 5 +++-- modules/inventory/codem-inventory/server.lua | 5 +++-- modules/inventory/core_inventory/client.lua | 1 + modules/inventory/core_inventory/server.lua | 2 +- modules/inventory/jpr-inventory/client.lua | 4 ++-- modules/inventory/jpr-inventory/server.lua | 12 +++++++++++- modules/inventory/origen_inventory/client.lua | 5 +++-- modules/inventory/origen_inventory/server.lua | 5 +++-- modules/inventory/ox_inventory/client.lua | 4 ++-- modules/inventory/ox_inventory/server.lua | 9 +++------ modules/inventory/ps-inventory/client.lua | 4 ++-- modules/inventory/ps-inventory/server.lua | 12 +++++++++++- modules/inventory/qb-inventory/client.lua | 4 ++-- modules/inventory/qb-inventory/server.lua | 4 ++-- modules/inventory/qs-inventory/client.lua | 4 ++-- modules/inventory/qs-inventory/server.lua | 4 ++-- modules/inventory/tgiann-inventory/client.lua | 4 ++-- modules/inventory/tgiann-inventory/server.lua | 15 ++++++++++++--- 20 files changed, 69 insertions(+), 36 deletions(-) diff --git a/modules/inventory/_default/client.lua b/modules/inventory/_default/client.lua index 21991ad..a9145b7 100644 --- a/modules/inventory/_default/client.lua +++ b/modules/inventory/_default/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field Inventory = Inventory or {} ---This will fallback to framework add item functions when an inventory does not have the specifiec function. diff --git a/modules/inventory/_default/server.lua b/modules/inventory/_default/server.lua index 2d42c54..48cfc2b 100644 --- a/modules/inventory/_default/server.lua +++ b/modules/inventory/_default/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field Inventory = Inventory or {} ---This will fallback to framework add item functions when an inventory does not have the specifiec function. diff --git a/modules/inventory/codem-inventory/client.lua b/modules/inventory/codem-inventory/client.lua index 11be4c5..2b7a208 100644 --- a/modules/inventory/codem-inventory/client.lua +++ b/modules/inventory/codem-inventory/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('codem-inventory') ~= 'started' then return end Inventory = Inventory or {} @@ -8,8 +9,9 @@ local codem = exports['codem-inventory'] ---@return table Inventory.GetItemInfo = function(item) local itemData = codem:GetItemList(item) + if not itemData then return {} end local image = itemData.image and Inventory.GetImagePath(itemData.image) or Inventory.GetImagePath(item) - local repackedTable = { + return { name = itemData.name or "Missing Name", label = itemData.label or "Missing Label", stack = itemData.unique or "false", @@ -17,7 +19,6 @@ Inventory.GetItemInfo = function(item) description = itemData.description or "none", image = image, } - return repackedTable or {} end ---comment diff --git a/modules/inventory/codem-inventory/server.lua b/modules/inventory/codem-inventory/server.lua index cbf6847..8963a93 100644 --- a/modules/inventory/codem-inventory/server.lua +++ b/modules/inventory/codem-inventory/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('codem-inventory') ~= 'started' then return end Inventory = Inventory or {} @@ -6,7 +7,8 @@ local codem = exports['codem-inventory'] Inventory.GetItemInfo = function(item) local itemData = codem:GetItemList(item) - local repackedTable = { + if not itemData then return {} end + return { name = itemData.name or "Missing Name", label = itemData.label or "Missing Label", stack = itemData.unique or "false", @@ -14,7 +16,6 @@ Inventory.GetItemInfo = function(item) description = itemData.description or "none", image = itemData.image or Inventory.GetImagePath(item), } - return repackedTable or {} end Inventory.AddItem = function(src, item, count, slot, metadata) diff --git a/modules/inventory/core_inventory/client.lua b/modules/inventory/core_inventory/client.lua index f59f174..c3d6ddc 100644 --- a/modules/inventory/core_inventory/client.lua +++ b/modules/inventory/core_inventory/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('core_inventory') ~= 'started' then return end Inventory = Inventory or {} diff --git a/modules/inventory/core_inventory/server.lua b/modules/inventory/core_inventory/server.lua index 65792dc..e190413 100644 --- a/modules/inventory/core_inventory/server.lua +++ b/modules/inventory/core_inventory/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('core_inventory') ~= 'started' then return end Inventory = Inventory or {} @@ -76,7 +77,6 @@ Inventory.GetItemBySlot = function(src, slot) local inv = Inventory.GetPlayerInventory(src) if not inv then return {} end for _, v in pairs(inv) do - print(v.slot, slot) if v.slot == slot then return { name = v.name, diff --git a/modules/inventory/jpr-inventory/client.lua b/modules/inventory/jpr-inventory/client.lua index f7deebc..6aeb6f8 100644 --- a/modules/inventory/jpr-inventory/client.lua +++ b/modules/inventory/jpr-inventory/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('jpr-inventory') ~= 'started' then return end local jpr = exports['jpr-inventory'] @@ -29,7 +30,7 @@ end Inventory.GetItemInfo = function(item) local itemData = Framework.Shared.Items[item] if not itemData then return {} end - local repackedTable = { + return { name = itemData.name, label = itemData.label, stack = itemData.unique, @@ -37,5 +38,4 @@ Inventory.GetItemInfo = function(item) description = itemData.description, image = Inventory.GetImagePath(itemData.name) } - return repackedTable end \ No newline at end of file diff --git a/modules/inventory/jpr-inventory/server.lua b/modules/inventory/jpr-inventory/server.lua index 9c7cf01..908374f 100644 --- a/modules/inventory/jpr-inventory/server.lua +++ b/modules/inventory/jpr-inventory/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('jpr-inventory') ~= 'started' then return end local jpr = exports['jpr-inventory'] @@ -56,7 +57,16 @@ end Inventory.GetItemBySlot = function(src, slot) local slotData = jpr:GetItemBySlot(src, slot) if not slotData then return {} end - return { name = slotData.name, label = slotData.label, weight = slotData.weight, slot = slot, count = slotData.amount, metadata = slotData.info, stack = slotData.unique, description = slotData.description } + return { + name = slotData.name, + label = slotData.label, + weight = slotData.weight, + slot = slot, + count = slotData.amount, + metadata = slotData.info, + stack = slotData.unique, + description = slotData.description + } end ---comment diff --git a/modules/inventory/origen_inventory/client.lua b/modules/inventory/origen_inventory/client.lua index a7f8359..6e76284 100644 --- a/modules/inventory/origen_inventory/client.lua +++ b/modules/inventory/origen_inventory/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('origen_inventory') ~= 'started' then return end Inventory = Inventory or {} @@ -9,7 +10,8 @@ local origin = exports.origen_inventory ---@return table Inventory.GetItemInfo = function(item) local itemData = origin:Items(item) - local repackedTable = { + if not itemData then return {} end + return { name = itemData.name or "Missing Name", label = itemData.label or "Missing Label", stack = itemData.unique or "false", @@ -17,7 +19,6 @@ Inventory.GetItemInfo = function(item) description = itemData.description or "none", image = itemData.image or Inventory.GetImagePath(item), } - return repackedTable or {} end ---comment diff --git a/modules/inventory/origen_inventory/server.lua b/modules/inventory/origen_inventory/server.lua index f567fb9..a2e69f5 100644 --- a/modules/inventory/origen_inventory/server.lua +++ b/modules/inventory/origen_inventory/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('origen_inventory') ~= 'started' then return end Inventory = Inventory or {} @@ -25,7 +26,8 @@ end Inventory.GetItemInfo = function(item) local itemData = origen_inventory:Items(item) - local repackedTable = { + if not itemData then return {} end + return { name = itemData.name or "Missing Name", label = itemData.label or "Missing Label", stack = itemData.unique or "false", @@ -33,7 +35,6 @@ Inventory.GetItemInfo = function(item) description = itemData.description or "none", image = itemData.image or Inventory.GetImagePath(item), } - return repackedTable or {} end Inventory.GetItemCount = function(src, item, metadata) diff --git a/modules/inventory/ox_inventory/client.lua b/modules/inventory/ox_inventory/client.lua index 766c571..284edd6 100644 --- a/modules/inventory/ox_inventory/client.lua +++ b/modules/inventory/ox_inventory/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('ox_inventory') ~= 'started' then return end local ox_inventory = exports.ox_inventory @@ -9,7 +10,7 @@ Inventory = Inventory or {} Inventory.GetItemInfo = function(item) local itemData = ox_inventory:Items(item) if not itemData then return {} end - local repackedTable = { + return { name = itemData.name or "Missing Name", label = itemData.label or "Missing Label", stack = itemData.stack or "true", @@ -17,7 +18,6 @@ Inventory.GetItemInfo = function(item) description = itemData.description or "none", image = (itemData.client and itemData.client.image) or Inventory.GetImagePath(item), } - return repackedTable end ---comment diff --git a/modules/inventory/ox_inventory/server.lua b/modules/inventory/ox_inventory/server.lua index e2eb791..cbe0569 100644 --- a/modules/inventory/ox_inventory/server.lua +++ b/modules/inventory/ox_inventory/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('ox_inventory') ~= 'started' then return end local ox_inventory = exports.ox_inventory @@ -19,18 +20,14 @@ end Inventory.GetItemInfo = function(item) local itemData = ox_inventory:Items(item) if not itemData then return {} end - local repackedTable = { + return { name = itemData.name or "Missing Name", label = itemData.label or "Missing Label", stack = itemData.stack or "true", weight = itemData.weight or "0", description = itemData.description or "none", - image = string.format("nui://ox_inventory/web/images/%s", itemData.client - and itemData.client.image - or string.format("%s.png", item) - ), + image = string.format("nui://ox_inventory/web/images/%s", itemData.client and itemData.client.image or string.format("%s.png", item)), } - return repackedTable end -- string.format("nui://ox_inventory/web/images/%s.png", item) diff --git a/modules/inventory/ps-inventory/client.lua b/modules/inventory/ps-inventory/client.lua index 6d37dd6..cf69bb0 100644 --- a/modules/inventory/ps-inventory/client.lua +++ b/modules/inventory/ps-inventory/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('ps-inventory') ~= 'started' then return end local ps = exports['ps-inventory'] @@ -31,7 +32,7 @@ end Inventory.GetItemInfo = function(item) local itemData = Framework.Shared.Items[item] if not itemData then return {} end - local repackedTable = { + return { name = itemData.name, label = itemData.label, stack = itemData.unique, @@ -39,5 +40,4 @@ Inventory.GetItemInfo = function(item) description = itemData.description, image = Inventory.GetImagePath(itemData.name) } - return repackedTable end \ No newline at end of file diff --git a/modules/inventory/ps-inventory/server.lua b/modules/inventory/ps-inventory/server.lua index ff95702..60ef824 100644 --- a/modules/inventory/ps-inventory/server.lua +++ b/modules/inventory/ps-inventory/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('ps-inventory') ~= 'started' then return end local sloth = exports['ps-inventory'] @@ -57,7 +58,16 @@ end Inventory.GetItemBySlot = function(src, slot) local slotData = sloth:GetItemBySlot(src, slot) if not slotData then return {} end - return {name = slotData.name, label = slotData.name, weight = slotData.weight, slot = slot, count = slotData.amount, metadata = slotData.info, stack = slotData.unique, description = slotData.description} + return { + name = slotData.name, + label = slotData.name, + weight = slotData.weight, + slot = slot, + count = slotData.amount, + metadata = slotData.info, + stack = slotData.unique, + description = slotData.description + } end ---comment diff --git a/modules/inventory/qb-inventory/client.lua b/modules/inventory/qb-inventory/client.lua index 0818f4f..10cab4f 100644 --- a/modules/inventory/qb-inventory/client.lua +++ b/modules/inventory/qb-inventory/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qb-inventory') ~= 'started' then return end local qb = exports['qb-inventory'] @@ -30,7 +31,7 @@ end Inventory.GetItemInfo = function(item) local itemData = Framework.Shared.Items[item] if not itemData then return {} end - local repackedTable = { + return { name = itemData.name, label = itemData.label, stack = itemData.unique, @@ -38,6 +39,5 @@ Inventory.GetItemInfo = function(item) description = itemData.description, image = Inventory.GetImagePath(itemData.image or itemData.name) } - return repackedTable end diff --git a/modules/inventory/qb-inventory/server.lua b/modules/inventory/qb-inventory/server.lua index ba70836..bfd7b74 100644 --- a/modules/inventory/qb-inventory/server.lua +++ b/modules/inventory/qb-inventory/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qb-inventory') ~= 'started' then return end local qbInventory = exports['qb-inventory'] @@ -43,7 +44,7 @@ end Inventory.GetItemInfo = function(item) local itemData = Framework.Shared.Items[item] if not itemData then return {} end - local repackedTable = { + return { name = itemData.name, label = itemData.label, stack = itemData.unique, @@ -51,7 +52,6 @@ Inventory.GetItemInfo = function(item) description = itemData.description, image = Inventory.GetImagePath(itemData.image or itemData.name) } - return repackedTable end ---comment diff --git a/modules/inventory/qs-inventory/client.lua b/modules/inventory/qs-inventory/client.lua index 9a0f0d1..a1058aa 100644 --- a/modules/inventory/qs-inventory/client.lua +++ b/modules/inventory/qs-inventory/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qs-inventory') ~= 'started' then return end local quasar = exports["qs-inventory"] Inventory = Inventory or {} @@ -17,7 +18,7 @@ Inventory.GetItemInfo = function(item) if not itemsData then return {} end local itemData = itemsData[item] if not itemData then return {} end - local repackedTable = { + return { name = itemData.name or "Missing Name", label = itemData.label or "Missing Label", stack = itemData.unique or "false", @@ -25,7 +26,6 @@ Inventory.GetItemInfo = function(item) description = itemData.description or "none", image = itemData.image or Inventory.GetImagePath(item), } - return repackedTable end ---comment diff --git a/modules/inventory/qs-inventory/server.lua b/modules/inventory/qs-inventory/server.lua index 0cbc1a8..f7e06ed 100644 --- a/modules/inventory/qs-inventory/server.lua +++ b/modules/inventory/qs-inventory/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qs-inventory') ~= 'started' then return end local quasar = exports['qs-inventory'] @@ -131,7 +132,7 @@ Inventory.GetItemInfo = function(item) if not itemsData then return {} end local itemData = itemsData[item] if not itemData then return {} end - local repackedTable = { + return { name = itemData.name or "Missing Name", label = itemData.label or "Missing Label", stack = itemData.unique or "false", @@ -139,7 +140,6 @@ Inventory.GetItemInfo = function(item) description = itemData.description or "none", image = itemData.image or Inventory.GetImagePath(item), } - return repackedTable end diff --git a/modules/inventory/tgiann-inventory/client.lua b/modules/inventory/tgiann-inventory/client.lua index 5ddcee4..ed33bd8 100644 --- a/modules/inventory/tgiann-inventory/client.lua +++ b/modules/inventory/tgiann-inventory/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('tgiann-inventory') ~= 'started' then return end local tgiann = exports["tgiann-inventory"] @@ -14,7 +15,7 @@ end Inventory.GetItemInfo = function(item) local itemData = tgiann:GetItemList() if not itemData[item] then return {} end - local repackedTable = { + return { name = itemData.name or "Missing Name", label = itemData.label or "Missing Label", stack = itemData.unique or "false", @@ -22,7 +23,6 @@ Inventory.GetItemInfo = function(item) description = itemData.description or "none", image = itemData.image or Inventory.GetImagePath(item), } - return repackedTable end ---comment diff --git a/modules/inventory/tgiann-inventory/server.lua b/modules/inventory/tgiann-inventory/server.lua index 6219a5e..553d998 100644 --- a/modules/inventory/tgiann-inventory/server.lua +++ b/modules/inventory/tgiann-inventory/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('tgiann-inventory') ~= 'started' then return end local tgiann = exports["tgiann-inventory"] @@ -100,7 +101,16 @@ end Inventory.GetItemBySlot = function(src, slot) local item = tgiann:GetItemBySlot(src, slot) if not item then return {} end - return {name = item.name, label = item.label, weight = item.weight, slot = slot, count = item.amount, metadata = item.info, stack = item.unique or false, description = item.description} + return { + name = item.name, + label = item.label, + weight = item.weight, + slot = slot, + count = item.amount, + metadata = item.info, + stack = item.unique or false, + description = item.description + } end ---This will return a table of the item data including the image (very useful for menus etc) @@ -109,7 +119,7 @@ end Inventory.GetItemInfo = function(item) local itemData = tgiann:GetItemList() if not itemData[item] then return {} end - local repackedTable = { + return { name = itemData.name or "Missing Name", label = itemData.label or "Missing Label", stack = itemData.unique or "false", @@ -117,7 +127,6 @@ Inventory.GetItemInfo = function(item) description = itemData.description or "none", image = itemData.image or Inventory.GetImagePath(item), } - return repackedTable end ---This will update the item metadata for an item with the provided slot and metadata, its best to get the item first From 6bd3df2e8071805e3a551b0dcb27ce9e2b416dde Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Fri, 9 May 2025 02:01:37 -0400 Subject: [PATCH 04/38] ---@diagnostic disable: duplicate-set-field --- modules/doorlock/doors_creator/client.lua | 1 + modules/doorlock/doors_creator/server.lua | 1 + modules/doorlock/ox_doorlock/client.lua | 5 ++++- modules/doorlock/ox_doorlock/server.lua | 1 + modules/doorlock/qb-doorlock/client.lua | 1 + modules/doorlock/qb-doorlock/server.lua | 1 + modules/doorlock/rcore_doorlock/client.lua | 1 + modules/doorlock/rcore_doorlock/server.lua | 1 + 8 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/doorlock/doors_creator/client.lua b/modules/doorlock/doors_creator/client.lua index 88b9745..4d11da1 100644 --- a/modules/doorlock/doors_creator/client.lua +++ b/modules/doorlock/doors_creator/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('doors_creator') ~= 'started' then return end Doorlock = Doorlock or {} diff --git a/modules/doorlock/doors_creator/server.lua b/modules/doorlock/doors_creator/server.lua index b9ae565..c45de2e 100644 --- a/modules/doorlock/doors_creator/server.lua +++ b/modules/doorlock/doors_creator/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('doors_creator') ~= 'started' then return end Doorlock = Doorlock or {} diff --git a/modules/doorlock/ox_doorlock/client.lua b/modules/doorlock/ox_doorlock/client.lua index 3c25dd1..738cdf7 100644 --- a/modules/doorlock/ox_doorlock/client.lua +++ b/modules/doorlock/ox_doorlock/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('ox_doorlock') ~= 'started' then return end Doorlock = Doorlock or {} @@ -5,5 +6,7 @@ Doorlock = Doorlock or {} ---This will get the closest door to the ped ---@return string | nil Doorlock.GetClosestDoor = function() - return exports.ox_doorlock:getClosestDoor() + local doorData = exports.ox_doorlock:getClosestDoor() + if not doorData then return end + return tostring(doorData.id) or nil end diff --git a/modules/doorlock/ox_doorlock/server.lua b/modules/doorlock/ox_doorlock/server.lua index a0324ba..3c0ff18 100644 --- a/modules/doorlock/ox_doorlock/server.lua +++ b/modules/doorlock/ox_doorlock/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('ox_doorlock') ~= 'started' then return end Doorlock = Doorlock or {} diff --git a/modules/doorlock/qb-doorlock/client.lua b/modules/doorlock/qb-doorlock/client.lua index 11929e5..5c7c92b 100644 --- a/modules/doorlock/qb-doorlock/client.lua +++ b/modules/doorlock/qb-doorlock/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qb-doorlock') ~= 'started' then return end Doorlock = Doorlock or {} diff --git a/modules/doorlock/qb-doorlock/server.lua b/modules/doorlock/qb-doorlock/server.lua index 21648e3..59e19cf 100644 --- a/modules/doorlock/qb-doorlock/server.lua +++ b/modules/doorlock/qb-doorlock/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qb-doorlock') ~= 'started' then return end Doorlock = Doorlock or {} diff --git a/modules/doorlock/rcore_doorlock/client.lua b/modules/doorlock/rcore_doorlock/client.lua index efb90be..ceb596b 100644 --- a/modules/doorlock/rcore_doorlock/client.lua +++ b/modules/doorlock/rcore_doorlock/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('rcore_doorlock') ~= 'started' then return end Doorlock = Doorlock or {} diff --git a/modules/doorlock/rcore_doorlock/server.lua b/modules/doorlock/rcore_doorlock/server.lua index 9535aab..c7190c8 100644 --- a/modules/doorlock/rcore_doorlock/server.lua +++ b/modules/doorlock/rcore_doorlock/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('rcore_doorlock') ~= 'started' then return end Doorlock = Doorlock or {} From a1bd168994665b714e18e56bac2be4ae783828e4 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Fri, 9 May 2025 02:26:02 -0400 Subject: [PATCH 05/38] ---@diagnostic disable: duplicate-set-field --- modules/fuel/lc_fuel/client.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/fuel/lc_fuel/client.lua b/modules/fuel/lc_fuel/client.lua index ee85467..3048cb9 100644 --- a/modules/fuel/lc_fuel/client.lua +++ b/modules/fuel/lc_fuel/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field local resourceName = "lc_fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end @@ -6,7 +7,6 @@ Fuel = Fuel or {} ---This will get the name of the Fuel being used (if a supported Fuel). ---@return string ----@diagnostic disable-next-line: duplicate-set-field Fuel.GetResourceName = function() return resourceName end @@ -14,7 +14,6 @@ end ---This will get the fuel level of the vehicle. ---@param vehicle number The vehicle entity ID. ---@return number fuel The fuel level of the vehicle. ----@diagnostic disable-next-line: duplicate-set-field Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports["lc_fuel"]:GetFuel(vehicle) @@ -24,7 +23,6 @@ end ---@param vehicle number The vehicle entity ID. ---@param fuel number The fuel level to set. ---@return nil ----@diagnostic disable-next-line: duplicate-set-field Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports["lc_fuel"]:SetFuel(vehicle, fuel) From c651b767bac2c4717a719db4c7b319710d88359b Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Fri, 9 May 2025 03:16:27 -0400 Subject: [PATCH 06/38] missing fallback added --- modules/inventory/_default/client.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/inventory/_default/client.lua b/modules/inventory/_default/client.lua index a9145b7..42853d9 100644 --- a/modules/inventory/_default/client.lua +++ b/modules/inventory/_default/client.lua @@ -1,28 +1,34 @@ ---@diagnostic disable: duplicate-set-field Inventory = Inventory or {} ----This will fallback to framework add item functions when an inventory does not have the specifiec function. +---Return the item info in oxs format, {name, label, stack, weight, description, image} ---@param item string ---@return table Inventory.GetItemInfo = function(item) return Framework.GetItemInfo(item) end ----This will fallback to framework add item functions when an inventory does not have the specifiec function. +---Will return boolean if the player has the item. ---@param item string ---@return boolean Inventory.HasItem = function(item) return Framework.HasItem(item) end ----This will fallback to framework add item functions when an inventory does not have the specifiec function. +---This will return th count of the item in the players inventory, if not found will return 0. ---@param item string ---@return number Inventory.GetItemCount = function(item) return Framework.GetItemCount(item) end ----This will provide a image of the community bridge logo if the inventory isnt bridged for the specific path. +---This will return the players inventory in the format of {name, label, count, slot, metadata} +---@return table +Inventory.GetPlayerInventory = function() + return Framework:GetPlayerInventory() +end + +---This will get the image path for this item, if not found will return placeholder. ---@param item string ---@return string Inventory.GetImagePath = function(item) From 53d27c528e1e3b51f1d484fec329fb5dbfb6c605 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Fri, 9 May 2025 03:17:28 -0400 Subject: [PATCH 07/38] minor cleanup, functions notated --- modules/inventory/codem-inventory/client.lua | 23 +++--- modules/inventory/core_inventory/client.lua | 82 ++++++++++--------- modules/inventory/jpr-inventory/client.lua | 51 ++++++------ modules/inventory/origen_inventory/client.lua | 30 +++---- modules/inventory/ox_inventory/client.lua | 20 ++--- modules/inventory/ps-inventory/client.lua | 51 ++++++------ modules/inventory/qb-inventory/client.lua | 47 +++++------ modules/inventory/qs-inventory/client.lua | 38 ++++----- modules/inventory/tgiann-inventory/client.lua | 33 ++++---- 9 files changed, 188 insertions(+), 187 deletions(-) diff --git a/modules/inventory/codem-inventory/client.lua b/modules/inventory/codem-inventory/client.lua index 2b7a208..ea2b347 100644 --- a/modules/inventory/codem-inventory/client.lua +++ b/modules/inventory/codem-inventory/client.lua @@ -4,7 +4,7 @@ Inventory = Inventory or {} local codem = exports['codem-inventory'] ----comment +---Return the item info in oxs format, {name, label, stack, weight, description, image} ---@param item string ---@return table Inventory.GetItemInfo = function(item) @@ -21,7 +21,17 @@ Inventory.GetItemInfo = function(item) } end ----comment +---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("codem-inventory", string.format("html/images/%s.png", item)) + local imagePath = file and string.format("nui://codem-inventory/html/images/%s.png", item) + return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end + +---This will return the players inventory in the format of {name, label, count, slot, metadata} ---@return table Inventory.GetPlayerInventory = function() local items = {} @@ -41,12 +51,3 @@ Inventory.GetPlayerInventory = function() return items end ----comment ----@param item string ----@return string -Inventory.GetImagePath = function(item) - item = Inventory.StripPNG(item) - local file = LoadResourceFile("codem-inventory", string.format("html/images/%s.png", item)) - local imagePath = file and string.format("nui://codem-inventory/html/images/%s.png", item) - return imagePath or "https://avatars.githubusercontent.com/u/47620135" -end \ No newline at end of file diff --git a/modules/inventory/core_inventory/client.lua b/modules/inventory/core_inventory/client.lua index c3d6ddc..f31858c 100644 --- a/modules/inventory/core_inventory/client.lua +++ b/modules/inventory/core_inventory/client.lua @@ -1,50 +1,12 @@ ---@diagnostic disable: duplicate-set-field if GetResourceState('core_inventory') ~= 'started' then return end - -Inventory = Inventory or {} - local core = exports.core_inventory Inventory = Inventory or {} ----comment +---Return the item info in oxs format, {name, label, stack, weight, description, image} ---@param item string ----@return string -Inventory.GetImagePath = function(item) - item = Inventory.StripPNG(item) - local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item)) - local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item) - return imagePath or "https://avatars.githubusercontent.com/u/47620135" -end - ----comment ----@param item string ----@return boolean -Inventory.HasItem = function(item) - return core:hasItem(item, 1) -end - ----comment ----@param item string ----@return number -Inventory.GetItemCount = function(item) - return core:getItemCount(item) -end - -Inventory.GetPlayerInventory = function() - local playerItems = core:getInventory() - local repackedTable = {} - for _, v in pairs(playerItems) do - table.insert(repackedTable, { - name = v.name, - count = v.count, - metadata = v.metadata, - slot = v.id, - }) - end - return repackedTable -end - +---@return table Inventory.GetItemInfo = function(item) local frameworkName = Framework.GetFrameworkName() if not frameworkName then return {} end @@ -59,4 +21,44 @@ Inventory.GetItemInfo = function(item) if not dataRepack then return {} end end return {name = dataRepack.name, label = dataRepack.label, stack = dataRepack.stack, weight = dataRepack.weight, description = dataRepack.description, image = Inventory.GetImagePath(dataRepack.name) } +end + +---Will return boolean if the player has the item. +---@param item string +---@return boolean +Inventory.HasItem = function(item) + return core:hasItem(item, 1) +end + +---This will return th count of the item in the players inventory, if not found will return 0. +---@param item string +---@return number +Inventory.GetItemCount = function(item) + return core:getItemCount(item) +end + +---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("core_inventory", string.format("html/img/%s.png", item)) + local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item) + return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end + +---This will return the players inventory in the format of {name, label, count, slot, metadata} +---@return table +Inventory.GetPlayerInventory = function() + local playerItems = core:getInventory() + local repackedTable = {} + for _, v in pairs(playerItems) do + table.insert(repackedTable, { + name = v.name, + count = v.count, + metadata = v.metadata, + slot = v.id, + }) + end + return repackedTable end \ No newline at end of file diff --git a/modules/inventory/jpr-inventory/client.lua b/modules/inventory/jpr-inventory/client.lua index 6aeb6f8..a2b0422 100644 --- a/modules/inventory/jpr-inventory/client.lua +++ b/modules/inventory/jpr-inventory/client.lua @@ -1,32 +1,12 @@ ---@diagnostic disable: duplicate-set-field if GetResourceState('jpr-inventory') ~= 'started' then return end - local jpr = exports['jpr-inventory'] + Inventory = Inventory or {} -RegisterNetEvent('community_bridge:client:jpr-inventory:openStash', function(id, data) - if source ~= 65535 then return end - TriggerEvent("inventory:client:SetCurrentStash", id) - TriggerServerEvent('inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots }) -end) - ----comment +---Return the item info in oxs format, {name, label, stack, weight, description, image} ---@param item string ----@return boolean -Inventory.HasItem = function(item) - return jpr:HasItem(item) -end - ----comment ----@param item string ----@return string -Inventory.GetImagePath = function(item) - item = Inventory.StripPNG(item) - local file = LoadResourceFile("jpr-inventory", string.format("html/images/%s.png", item)) - local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item) - return imagePath or "https://avatars.githubusercontent.com/u/47620135" -end - +---@return table Inventory.GetItemInfo = function(item) local itemData = Framework.Shared.Items[item] if not itemData then return {} end @@ -38,4 +18,27 @@ Inventory.GetItemInfo = function(item) description = itemData.description, image = Inventory.GetImagePath(itemData.name) } -end \ No newline at end of file +end + +---Will return boolean if the player has the item. +---@param item string +---@return boolean +Inventory.HasItem = function(item) + return jpr:HasItem(item) +end + +---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("jpr-inventory", string.format("html/images/%s.png", item)) + local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item) + return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end + +RegisterNetEvent('community_bridge:client:jpr-inventory:openStash', function(id, data) + if source ~= 65535 then return end + TriggerEvent("inventory:client:SetCurrentStash", id) + TriggerServerEvent('inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots }) +end) \ No newline at end of file diff --git a/modules/inventory/origen_inventory/client.lua b/modules/inventory/origen_inventory/client.lua index 6e76284..8f70ff1 100644 --- a/modules/inventory/origen_inventory/client.lua +++ b/modules/inventory/origen_inventory/client.lua @@ -1,11 +1,9 @@ ---@diagnostic disable: duplicate-set-field if GetResourceState('origen_inventory') ~= 'started' then return end - Inventory = Inventory or {} - local origin = exports.origen_inventory ----comment +---Return the item info in oxs format, {name, label, stack, weight, description, image} ---@param item string ---@return table Inventory.GetItemInfo = function(item) @@ -21,26 +19,23 @@ Inventory.GetItemInfo = function(item) } end ----comment +---Will return boolean if the player has the item. ---@param item string ---@return boolean Inventory.HasItem = function(item) return origin:HasItem(item) end ----comment +---This will return th count of the item in the players inventory, if not found will return 0. ---@param item string ---@return number Inventory.GetItemCount = function(item) - local searchItem = origin:Search('slots', item) - local count = 0 - for _, v in pairs(searchItem) do - count = count + v.count - end - return count + local inventory = origin:Search('count', item) + if not inventory then return 0 end + return inventory.count end ----comment +---This will get the image path for this item, if not found will return placeholder. ---@param item string ---@return string Inventory.GetImagePath = function(item) @@ -50,13 +45,14 @@ Inventory.GetImagePath = function(item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" end ----comment +---This will return the players inventory in the format of {name, label, count, slot, metadata} ---@return table Inventory.GetPlayerInventory = function() - local items = {} + local repack = {} local inventory = origin:GetInventory() + if not inventory then return {} end for _, v in pairs(inventory) do - table.insert(items, { + table.insert(repack, { name = v.name, label = v.label, count = v.count, @@ -67,5 +63,5 @@ Inventory.GetPlayerInventory = function() weight = v.weight }) end - return items -end + return repack +end \ No newline at end of file diff --git a/modules/inventory/ox_inventory/client.lua b/modules/inventory/ox_inventory/client.lua index 284edd6..1fcbaea 100644 --- a/modules/inventory/ox_inventory/client.lua +++ b/modules/inventory/ox_inventory/client.lua @@ -4,7 +4,7 @@ local ox_inventory = exports.ox_inventory Inventory = Inventory or {} ----comment +---Return the item info in oxs format, {name, label, stack, weight, description, image} ---@param item string ---@return table Inventory.GetItemInfo = function(item) @@ -20,23 +20,21 @@ Inventory.GetItemInfo = function(item) } end ----comment +---Will return boolean if the player has the item. ---@param item string ---@return boolean Inventory.HasItem = function(item) - local itemCount = ox_inventory:Search('count', item) - local hasItem = itemCount ~= 0 - return hasItem + return ox_inventory:Search('count', item) > 0 end ----comment +---This will return th count of the item in the players inventory, if not found will return 0. ---@param item string ---@return number Inventory.GetItemCount = function(item) return ox_inventory:GetItemCount(item, nil, false) end ----comment +---This will get the image path for this item, if not found will return placeholder. ---@param item string ---@return string Inventory.GetImagePath = function(item) @@ -46,14 +44,12 @@ Inventory.GetImagePath = function(item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" end ----comment +---This will return the players inventory in the format of {name, label, count, slot, metadata} ---@return table Inventory.GetPlayerInventory = function() - return exports.ox_inventory:GetPlayerItems() + return ox_inventory:GetPlayerItems() end Inventory.OpenShop = function(shopTitle, shopInventory) ox_inventory:openInventory("shop", { type = shopTitle, id = 1 }) -end - ---Bridge.RegisterModule("Inventory", Inventory) +end \ No newline at end of file diff --git a/modules/inventory/ps-inventory/client.lua b/modules/inventory/ps-inventory/client.lua index cf69bb0..b56364d 100644 --- a/modules/inventory/ps-inventory/client.lua +++ b/modules/inventory/ps-inventory/client.lua @@ -1,34 +1,12 @@ ---@diagnostic disable: duplicate-set-field if GetResourceState('ps-inventory') ~= 'started' then return end - local ps = exports['ps-inventory'] Inventory = Inventory or {} -RegisterNetEvent('community_bridge:client:ps-inventory:openStash', function(id, data) - if source ~= 65535 then return end - TriggerEvent('ps-inventory:client:SetCurrentStash', id) - TriggerServerEvent('ps-inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots }) -end) - - ----comment +---Return the item info in oxs format, {name, label, stack, weight, description, image} ---@param item string ----@return boolean -Inventory.HasItem = function(item) - return ps:HasItem(item) -end - ----comment ----@param item string ----@return string -Inventory.GetImagePath = function(item) - item = Inventory.StripPNG(item) - local file = LoadResourceFile("ps-inventory", string.format("html/images/%s.png", item)) - local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item) - return imagePath or "https://avatars.githubusercontent.com/u/47620135" -end - +---@return table Inventory.GetItemInfo = function(item) local itemData = Framework.Shared.Items[item] if not itemData then return {} end @@ -40,4 +18,27 @@ Inventory.GetItemInfo = function(item) description = itemData.description, image = Inventory.GetImagePath(itemData.name) } -end \ No newline at end of file +end + +---Will return boolean if the player has the item. +---@param item string +---@return boolean +Inventory.HasItem = function(item) + return ps:HasItem(item) +end + +---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("ps-inventory", string.format("html/images/%s.png", item)) + local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item) + return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end + +RegisterNetEvent('community_bridge:client:ps-inventory:openStash', function(id, data) + if source ~= 65535 then return end + TriggerEvent('ps-inventory:client:SetCurrentStash', id) + TriggerServerEvent('ps-inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots }) +end) \ No newline at end of file diff --git a/modules/inventory/qb-inventory/client.lua b/modules/inventory/qb-inventory/client.lua index 10cab4f..ef831f0 100644 --- a/modules/inventory/qb-inventory/client.lua +++ b/modules/inventory/qb-inventory/client.lua @@ -1,33 +1,12 @@ ---@diagnostic disable: duplicate-set-field if GetResourceState('qb-inventory') ~= 'started' then return end - local qb = exports['qb-inventory'] Inventory = Inventory or {} -RegisterNetEvent('community_bridge:client:qb-inventory:openStash', function(id, data) - if source ~= 65535 then return end - TriggerEvent("inventory:client:SetCurrentStash", id) - TriggerServerEvent('inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots }) -end) - ----This will return a boolean if the player has the item in their inventory +---Return the item info in oxs format, {name, label, stack, weight, description, image} ---@param item string ----@return boolean -Inventory.HasItem = function(item) - return qb:HasItem(item) -end - ----This will return a string of the image path for the item ----@param item string ----@return string -Inventory.GetImagePath = function(item) - item = Inventory.StripPNG(item) - local file = LoadResourceFile("qb-inventory", string.format("html/images/%s.png", item)) - local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item) - return imagePath or "https://avatars.githubusercontent.com/u/47620135" -end - +---@return table Inventory.GetItemInfo = function(item) local itemData = Framework.Shared.Items[item] if not itemData then return {} end @@ -41,3 +20,25 @@ Inventory.GetItemInfo = function(item) } end +---Will return boolean if the player has the item. +---@param item string +---@return boolean +Inventory.HasItem = function(item) + return qb:HasItem(item) +end + +---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("qb-inventory", string.format("html/images/%s.png", item)) + local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item) + return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end + +RegisterNetEvent('community_bridge:client:qb-inventory:openStash', function(id, data) + if source ~= 65535 then return end + TriggerEvent("inventory:client:SetCurrentStash", id) + TriggerServerEvent('inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots }) +end) \ No newline at end of file diff --git a/modules/inventory/qs-inventory/client.lua b/modules/inventory/qs-inventory/client.lua index a1058aa..384710a 100644 --- a/modules/inventory/qs-inventory/client.lua +++ b/modules/inventory/qs-inventory/client.lua @@ -1,16 +1,10 @@ ---@diagnostic disable: duplicate-set-field if GetResourceState('qs-inventory') ~= 'started' then return end local quasar = exports["qs-inventory"] + Inventory = Inventory or {} ----comment ----@param id any ----@return nil -Inventory.OpenStash = function(id) - quasar:RegisterStash(id, 50, 50000) -end - ----comment +---Return the item info in oxs format, {name, label, stack, weight, description, image} ---@param item string ---@return table Inventory.GetItemInfo = function(item) @@ -28,7 +22,7 @@ Inventory.GetItemInfo = function(item) } end ----comment +---Will return boolean if the player has the item. ---@param item string ---@return boolean Inventory.HasItem = function(item) @@ -36,7 +30,15 @@ Inventory.HasItem = function(item) return check and true or false end ----comment +---This will return th count of the item in the players inventory, if not found will return 0. +---@param item string +---@return number +Inventory.GetItemCount = function(item) + local searchItem = quasar:Search(item) + return searchItem or 0 +end + +---This will get the image path for this item, if not found will return placeholder. ---@param item string ---@return string Inventory.GetImagePath = function(item) @@ -46,15 +48,7 @@ Inventory.GetImagePath = function(item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" end ----comment ----@param item string ----@return number -Inventory.GetItemCount = function(item) - local searchItem = quasar:Search(item) - return searchItem or 0 -end - ----comment +---This will return the players inventory in the format of {name, label, count, slot, metadata} ---@return table Inventory.GetPlayerInventory = function() local items = {} @@ -74,3 +68,9 @@ Inventory.GetPlayerInventory = function() return items end +---comment +---@param id any +---@return nil +Inventory.OpenStash = function(id) + quasar:RegisterStash(id, 50, 50000) +end diff --git a/modules/inventory/tgiann-inventory/client.lua b/modules/inventory/tgiann-inventory/client.lua index ed33bd8..75c055e 100644 --- a/modules/inventory/tgiann-inventory/client.lua +++ b/modules/inventory/tgiann-inventory/client.lua @@ -4,12 +4,7 @@ local tgiann = exports["tgiann-inventory"] Inventory = Inventory or {} ----@param id any ----@return nil -Inventory.OpenStash = function(id) - -- open stash export... not sure what it is yet. -end - +---Return the item info in oxs format, {name, label, stack, weight, description, image} ---@param item string ---@return table Inventory.GetItemInfo = function(item) @@ -25,7 +20,14 @@ Inventory.GetItemInfo = function(item) } end ----comment +---Will return boolean if the player has the item. +---@param item string +---@return boolean +Inventory.HasItem = function(item) + return tgiann:HasItem(item) +end + +---This will return th count of the item in the players inventory, if not found will return 0. ---@param item string ---@return number Inventory.GetItemCount = function(item) @@ -33,14 +35,7 @@ Inventory.GetItemCount = function(item) return searchItem or 0 end ----This will return a boolean if the player has the item in the inventory ----@param item string ----@return boolean -Inventory.HasItem = function(item) - return tgiann:HasItem(item) -end - --- This will return the image path, it is incredibley useful for menus etc +---This will get the image path for this item, if not found will return placeholder. ---@param item string ---@return string Inventory.GetImagePath = function(item) @@ -51,7 +46,7 @@ Inventory.GetImagePath = function(item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" end ----This will return the player inventory in a table +---This will return the players inventory in the format of {name, label, count, slot, metadata} ---@return table Inventory.GetPlayerInventory = function() local items = {} @@ -70,3 +65,9 @@ Inventory.GetPlayerInventory = function() end return items end + +---@param id any +---@return nil +Inventory.OpenStash = function(id) + -- open stash export... not sure what it is yet. +end \ No newline at end of file From e1235dfc7c4da9343471d5bb64540f3862ddfb9f Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Fri, 9 May 2025 06:03:09 -0400 Subject: [PATCH 08/38] reorganized, notation --- modules/framework/qb-core/server.lua | 13 +- modules/inventory/_default/server.lua | 88 +++++-- modules/inventory/codem-inventory/client.lua | 4 + modules/inventory/codem-inventory/server.lua | 155 +++++++++--- modules/inventory/core_inventory/server.lua | 182 +++++++++----- modules/inventory/jpr-inventory/server.lua | 138 ++++++---- modules/inventory/origen_inventory/server.lua | 206 +++++++++------ modules/inventory/ox_inventory/server.lua | 150 ++++++----- modules/inventory/ps-inventory/server.lua | 180 ++++++++----- modules/inventory/qb-inventory/server.lua | 165 +++++++----- modules/inventory/qs-inventory/server.lua | 238 ++++++++++-------- modules/inventory/tgiann-inventory/server.lua | 191 ++++++++------ 12 files changed, 1095 insertions(+), 615 deletions(-) diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index 1d81bc3..fa9028f 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -72,7 +72,7 @@ Framework.GetItem = function(src, item, metadata) return repackedTable end ----This will get the data about an item such as name, label, stack, weight, description and image. +---This will return a table with the item info, {name, label, stack, weight, description, image} ---@param item string ---@return table Framework.GetItemInfo = function(item) @@ -89,8 +89,13 @@ Framework.GetItemInfo = function(item) return repackedTable end --- Framework.GetItemCount(src, item, metadata) --- Returns the count of items matching the specified name and if passed metadata from the player's inventory. +---This will return the count of the item in the players inventory, if not found will return 0. +--- +---if metadata is passed it will find the matching items count. +---@param src number +---@param item string +---@param metadata table +---@return number Framework.GetItemCount = function(src, item, metadata) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -105,7 +110,7 @@ Framework.GetItemCount = function(src, item, metadata) return count end ----comment +---This will return a boolean if the player has the item. ---@param src number ---@param item string ---@return boolean diff --git a/modules/inventory/_default/server.lua b/modules/inventory/_default/server.lua index 48cfc2b..eac7130 100644 --- a/modules/inventory/_default/server.lua +++ b/modules/inventory/_default/server.lua @@ -1,37 +1,41 @@ ---@diagnostic disable: duplicate-set-field Inventory = Inventory or {} ----This will fallback to framework add item functions when an inventory does not have the specifiec function. +---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 ---@param metadata table ----@return boolean|nil +---@return boolean Inventory.AddItem = function(src, item, count, slot, metadata) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata}) return Framework.AddItem(src, item, count, slot, metadata) end ----This will fallback to framework add item functions when an inventory does not have the specifiec function. +---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 ---@param metadata table ----@return boolean|nil +---@return boolean Inventory.RemoveItem = function(src, item, count, slot, metadata) item = type(item) == "table" and item.name or item + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata}) return Framework.RemoveItem(src, item, count, slot, metadata) end ----This will fallback to framework add item functions when an inventory does not have the specifiec function. +---This will return a table with the item info, {name, label, stack, weight, description, image} ---@param item string ---@return table Inventory.GetItemInfo = function(item) return Framework.GetItemInfo(item) end ----This will fallback to framework add item functions when an inventory does not have the specifiec function. +---This will return the count of the item in the players inventory, if not found will return 0. +--- +---if metadata is passed it will find the matching items count. ---@param src number ---@param item string ---@param metadata table @@ -40,14 +44,16 @@ Inventory.GetItemCount = function(src, item, metadata) return Framework.GetItemCount(src, item, metadata) end ----This will fallback to framework add item functions when an inventory does not have the specifiec function. +---This wil return the players inventory. ---@param src number ---@return table Inventory.GetPlayerInventory = function(src) return Framework.GetPlayerInventory(src) end ----This will fallback to framework add item functions when an inventory does not have the specifiec function. +---Returns the specified slot data as a table. +--- +---format {weight, name, metadata, slot, label, count} ---@param src number ---@param slot number ---@return table @@ -55,19 +61,32 @@ Inventory.GetItemBySlot = function(src, slot) return Framework.GetItemBySlot(src, slot) end ----This will fallback to framework add item functions when an inventory does not have the specifiec function. +---This will set the metadata of an item in the inventory. ---@param src number ---@param item string ---@param slot number ---@param metadata table ----@return boolean +---@return nil Inventory.SetMetadata = function(src, item, slot, metadata) return Framework.SetMetadata(src, item, slot, metadata) end ----This will fallback to framework add item functions when an inventory does not have the specifiec function. +---This will open the specified stash for the src passed. ---@param src number ----@param id string||number +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return nil +Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) + return false, Prints.Error("This Inventory Has Not Been Bridged For A Stash Feature.") +end + +---This will register a stash +---@param id number||string ---@param label string ---@param slots number ---@param weight number @@ -75,11 +94,52 @@ end ---@param groups table ---@param coords table ---@return boolean -Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) +Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) return false, Prints.Error("This Inventory Has Not Been Bridged For A Stash Feature.") end ----This will provide a image of the community bridge logo if the inventory isnt bridged for the specific path. +---This will return a boolean if the player has the item. +---@param src number +---@param item string +---@return boolean +Inventory.HasItem = function(src, item) + return Framework.HasItem(src, item) +end + +---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 false, Prints.Error("This Inventory Has Not Been Bridged For A CanCarryItem Feature.") +end + +---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) + return false, Prints.Error("This Inventory Has Not Been Bridged For A UpdatePlate Feature.") +end + +-- This will open the specified shop for the src passed. +---@param src number +---@param shopTitle string +Inventory.OpenShop = function(src, shopTitle) + return false, Prints.Error("This Inventory Has Not Been Bridged For A OpenShop Feature.") +end + +-- This will register a shop, if it already exists it will return true. +-- @param shopTitle string +-- @param shopInventory table +-- @param shopCoords table +-- @param shopGroups table +Inventory.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups) + return false, Prints.Error("This Inventory Has Not Been Bridged For A CreateShop Feature.") +end + +---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) diff --git a/modules/inventory/codem-inventory/client.lua b/modules/inventory/codem-inventory/client.lua index ea2b347..4893b37 100644 --- a/modules/inventory/codem-inventory/client.lua +++ b/modules/inventory/codem-inventory/client.lua @@ -51,3 +51,7 @@ Inventory.GetPlayerInventory = function() return items end +RegisterNetEvent('community_bridge:client:codem-inventory:openStash', function(id, data) + if source ~= 65535 then return end + TriggerServerEvent('codem-inventory:server:openstash', id, data.slots, data.weight, data.label) +end) \ No newline at end of file diff --git a/modules/inventory/codem-inventory/server.lua b/modules/inventory/codem-inventory/server.lua index 8963a93..4f68f4b 100644 --- a/modules/inventory/codem-inventory/server.lua +++ b/modules/inventory/codem-inventory/server.lua @@ -5,6 +5,33 @@ Inventory = Inventory or {} local codem = exports['codem-inventory'] +---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 +---@param metadata table +---@return boolean +Inventory.AddItem = function(src, item, count, slot, metadata) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata}) + return codem:AddItem(src, item, count, slot, metadata) +end + +---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 +---@param metadata table +---@return boolean +Inventory.RemoveItem = function(src, item, count, slot, metadata) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata}) + return codem:RemoveItem(src, item, count, slot) +end + +---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 = codem:GetItemList(item) if not itemData then return {} end @@ -18,15 +45,9 @@ Inventory.GetItemInfo = function(item) } end -Inventory.AddItem = function(src, item, count, slot, metadata) - TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata}) - return codem:AddItem(src, item, count, slot, metadata) -end - -Inventory.GetItemBySlot = function(src, slot) - return codem:GetItemBySlot(src, slot) -end - +---This wil return the players inventory. +---@param src number +---@return table Inventory.GetPlayerInventory = function(src) local identifier = Framework.GetPlayerIdentifier(src) local playerItems = codem:GetInventory(identifier, src) @@ -42,26 +63,65 @@ Inventory.GetPlayerInventory = function(src) return repackedTable end -Inventory.RemoveItem = function(src, item, count, slot, metadata) - if not slot and metadata then - local inv = Inventory.GetPlayerInventory(src) - if not inv then return false end - for _, v in pairs(inv) do - if v.name == item and v.metadata == metadata then - slot = v.slot - break - end - end - end - TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata}) - return codem:RemoveItem(src, item, count, slot) +---Returns the specified slot data as a table. +--- +---format {weight, name, metadata, slot, label, count} +---@param src number +---@param slot number +---@return table +Inventory.GetItemBySlot = function(src, slot) + local slotData = codem:GetItemBySlot(src, slot) + if not slotData then return {} end + return { + name = v.name, + label = v.label or v.name, + weight = v.weight, + slot = v.slot, + count = v.amount or v.count, + metadata = v.info or v.metadata, + stack = v.unique, + description = v.description + } end +---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) return codem:SetItemMetadata(src, slot, metadata) end ----comment +---This will open the specified stash for the src passed. +---@param src number +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return nil +Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) + TriggerClientEvent('community_bridge:client:codem-inventory:openStash', src, id, { label = label, slots = slots, weight = weight }) +end + +---This will register a stash +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return boolean +Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) + return true +end + +---This will return a boolean if the player has the item. ---@param src number ---@param item string ---@return boolean @@ -69,23 +129,26 @@ Inventory.HasItem = function(src, item) return codem:HasItem(src, item, 1) end -Inventory.GetItemBySlot = function(src, slot) - local slotData = codem:GetItemBySlot(src, slot) - if not slotData then return {} end - for _, v in pairs(slotData) do - return { - name = v.name, - label = v.name, - weight = v.weight, - slot = v.slot, - count = v.amount, - metadata = v.info, - stack = v.unique, - description = v.description - } - end +---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 true end +---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) + return false, print("Unable to update plate for codem-inventory, I do not have access to a copy of this inventory to bridge the feature.") +end + +---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("codem-inventory", string.format("html/images/%s.png", item)) @@ -93,3 +156,19 @@ Inventory.GetImagePath = function(item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" end + +-- This will open the specified shop for the src passed. +---@param src number +---@param shopTitle string +Inventory.OpenShop = function(src, shopTitle) + print("Unable to open shop for codem-inventory, I do not have access to a copy of this inventory to bridge the feature.") +end + +-- This will register a shop, if it already exists it will return true. +-- @param shopTitle string +-- @param shopInventory table +-- @param shopCoords table +-- @param shopGroups table +Inventory.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups) + return true, print("Unable to Create Shop for codem-inventory, I do not have access to a copy of this inventory to bridge the feature.") +end \ No newline at end of file diff --git a/modules/inventory/core_inventory/server.lua b/modules/inventory/core_inventory/server.lua index e190413..d9869fa 100644 --- a/modules/inventory/core_inventory/server.lua +++ b/modules/inventory/core_inventory/server.lua @@ -5,16 +5,6 @@ Inventory = Inventory or {} local core = exports.core_inventory ----comment ----@param item string ----@return string -Inventory.GetImagePath = function(item) - item = Inventory.StripPNG(item) - local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item)) - local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item) - return imagePath or "https://avatars.githubusercontent.com/u/47620135" -end - ---This will add an item, and return true or false based on success ---@param src number ---@param item string @@ -24,24 +14,16 @@ end ---@return boolean Inventory.AddItem = function(src, item, count, slot, metadata) TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata}) - local itemsAdd = core:addItem(src, item, count, metadata) - return itemsAdd -end - -Inventory.GetPlayerInventory = function(src) - local playerItems = core:getInventory(src) - local repackedTable = {} - for _, v in pairs(playerItems) do - table.insert(repackedTable, { - name = v.name, - count = v.count, - metadata = v.metadata, - slot = v.id, - }) - end - return repackedTable + return core:addItem(src, item, count, metadata) end +---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 +---@param metadata table +---@return boolean Inventory.RemoveItem = function(src, item, count, slot, metadata) if not slot and metadata then local inv = Inventory.GetPlayerInventory(src) @@ -69,27 +51,9 @@ Inventory.RemoveItem = function(src, item, count, slot, metadata) -- I hate this inventory so much, I am so sorry for this. end ----This will get the item from the specified slot. ----@param src number ----@param slot number ----@return table -Inventory.GetItemBySlot = function(src, slot) - local inv = Inventory.GetPlayerInventory(src) - if not inv then return {} end - for _, v in pairs(inv) do - if v.slot == slot then - return { - name = v.name, - count = v.count, - metadata = v.metadata, - slot = v.slot, - } - end - end - return {} -end - ----Returns the total count of an item in the inventory. +---This will return the count of the item in the players inventory, if not found will return 0. +--- +---if metadata is passed it will find the matching items count. ---@param src number ---@param item string ---@param metadata table @@ -110,13 +74,43 @@ Inventory.GetItemCount = function(src, item, metadata) return count or 0 end ----Returns boolean if the player has the item in their inventory. +---This wil return the players inventory. ---@param src number ----@param item string ----@return boolean -Inventory.HasItem = function(src, item) - local count = core:getItemCount(src, item) - return count > 0 +---@return table +Inventory.GetPlayerInventory = function(src) + local playerItems = core:getInventory(src) + local repackedTable = {} + for _, v in pairs(playerItems) do + table.insert(repackedTable, { + name = v.name, + count = v.count, + metadata = v.metadata, + slot = v.id, + }) + end + return repackedTable +end + +---Returns the specified slot data as a table. +--- +---format {weight, name, metadata, slot, label, count} +---@param src number +---@param slot number +---@return table +Inventory.GetItemBySlot = function(src, slot) + local inv = Inventory.GetPlayerInventory(src) + if not inv then return {} end + for _, v in pairs(inv) do + if v.slot == slot then + return { + name = v.name, + count = v.count, + metadata = v.metadata, + slot = v.slot, + } + end + end + return {} end ---This will set the metadata of an item in the inventory. @@ -129,7 +123,56 @@ Inventory.SetMetadata = function(src, item, slot, metadata) core:setMetadata(src, slot, metadata) end ----comment +---This will open the specified stash for the src passed. +---@param src number +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return nil +Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) + if not slots then slots = 30 end + local mathyShit = slots / 2 + core:openInventory(playerid, id, 'stash', mathyShit, mathyShit, true, nil, false) +end + +---This will register a stash +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return boolean +Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) + if not slots then slots = 30 end + local mathyShit = slots / 2 + core:openInventory(nil, id, 'stash', mathyShit, mathyShit, false, nil, false) + return true +end + +---This will return a boolean if the player has the item. +---@param src number +---@param item string +---@return boolean +Inventory.HasItem = function(src, item) + return core:getItemCount(src, item) > 0 +end + +---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 true +end + +---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 @@ -148,10 +191,37 @@ Inventory.UpdatePlate = function(oldplate, newplate) } MySQL.transaction.await(queries, values) if GetResourceState('jg-mechanic') ~= 'started' then return true end - exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) - return true + return true, exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) end +---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("core_inventory", string.format("html/img/%s.png", item)) + local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item) + return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end + +-- This will open the specified shop for the src passed. +---@param src number +---@param shopTitle string +Inventory.OpenShop = function(src, shopTitle) + return false, print("Unable to open shop for core_inventory, I do not have access to a copy of this inventory to bridge the feature.") +end + +-- This will register a shop, if it already exists it will return true. +-- @param shopTitle string +-- @param shopInventory table +-- @param shopCoords table +-- @param shopGroups table +Inventory.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups) + return false, print("Unable to open shop for core_inventory, I do not have access to a copy of this inventory to bridge the feature.") +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. lib.callback.register('community_bridge:Callback:core_inventory', function(source) local items = core:getItemsList() return items or {} diff --git a/modules/inventory/jpr-inventory/server.lua b/modules/inventory/jpr-inventory/server.lua index 908374f..df331af 100644 --- a/modules/inventory/jpr-inventory/server.lua +++ b/modules/inventory/jpr-inventory/server.lua @@ -2,55 +2,46 @@ if GetResourceState('jpr-inventory') ~= 'started' then return end local jpr = exports['jpr-inventory'] +local registeredShops = {} Inventory = Inventory or {} ----comment ----@param id string||number ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@param groups table ----@param coords table ----@return boolean -Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) - return true -end - ----comment +---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 +---@param metadata table ---@return boolean -Inventory.HasItem = function(src, item) - return jpr:HasItem(src, item, 1) +Inventory.AddItem = function(src, item, count, slot, metadata) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata}) + return exports['jpr-inventory']:AddItem(src, item, count, slot, metadata, 'community_bridge Item added') end ----comment +---This will remove an item, and return true or false based on success ---@param src number ----@param id string||number ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@param groups table ----@param coords table ----@return nil -Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) - TriggerClientEvent('community_bridge:client:qb-inventory:openStash', src, id, { weight = weight, slots = slots }) -end - ----comment ---@param item string ----@return string -Inventory.GetImagePath = function(item) - item = Inventory.StripPNG(item) - local file = LoadResourceFile("jpr-inventory", string.format("html/images/%s.png", item)) - local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item) - return imagePath or "https://avatars.githubusercontent.com/u/47620135" +---@param count number +---@param slot number +---@param metadata table +---@return boolean +Inventory.RemoveItem = function(src, item, count, slot, metadata) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata}) + return exports['jpr-inventory']:RemoveItem(src, item, count, slot, 'community_bridge Item removed') end ----comment +---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 itemTable = Framework.GetItemInfo(item) + itemTable.image = Inventory.GetImagePath(item) + return itemTable +end + +---Returns the specified slot data as a table. +--- +---format {weight, name, metadata, slot, label, count} ---@param src number ---@param slot number ---@return table @@ -69,7 +60,51 @@ Inventory.GetItemBySlot = function(src, slot) } end ----comment +---This will open the specified stash for the src passed. +---@param src number +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return nil +Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) + TriggerClientEvent('community_bridge:client:jpr-inventory:openStash', src, id, { weight = weight, slots = slots }) +end + +---This will register a stash +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return boolean +Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) + return true +end + +---This will return a boolean if the player has the item. +---@param src number +---@param item string +---@return boolean +Inventory.HasItem = function(src, item) + return jpr:HasItem(src, item, 1) +end + +---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 true +end + +---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 @@ -81,18 +116,32 @@ Inventory.UpdatePlate = function(oldplate, newplate) local values = { newplate = newplate, oldplate = oldplate } MySQL.transaction.await(queries, values) if GetResourceState('jg-mechanic') ~= 'started' then return true end - exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) - return true + return true, exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) end +---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("jpr-inventory", string.format("html/images/%s.png", item)) + local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item) + return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end -local registeredShops = {} - +-- This will open the specified shop for the src passed. +---@param src number +---@param shopTitle string Inventory.OpenShop = function(src, shopTitle) - return jpr:OpenShop(src, shopTitle) + jpr:OpenShop(src, shopTitle) end -Inventory.CreateShop = function(src, shopTitle, shopInventory, shopCoords, shopGroups) +-- This will register a shop, if it already exists it will return true. +-- @param shopTitle string +-- @param shopInventory table +-- @param shopCoords table +-- @param shopGroups table +Inventory.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups) if not shopTitle or not shopInventory or not shopCoords then return end if registeredShops[shopTitle] then return true end @@ -104,6 +153,5 @@ Inventory.CreateShop = function(src, shopTitle, shopInventory, shopCoords, shopG jpr:CreateShop(repackedShopItems) registeredShops[shopTitle] = true - --Inventory.OpenShop(src, shopTitle) return true end \ No newline at end of file diff --git a/modules/inventory/origen_inventory/server.lua b/modules/inventory/origen_inventory/server.lua index a2e69f5..11d4cfa 100644 --- a/modules/inventory/origen_inventory/server.lua +++ b/modules/inventory/origen_inventory/server.lua @@ -3,29 +3,37 @@ if GetResourceState('origen_inventory') ~= 'started' then return end Inventory = Inventory or {} -local origen_inventory = exports.origen_inventory +local origin = exports.origen_inventory -Inventory.AddItem = function(src, item, count, slot, metadata) - TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata}) - return origen_inventory:AddItem(src, item, count, metadata, slot, true) -end - -Inventory.RemoveItem = function(src, item, count, slot, metadata) - TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata}) - return origen_inventory:removeItem(src, item, count, metadata, slot, true) -end - ----comment +---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 +---@param metadata table ---@return boolean -Inventory.HasItem = function(src, item) - local count = origen_inventory:getItemCount(src , item) - return count > 0 +Inventory.AddItem = function(src, item, count, slot, metadata) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata}) + return origin:AddItem(src, item, count, metadata, slot, true) end +---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 +---@param metadata table +---@return boolean +Inventory.RemoveItem = function(src, item, count, slot, metadata) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata}) + return origin:removeItem(src, item, count, metadata, slot, true) +end + +---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 = origen_inventory:Items(item) + local itemData = origin:Items(item) if not itemData then return {} end return { name = itemData.name or "Missing Name", @@ -37,79 +45,106 @@ Inventory.GetItemInfo = function(item) } end + +---This will return the count of the item in the players inventory, if not found will return 0. +--- +---if metadata is passed it will find the matching items count. +---@param src number +---@param item string +---@param metadata table +---@return number Inventory.GetItemCount = function(src, item, metadata) - if not metadata then - return origen_inventory:GetItemTotalAmount(src, item) - else - local items = origen_inventory:GetInventory(src) - local count = 0 - for _, itemInfo in pairs(items) do - if itemInfo.name == item and itemInfo.info == metadata or itemInfo.metadata == metadata then - count = count + itemInfo.count - end - end - return count - end + return origin:getItemCount(src, item, metadata, false) end +---This wil return the players inventory. +---@param src number +---@return table Inventory.GetPlayerInventory = function(src) - local playerItems = origen_inventory:GetInventory(src) - local repackedTable = {} - for _, v in pairs(playerItems.inventory) do - table.insert(repackedTable, { - name = v.name, - count = v.count, - metadata = v.metadata, - slot = v.slot, - }) - end - return repackedTable + return origin:GetInventory(src) end +---Returns the specified slot data as a table. +--- +---format {weight, name, metadata, slot, label, count} +---@param src number +---@param slot number +---@return table Inventory.GetItemBySlot = function(src, slot) - -- This inventory got rid of almost all the great exports they had =( - local slotData = Inventory.GetInventoryItems(src) - for _, item in pairs(slotData) do - if item.slot == slot then + local inv = origin:getInventory(src) + for k, v in pairs(inv) do + if v.slot == slot then return { - name = item.name, - label = item.name, - weight = item.weight, - slot = slot, - count = item.amount, - metadata = item.metadata, - stack = item.unique or false, - description = item.description + weight = v.weight, + name = v.name, + metadata = v.metadata, + slot = v.slot, + label = v.label, + count = v.count } end end return {} end -Inventory.CanCarryItem = function(src, item, count) - return origen_inventory:CanCarryItems(src, item, count) -end - -Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) - return origen_inventory:RegisterStash(id, { label = label, slots = slots, weight = weight }) -end - -Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) - return origen_inventory:OpenInventory(src, 'stash', id) -end - +---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) - Inventory.RemoveItem (src, item, 1, slot, nil) - Inventory.AddItem(src, item, 1, slot, metadata) + origin:setMetadata(src, slot, metadata) end -Inventory.GetImagePath = function(item) - item = Inventory.StripPNG(item) - local file = LoadResourceFile("origen_inventory", string.format("html/images/%s.png", item)) - local imagePath = file and string.format("nui://origen_inventory/html/images/%s.png", item) - return imagePath or "https://avatars.githubusercontent.com/u/47620135" +---This will open the specified stash for the src passed. +---@param src number +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return nil +Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) + return origin:OpenInventory(src, 'stash', id) end +---This will register a stash +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return boolean +Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) + return origin:registerStash(id, label, slots, weight, owner, groups, coords) +end + +---This will return a boolean if the player has the item. +---@param src number +---@param item string +---@return boolean +Inventory.HasItem = function(src, item) + return origin:getItemCount(src , item) > 0 +end + +---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 origin:canCarryItem(src, item, count) +end + +---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) local queries = { 'UPDATE gloveboxitems SET plate = @newplate WHERE plate = @oldplate', @@ -118,6 +153,31 @@ Inventory.UpdatePlate = function(oldplate, newplate) local values = { newplate = newplate, oldplate = oldplate } MySQL.transaction.await(queries, values) if GetResourceState('jg-mechanic') ~= 'started' then return true end - exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) - return true -end \ No newline at end of file + return true, exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) +end + +---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("origin", string.format("html/images/%s.png", item)) + local imagePath = file and string.format("nui://origen_inventory/html/images/%s.png", item) + return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end + +-- This will open the specified shop for the src passed. +---@param src number +---@param shopTitle string +Inventory.OpenShop = function(src, shopTitle) + print("Currently runtime shops are not supported in origen_inventory") +end + +-- This will register a shop, if it already exists it will return true. +-- @param shopTitle string +-- @param shopInventory table +-- @param shopCoords table +-- @param shopGroups table +Inventory.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups) + return true, print("Currently runtime shops are not supported in origen_inventory") +end diff --git a/modules/inventory/ox_inventory/server.lua b/modules/inventory/ox_inventory/server.lua index cbe0569..02e6cfb 100644 --- a/modules/inventory/ox_inventory/server.lua +++ b/modules/inventory/ox_inventory/server.lua @@ -2,6 +2,7 @@ if GetResourceState('ox_inventory') ~= 'started' then return end local ox_inventory = exports.ox_inventory +local registeredShops = {} Inventory = Inventory or {} @@ -17,20 +18,6 @@ Inventory.AddItem = function(src, item, count, slot, metadata) return ox_inventory:AddItem(src, item, count, metadata) end -Inventory.GetItemInfo = function(item) - local itemData = ox_inventory:Items(item) - if not itemData then return {} end - return { - name = itemData.name or "Missing Name", - label = itemData.label or "Missing Label", - stack = itemData.stack or "true", - weight = itemData.weight or "0", - description = itemData.description or "none", - image = string.format("nui://ox_inventory/web/images/%s", itemData.client and itemData.client.image or string.format("%s.png", item)), - } -end --- string.format("nui://ox_inventory/web/images/%s.png", item) - ---This will remove an item, and return true or false based on success ---@param src number ---@param item string @@ -43,24 +30,25 @@ Inventory.RemoveItem = function(src, item, count, slot, metadata) return ox_inventory:RemoveItem(src, item, count, metadata, slot) end ----comment ----@param src number +---This will return a table with the item info, {name, label, stack, weight, description, image} ---@param item string ----@param metadata table ---@return table -Inventory.GetItem = function(src, item, metadata) - return ox_inventory:GetItem(src, item, metadata, false) +Inventory.GetItemInfo = function(item) + local itemData = ox_inventory:Items(item) + if not itemData then return {} end + return { + name = itemData.name or "Missing Name", + label = itemData.label or "Missing Label", + stack = itemData.stack or "true", + weight = itemData.weight or "0", + description = itemData.description or "none", + image = string.format("nui://ox_inventory/web/images/%s", itemData.client and itemData.client.image or string.format("%s.png", item)), + } end ----This will get the item from the specified slot. ----@param src number ----@param slot number ----@return table -Inventory.GetItemBySlot = function(src, slot) - return ox_inventory:GetSlot(src, slot) -end - ----comment +---This will return the count of the item in the players inventory, if not found will return 0. +--- +---if metadata is passed it will find the matching items count. ---@param src number ---@param item string ---@param metadata table @@ -69,15 +57,6 @@ Inventory.GetItemCount = function(src, item, metadata) return ox_inventory:GetItemCount(src, item, metadata, false) end ----comment ----@param src number ----@param item string ----@return boolean -Inventory.HasItem = function(src, item) - local count = ox_inventory:GetItemCount(src, item, nil, false) - return count > 0 -end - ---This wil return the players inventory. ---@param src number ---@return table @@ -85,13 +64,38 @@ Inventory.GetPlayerInventory = function(src) return ox_inventory:GetInventoryItems(src, false) end ----This is to get if there is available space in the inventory. +---Returns the specified slot data as a table. +--- +---format {weight, name, metadata, slot, label, count} +---@param src number +---@param slot number +---@return table +Inventory.GetItemBySlot = function(src, slot) + return ox_inventory:GetSlot(src, slot) +end + +---This will set the metadata of an item in the inventory. ---@param src number ---@param item string ----@param count number ----@return boolean -Inventory.CanCarryItem = function(src, item, count) - return ox_inventory:CanCarryItem(src, item, count) +---@param slot number +---@param metadata table +---@return nil +Inventory.SetMetadata = function(src, item, slot, metadata) + ox_inventory:SetMetadata(src, slot, metadata) +end + +---This will open the specified stash for the src passed. +---@param src number +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return nil +Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) + TriggerClientEvent('ox_inventory:openInventory', src, 'stash', 'stash_' .. id) end ---This will register a stash @@ -107,28 +111,21 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor return ox_inventory:RegisterStash(id, label, slots, weight, owner) end ----comment ----@param src number ----@param id number||string ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@param groups table ----@param coords table ----@return nil -Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) - TriggerClientEvent('ox_inventory:openInventory', src, 'stash', 'stash_' .. id) -end - ----This will set the metadata of an item in the inventory. +---This will return a boolean if the player has the item. ---@param src number ---@param item string ----@param slot number ----@param metadata table ----@return nil -Inventory.SetMetadata = function(src, item, slot, metadata) - ox_inventory:SetMetadata(src, slot, metadata) +---@return boolean +Inventory.HasItem = function(src, item) + return ox_inventory:GetItemCount(src, item, nil, false) > 0 +end + +---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 ox_inventory:CanCarryItem(src, item, count) end ---This will update the plate to the vehicle inside the inventory. (It will also update with jg-mechanic if using it) @@ -138,8 +135,7 @@ end Inventory.UpdatePlate = function(oldplate, newplate) ox_inventory:UpdateVehicle(oldplate, newplate) if GetResourceState('jg-mechanic') ~= 'started' then return true end - exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) - return true + return true, exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) end ---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) @@ -152,16 +148,38 @@ Inventory.GetImagePath = function(item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" end -local registeredShops = {} - +-- This will open the specified shop for the src passed. +---@param src number +---@param shopTitle string Inventory.OpenShop = function(src, shopTitle) TriggerClientEvent('ox_inventory:openInventory', src, 'shop', {type = shopTitle}) end +-- This will register a shop, if it already exists it will return true. +-- @param shopTitle string +-- @param shopInventory table +-- @param shopCoords table +-- @param shopGroups table Inventory.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups) if registeredShops[shopTitle] then return true end registeredShops[shopTitle] = true ox_inventory:RegisterShop(shopTitle, { name = shopTitle, inventory = shopInventory, groups = shopGroups, }) --return Inventory.OpenShop(src, shopTitle) return true +end + + + +---UNUSED: +---This will return generic item data from the specified inventory, with the items total count. +--- +---format without metadata { count, stack, name, weight, label } +--- +---fortmat with metadata { count, stack, name, weight, label, metadata } +---@param src number +---@param item string +---@param metadata table +---@return table +Inventory.GetItem = function(src, item, metadata) + return ox_inventory:GetItem(src, item, metadata, false) end \ No newline at end of file diff --git a/modules/inventory/ps-inventory/server.lua b/modules/inventory/ps-inventory/server.lua index 60ef824..879312e 100644 --- a/modules/inventory/ps-inventory/server.lua +++ b/modules/inventory/ps-inventory/server.lua @@ -1,27 +1,90 @@ ---@diagnostic disable: duplicate-set-field if GetResourceState('ps-inventory') ~= 'started' then return end - local sloth = exports['ps-inventory'] +local registeredShops = {} Inventory = Inventory or {} - ----comment ----@param id string||number ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@param groups table ----@param coords table +---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 +---@param metadata table ---@return boolean -Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) - return true +Inventory.AddItem = function(src, item, count, slot, metadata) + TriggerClientEvent('ps-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add', count) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata}) + return sloth:AddItem(src, item, count, slot, metadata, 'community_bridge') end ----comment +---This will remove an item, and return true or false based on success ---@param src number ----@param id string||number +---@param item string +---@param count number +---@param slot number +---@param metadata table +---@return boolean +Inventory.RemoveItem = function(src, item, count, slot, metadata) + TriggerClientEvent('ps-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'remove', count) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata}) + return sloth:RemoveItem(src, item, count, slot, 'community_bridge') +end + +---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 = QBCore.Shared.Items[item] + if not itemData then return {} end + return { + name = itemData.name or "Missing Name", + label = itemData.label or "Missing Label", + stack = itemData.stack or "true", + weight = itemData.weight or "0", + description = itemData.description or "none", + image = Inventory.GetImagePath(item), + } +end + +---Returns the specified slot data as a table. +--- +---format {weight, name, metadata, slot, label, count} +---@param src number +---@param slot number +---@return table +Inventory.GetItemBySlot = function(src, slot) + local slotData = sloth:GetItemBySlot(src, slot) + if not slotData then return {} end + return { + name = slotData.name, + label = slotData.label or slotData.name, + weight = slotData.weight, + slot = slot, + count = slotData.amount, + metadata = slotData.info, + stack = slotData.unique, + description = slotData.description + } +end + +---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) + local itemData = Inventory.GetItemBySlot(src, slot) + if not itemData then return end + if itemData.count > 1 then return print("Items with more than 1 count cannot be set with metadata plase adjust item to unique in the qb shared item name : "..item) end + Inventory.RemoveItem(src, item, 1, slot) + return Inventory.AddItem(src, item, 1, slot, metadata) +end + +---This will open the specified stash for the src passed. +---@param src number +---@param id number||string ---@param label string ---@param slots number ---@param weight number @@ -33,17 +96,20 @@ Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coo TriggerClientEvent('community_bridge:client:ps-inventory:openStash', src, id, { label = label, maxweight = weight, slots = slots, }) end ----comment ----@param item string ----@return string -Inventory.GetImagePath = function(item) - item = Inventory.StripPNG(item) - local file = LoadResourceFile("ps-inventory", string.format("html/images/%s.png", item)) - local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item) - return imagePath or "https://avatars.githubusercontent.com/u/47620135" +---This will register a stash +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return boolean +Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) + return true end ----comment +---This will return a boolean if the player has the item. ---@param src number ---@param item string ---@return boolean @@ -51,52 +117,16 @@ Inventory.HasItem = function(src, item) return sloth:HasItem(src, item, 1) end ----comment ----@param src number ----@param slot number ----@return table -Inventory.GetItemBySlot = function(src, slot) - local slotData = sloth:GetItemBySlot(src, slot) - if not slotData then return {} end - return { - name = slotData.name, - label = slotData.name, - weight = slotData.weight, - slot = slot, - count = slotData.amount, - metadata = slotData.info, - stack = slotData.unique, - description = slotData.description - } -end - ----comment +---This is to get if there is available space in the inventory, will return boolean. ---@param src number ---@param item string ----@param amount number ----@param slot number ----@param metadata table +---@param count number ---@return boolean -Inventory.AddItem = function(src, item, amount, slot, metadata) - TriggerClientEvent('ps-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add', amount) - TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = amount, slot = slot, metadata = metadata}) - return sloth:AddItem(src, item, amount, slot, metadata, 'community_bridge') +Inventory.CanCarryItem = function(src, item, count) + return true end ----comment ----@param src number ----@param item string ----@param amount number ----@param slot number ----@param metadata table ----@return boolean -Inventory.RemoveItem = function(src, item, amount, slot, metadata) - TriggerClientEvent('ps-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'remove', amount) - TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = amount, slot = slot, metadata = metadata}) - return sloth:RemoveItem(src, item, amount, slot, 'community_bridge') -end - ----comment +---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 @@ -108,16 +138,31 @@ Inventory.UpdatePlate = function(oldplate, newplate) local values = { newplate = newplate, oldplate = oldplate } MySQL.transaction.await(queries, values) if GetResourceState('jg-mechanic') ~= 'started' then return true end - exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) - return true + return true, exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) end -local registeredShops = {} +---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("ps-inventory", string.format("html/images/%s.png", item)) + local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item) + return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end +-- This will open the specified shop for the src passed. +---@param src number +---@param shopTitle string Inventory.OpenShop = function(src, shopTitle) return sloth:OpenShop(src, shopTitle) end +-- This will register a shop, if it already exists it will return true. +-- @param shopTitle string +-- @param shopInventory table +-- @param shopCoords table +-- @param shopGroups table Inventory.CreateShop = function(src, shopTitle, shopInventory, shopCoords, shopGroups) if not shopTitle or not shopInventory or not shopCoords then return end if registeredShops[shopTitle] then return true end @@ -130,6 +175,5 @@ Inventory.CreateShop = function(src, shopTitle, shopInventory, shopCoords, shopG sloth:CreateShop(repackedShopItems) registeredShops[shopTitle] = true - --Inventory.OpenShop(src, shopTitle) return true end \ No newline at end of file diff --git a/modules/inventory/qb-inventory/server.lua b/modules/inventory/qb-inventory/server.lua index bfd7b74..adb6418 100644 --- a/modules/inventory/qb-inventory/server.lua +++ b/modules/inventory/qb-inventory/server.lua @@ -1,46 +1,46 @@ ---@diagnostic disable: duplicate-set-field if GetResourceState('qb-inventory') ~= 'started' then return end - local qbInventory = exports['qb-inventory'] Inventory = Inventory or {} +local registeredShops = {} +local v1ShopData = {} + local function getInventoryNewVersion() - if tonumber(string.sub(GetResourceMetadata("qb-inventory", "version", 0), 1, 1)) >= 2 then - return true - else - return false - end + if tonumber(string.sub(GetResourceMetadata("qb-inventory", "version", 0), 1, 1)) >= 2 then return true end + return false end ----comment ----@param id string ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@param groups table ----@param coords table ----@return boolean -Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) - return true -end - ----comment +---This will add an item, and return true or false based on success ---@param src number ----@param id number||string ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@param groups table ----@param coords table ----@return nil -Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) - TriggerClientEvent('community_bridge:client:qb-inventory:openStash', src, id, { weight = weight, slots = slots }) +---@param item string +---@param count number +---@param slot number +---@param metadata table +---@return boolean +Inventory.AddItem = function(src, item, count, slot, metadata) + TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add', count) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata}) + return exports['qb-inventory']:AddItem(src, item, count, slot, metadata, 'community_bridge') end +---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 +---@param metadata table +---@return boolean +Inventory.RemoveItem = function(src, item, count, slot, metadata) + TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'remove', count) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata}) + return exports['qb-inventory']:RemoveItem(src, item, count, slot, 'community_bridge') +end +---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 = Framework.Shared.Items[item] if not itemData then return {} end @@ -54,26 +54,9 @@ Inventory.GetItemInfo = function(item) } end ----comment ----@param item string ----@return string -Inventory.GetImagePath = function(item) - -- check if contains.png and remove it if it does - item = Inventory.StripPNG(item) - local file = LoadResourceFile("qb-inventory", string.format("html/images/%s.png", item)) - local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item) - return imagePath or "https://avatars.githubusercontent.com/u/47620135" -end - ----comment ----@param src number ----@param item string ----@return boolean -Inventory.HasItem = function(src, item) - return qbInventory:HasItem(src, item, 1) -end - ----comment +---Returns the specified slot data as a table. +--- +---format {weight, name, metadata, slot, label, count} ---@param src number ---@param slot number ---@return table @@ -92,7 +75,61 @@ Inventory.GetItemBySlot = function(src, slot) } end ----comment +---This will open the specified stash for the src passed. +---@param src number +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return nil +Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) + TriggerClientEvent('community_bridge:client:qb-inventory:openStash', src, id, { weight = weight, slots = slots }) +end + +---This will register a stash +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return boolean +Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) + return true +end + +---This will return a boolean if the player has the item. +---@param src number +---@param item string +---@return boolean +Inventory.HasItem = function(src, item) + return qbInventory:HasItem(src, item, 1) +end + +---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 true +end + +---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("qb-inventory", string.format("html/images/%s.png", item)) + local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item) + return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end + +---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 @@ -119,25 +156,12 @@ Inventory.UpdatePlate = function(oldplate, newplate) MySQL.transaction.await(queries, values) end if GetResourceState('jg-mechanic') ~= 'started' then return true end - exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) - return true + return true, exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) end -Inventory.AddItem = function(src, item, amount, slot, metadata) - TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add', amount) - TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = amount, slot = slot, metadata = metadata}) - return exports['qb-inventory']:AddItem(src, item, amount, slot, metadata, 'community_bridge') -end - -Inventory.RemoveItem = function(src, item, amount, slot, metadata) - TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'remove', amount) - TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = amount, slot = slot, metadata = metadata}) - return exports['qb-inventory']:RemoveItem(src, item, amount, slot, 'community_bridge') -end - -local registeredShops = {} -local v1ShopData = {} - +-- This will open the specified shop for the src passed. +---@param src number +---@param shopTitle string Inventory.OpenShop = function(src, shopTitle) local newVersion = getInventoryNewVersion() if newVersion then @@ -149,6 +173,11 @@ Inventory.OpenShop = function(src, shopTitle) end end +-- This will register a shop, if it already exists it will return true. +-- @param shopTitle string +-- @param shopInventory table +-- @param shopCoords table +-- @param shopGroups table Inventory.CreateShop = function(src, shopTitle, shopInventory, shopCoords, shopGroups) if not shopTitle or not shopInventory or not shopCoords then return end if registeredShops[shopTitle] then return true end diff --git a/modules/inventory/qs-inventory/server.lua b/modules/inventory/qs-inventory/server.lua index f7e06ed..a792c4f 100644 --- a/modules/inventory/qs-inventory/server.lua +++ b/modules/inventory/qs-inventory/server.lua @@ -5,7 +5,7 @@ local quasar = exports['qs-inventory'] Inventory = Inventory or {} ----This will add the item if found and return a boolean on success +---This will add an item, and return true or false based on success ---@param src number ---@param item string ---@param count number @@ -18,7 +18,7 @@ Inventory.AddItem = function(src, item, count, slot, metadata) return quasar:AddItem(src, item, count, slot, metadata) end ----This will remove the item if found and return a boolean on success +---This will remove an item, and return true or false based on success ---@param src number ---@param item string ---@param count number @@ -30,101 +30,7 @@ Inventory.RemoveItem = function(src, item, count, slot, metadata) return quasar:RemoveItem(src, item, count, slot, metadata) end ----This will return a number of the items count in the inventory ----@param src number ----@param item string ----@param metadata table ----@return number -Inventory.GetItemCount = function(src, item, metadata) - return quasar:GetItemTotalAmount(src, item) -end - ----This will return the player inventory in a table following ox_inventory format ----@param src number ----@return table -Inventory.GetPlayerInventory = function(src) - local playerItems = quasar:GetInventory(src) - local repackedTable = {} - for _, v in pairs(playerItems) do - table.insert(repackedTable, { - name = v.name, - count = v.amount, - metadata = v.info, - slot = v.slot, - }) - end - return repackedTable -end - ----This will return a boolean of if the player has the item in the inventory ----@param src number ----@param item string ----@return boolean -Inventory.HasItem = function(src, item) - local count = quasar:GetItemTotalAmount(src, item) - if not count then return false end - return count > 0 -end - ----This will return the item data in the inventory based on the slot if not found will return nil ----@param src number ----@param slot number ----@return table | nil -Inventory.GetItemBySlot = function(src, slot) - local playerItems = quasar:GetInventory(src) - for _, item in pairs(playerItems) do - if item.slot == slot then - return { - name = item.name, - label = item.label, - weight = item.weight, - slot = slot, - count = item.amount, - metadata = item.info, - stack = item.unique or false, - description = item.description - } - end - end - return nil -end - ----This will return a boolean if the player can carry the item ----@param src number ----@param item string ----@param count number ----@return boolean -Inventory.CanCarryItem = function(src, item, count) - return quasar:CanCarryItem(src, item, count) -end - ----@param id string ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@param groups table ----@param coords table ----@return boolean -Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) - return true -end - ----@param src number ----@param id string ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@param groups table ----@param coords table ----@return nil -Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) - TriggerEvent("inventory:server:OpenInventory", "stash", id, { maxweight = weight, slots = slots }) - TriggerClientEvent("inventory:client:SetCurrentStash",src, id) -end - ----This will return the data to an item +---This will return a table with the item info, {name, label, stack, weight, description, image} ---@param item string ---@return table Inventory.GetItemInfo = function(item) @@ -142,25 +48,118 @@ Inventory.GetItemInfo = function(item) } end +---This will return the count of the item in the players inventory, if not found will return 0. +--- +---if metadata is passed it will find the matching items count. +---@param src number +---@param item string +---@param metadata table +---@return number +Inventory.GetItemCount = function(src, item, metadata) + return quasar:GetItemTotalAmount(src, item) +end +---This wil return the players inventory. +---@param src number +---@return table +Inventory.GetPlayerInventory = function(src) + local playerItems = quasar:GetInventory(src) + local repackedTable = {} + for _, v in pairs(playerItems) do + table.insert(repackedTable, { + name = v.name, + count = v.amount, + metadata = v.info, + slot = v.slot, + }) + end + return repackedTable +end + +---Returns the specified slot data as a table. +--- +---format {weight, name, metadata, slot, label, count} +---@param src number +---@param slot number +---@return table +Inventory.GetItemBySlot = function(src, slot) + local playerItems = quasar:GetInventory(src) + for _, item in pairs(playerItems) do + if item.slot == slot then + return { + name = item.name, + label = item.label, + weight = item.weight, + slot = slot, + count = item.amount, + metadata = item.info, + stack = item.unique or false, + description = item.description + } + end + end + return {} +end + +---This will set the metadata of an item in the inventory. ---@param src number ---@param item string ---@param slot number ---@param metadata table ----@return boolean +---@return nil Inventory.SetMetadata = function(src, item, slot, metadata) return quasar:SetItemMetadata(src, slot, metadata) end ----@param item string ----@return string -Inventory.GetImagePath = function(item) - item = Inventory.StripPNG(item) - local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item)) - local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item) - return imagePath or "https://avatars.githubusercontent.com/u/47620135" +---This will open the specified stash for the src passed. +---@param src number +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return nil +Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) + TriggerEvent("inventory:server:OpenInventory", "stash", id, { maxweight = weight, slots = slots }) + TriggerClientEvent("inventory:client:SetCurrentStash",src, id) end +---This will register a stash +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return boolean +Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) + --exports['qs-inventory']:RegisterStash(src, id, stashSlots, stashWeight) -- this needs to pass source to register, need to plan around this. + return true +end + +---This will return a boolean if the player has the item. +---@param src number +---@param item string +---@return boolean +Inventory.HasItem = function(src, item) + local count = quasar:GetItemTotalAmount(src, item) + if not count then return false end + return count > 0 +end + +---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 quasar:CanCarryItem(src, item, count) +end + +---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 @@ -172,6 +171,31 @@ Inventory.UpdatePlate = function(oldplate, newplate) local values = { newplate = newplate, oldplate = oldplate } MySQL.transaction.await(queries, values) if GetResourceState('jg-mechanic') ~= 'started' then return true end - exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) - return true + return true, exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) +end + +---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("qs-inventory", string.format("html/images/%s.png", item)) + local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item) + return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end + +-- This will open the specified shop for the src passed. +---@param src number +---@param shopTitle string +Inventory.OpenShop = function(src, shopTitle) + print("Currently qs shop is not bridged") +end + +-- This will register a shop, if it already exists it will return true. +-- @param shopTitle string +-- @param shopInventory table +-- @param shopCoords table +-- @param shopGroups table +Inventory.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups) + return false, print("Currently qs shop is not bridged") end \ No newline at end of file diff --git a/modules/inventory/tgiann-inventory/server.lua b/modules/inventory/tgiann-inventory/server.lua index 553d998..995d989 100644 --- a/modules/inventory/tgiann-inventory/server.lua +++ b/modules/inventory/tgiann-inventory/server.lua @@ -5,7 +5,7 @@ local tgiann = exports["tgiann-inventory"] Inventory = Inventory or {} ----This Will add the item if found and return boolean on success +---This will add an item, and return true or false based on success ---@param src number ---@param item string ---@param count number @@ -13,12 +13,11 @@ Inventory = Inventory or {} ---@param metadata table ---@return boolean Inventory.AddItem = function(src, item, count, slot, metadata) - if not tgiann:CanCarryItem(src, item, count) then return false end TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata}) return tgiann:AddItem(src, item, count, slot, metadata, false) end ----This Will remove the item if found and return boolean on success +---This will remove an item, and return true or false based on success ---@param src number ---@param item string ---@param count number @@ -30,37 +29,35 @@ Inventory.RemoveItem = function(src, item, count, slot, metadata) return tgiann:RemoveItem(src, item, count, slot, metadata) end --- +---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 = tgiann:GetItemList() + if not itemData[item] then return {} end + return { + name = itemData.name or "Missing Name", + label = itemData.label or "Missing Label", + stack = itemData.unique or "false", + weight = itemData.weight or "0", + description = itemData.description or "none", + image = itemData.image or Inventory.GetImagePath(item), + } +end + +---This will return the count of the item in the players inventory, if not found will return 0. +--- +---if metadata is passed it will find the matching items count. ---@param src number ---@param item string ---@param metadata table ----@return table -Inventory.GetItem = function(src, item, metadata) - local item = tgiann:GetItemByName(src, item, metadata) - item.count = item.amount - item.metadata = item.info - return item -end - ----This will return a boolean if the player has the item in their inventory ----@param src number ----@param item string ----@return boolean -Inventory.HasItem = function(src, item) - return tgiann:HasItem(src, item, 1) -end - ----This will return the count of the item in the players inventory ----@param src number ----@param item string ----@param metadata optional table ---@return number Inventory.GetItemCount = function(src, item, metadata) local _item = tgiann:GetItemByName(src, item, metadata) return _item.amount or 0 end ----This will return the players inventory in a table in the format ox_inventory uses +---This wil return the players inventory. ---@param src number ---@return table Inventory.GetPlayerInventory = function(src) @@ -74,27 +71,9 @@ Inventory.GetPlayerInventory = function(src) return items end ----This will return a boolean if the player can carry the item ----@param src number ----@param item string ----@param count number ----@return boolean -Inventory.CanCarryItem = function(src, item, count) - return tgiann:CanCarryItem(src, item, count) -end - ----comment ----@param id string or number ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@return boolean -Inventory.RegisterStash = function(id, label, slots, weight, owner) - return tgiann:CreateCustomStashWithItem(id, {}) -end - ----This will return the item data in the slot the item is found +---Returns the specified slot data as a table. +--- +---format {weight, name, metadata, slot, label, count} ---@param src number ---@param slot number ---@return table @@ -113,24 +92,7 @@ Inventory.GetItemBySlot = function(src, slot) } end ----This will return a table of the item data including the image (very useful for menus etc) ----@param item string ----@return table -Inventory.GetItemInfo = function(item) - local itemData = tgiann:GetItemList() - if not itemData[item] then return {} end - return { - name = itemData.name or "Missing Name", - label = itemData.label or "Missing Label", - stack = itemData.unique or "false", - weight = itemData.weight or "0", - description = itemData.description or "none", - image = itemData.image or Inventory.GetImagePath(item), - } -end - ----This will update the item metadata for an item with the provided slot and metadata, its best to get the item first ----And then set the metadata +---This will set the metadata of an item in the inventory. ---@param src number ---@param item string ---@param slot number @@ -140,18 +102,51 @@ Inventory.SetMetadata = function(src, item, slot, metadata) tgiann:UpdateItemMetadata(src, item, slot, metadata) end ----This will return the image path for the item ----@param item string ----@return string -Inventory.GetImagePath = function(item) - item = Inventory.StripPNG(item) - local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item)) - local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item)) - local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item) - return imagePath or "https://avatars.githubusercontent.com/u/47620135" +---This will open the specified stash for the src passed. +---@param src number +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return nil +Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) + print("Currently not bridged for stashes") end ----This will update the plate to a vehicle in the inventory +---This will register a stash +---@param id number||string +---@param label string +---@param slots number +---@param weight number +---@param owner string +---@param groups table +---@param coords table +---@return boolean +Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) + return false, print("Currently not bridged for stashes") +end + +---This will return a boolean if the player has the item. +---@param src number +---@param item string +---@return boolean +Inventory.HasItem = function(src, item) + return tgiann:HasItem(src, item, 1) +end + +---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 tgiann:CanCarryItem(src, item, count) +end + +---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 @@ -163,6 +158,50 @@ Inventory.UpdatePlate = function(oldplate, newplate) local values = { newplate = newplate, oldplate = oldplate } MySQL.transaction.await(queries, values) if GetResourceState('jg-mechanic') ~= 'started' then return true end - exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) - return true + return true, exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) +end + +---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 pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item)) + local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item)) + local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item) + return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end + + +-- This will open the specified shop for the src passed. +---@param src number +---@param shopTitle string +Inventory.OpenShop = function(src, shopTitle) + print("Currently tgiann-inventory is not bridged for shops") +end + +-- This will register a shop, if it already exists it will return true. +-- @param shopTitle string +-- @param shopInventory table +-- @param shopCoords table +-- @param shopGroups table +Inventory.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups) + return false, print("Currently tgiann-inventory is not bridged for shops") +end + +---UNUSED: +---This will return generic item data from the specified inventory, with the items total count. +--- +---format without metadata { count, stack, name, weight, label } +--- +---fortmat with metadata { count, stack, name, weight, label, metadata } +---@param src number +---@param item string +---@param metadata table +---@return table +Inventory.GetItem = function(src, item, metadata) + local item = tgiann:GetItemByName(src, item, metadata) + item.count = item.amount + item.metadata = item.info + return item end \ No newline at end of file From 91d69a6742d249ad8ef1ea4e4216bdeaf7d1238b Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Fri, 9 May 2025 06:21:18 -0400 Subject: [PATCH 09/38] wip --- modules/inventory/origen_inventory/client.lua | 6 +++++- modules/inventory/tgiann-inventory/client.lua | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/inventory/origen_inventory/client.lua b/modules/inventory/origen_inventory/client.lua index 8f70ff1..88f1a59 100644 --- a/modules/inventory/origen_inventory/client.lua +++ b/modules/inventory/origen_inventory/client.lua @@ -64,4 +64,8 @@ Inventory.GetPlayerInventory = function() }) end return repack -end \ No newline at end of file +end + +Inventory.OpenStash = function(id) + origin:openInventory('stash', id, { label = id, weight = 400000, slots = 100, }) +end diff --git a/modules/inventory/tgiann-inventory/client.lua b/modules/inventory/tgiann-inventory/client.lua index 75c055e..a658878 100644 --- a/modules/inventory/tgiann-inventory/client.lua +++ b/modules/inventory/tgiann-inventory/client.lua @@ -69,5 +69,5 @@ end ---@param id any ---@return nil Inventory.OpenStash = function(id) - -- open stash export... not sure what it is yet. + tgiann:OpenInventory('stash', id, { maxweight = 400000, slots = 100 }) end \ No newline at end of file From 38d0d5527ae654a5a0bea77a1afbfa38140e2f60 Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Fri, 9 May 2025 19:06:50 -0500 Subject: [PATCH 10/38] New features and cleanup Added Networked Markers Added Anim module Added framework default file for things that are native to game related to player Started on a batch network event trigger to allow for single event call for multiple events Updated params notation for ids Removed prints from client_entity + actions + ext --- init.lua | 51 ++--- lib/anim/client/client.lua | 161 ++++++++++++++ lib/batch/shared/events.lua | 65 ++++++ lib/entities/client/client_entity.lua | 10 +- lib/entities/client/client_entity_actions.lua | 2 - .../client/client_entity_actions_ext.lua | 9 +- lib/init.lua | 5 +- lib/markers/client/markers.lua | 207 ++++++++++++------ lib/markers/server/server.lua | 42 +++- lib/utility/shared/ids.lua | 6 +- modules/framework/_default/server.lua | 2 + modules/framework/es_extended/client.lua | 1 - modules/framework/es_extended/server.lua | 13 +- modules/framework/qb-core/client.lua | 2 +- modules/framework/qb-core/server.lua | 13 +- modules/framework/qbx_core/client.lua | 2 +- modules/framework/qbx_core/server.lua | 2 +- 17 files changed, 463 insertions(+), 130 deletions(-) create mode 100644 lib/anim/client/client.lua create mode 100644 lib/batch/shared/events.lua create mode 100644 modules/framework/_default/server.lua diff --git a/init.lua b/init.lua index 533efb5..1c6163b 100644 --- a/init.lua +++ b/init.lua @@ -8,7 +8,7 @@ function Bridge.RegisterModule(moduleName, moduleTable) return end - local wrappedModule = {} + local wrappedModule = Bridge[moduleName] or {} if type(moduleTable) == 'function' then Bridge[moduleName] = wrappedModule exports(moduleName, moduleTable) @@ -57,22 +57,28 @@ Bridge.RegisterModule("Shops", Shops) Bridge.RegisterModule("Housing", Housing) --lib -Bridge.RegisterModule("Tables", cLib.Tables) -Bridge.RegisterModule("Math", cLib.Math) -Bridge.RegisterModule("Prints", cLib.Prints) -Bridge.RegisterModule("Callback", cLib.Callback) +-- Bridge.RegisterModule("Tables", cLib.Tables) +-- Bridge.RegisterModule("Math", cLib.Math) +-- Bridge.RegisterModule("Prints", cLib.Prints) +-- Bridge.RegisterModule("Callback", cLib.Callback) ---new +-- --new Bridge.RegisterModule("Require", Require) -Bridge.RegisterModule("Ids", cLib.Ids) -Bridge.RegisterModule("ReboundEntities", cLib.ReboundEntities) -Bridge.RegisterModule("LA", cLib.LA) -Bridge.RegisterModule("Perlin", cLib.Perlin) -Bridge.RegisterModule("Actions", cLib.Actions) -Bridge.RegisterModule("Cache", cLib.Cache) -Bridge.RegisterModule("Skills", Skills) +-- Bridge.RegisterModule("Ids", cLib.Ids) +-- Bridge.RegisterModule("ReboundEntities", cLib.ReboundEntities) +-- Bridge.RegisterModule("LA", cLib.LA) +-- Bridge.RegisterModule("Perlin", cLib.Perlin) +-- Bridge.RegisterModule("Actions", cLib.Actions) +-- Bridge.RegisterModule("Cache", cLib.Cache) +-- Bridge.RegisterModule("Skills", Skills) +for k, v in pairs(cLib) do + if v then + Bridge.RegisterModule(k, v) + end +end + exports('Bridge', function() return Bridge end) @@ -81,13 +87,6 @@ end) -- ▄█▀ █▄▄ █▀▄ ▀▄▀ █▄▄ █▀▄ if not IsDuplicityVersion() then goto client end -Bridge.RegisterModule("SQL", cLib.SQL) -Bridge.RegisterModule("Logs", cLib.Logs) -Bridge.RegisterModule("ItemsBuilder", cLib.ItemsBuilder) -Bridge.RegisterModule("LootTables", cLib.LootTables) -Bridge.RegisterModule("Version", Version) -Bridge.RegisterModule("ServerEntity", cLib.ServerEntity) - -- ▄▀▀ █ █ ██▀ █▄ █ ▀█▀ -- ▀▄▄ █▄▄ █ █▄▄ █ ▀█ █ @@ -106,18 +105,6 @@ Bridge.RegisterModule("Menu", Menu) Bridge.RegisterModule("Dialogue", Dialogue) Bridge.RegisterModule("Accessibility", Accessibility) -- new -Bridge.RegisterModule("Utility", cLib.Utility) -Bridge.RegisterModule("Placeable", cLib.Placeable)--new -Bridge.RegisterModule("Gizmo", cLib.Gizmo) -Bridge.RegisterModule("Scaleform", cLib.Scaleform) -Bridge.RegisterModule("Raycast", cLib.Raycast) -Bridge.RegisterModule("PlaceableObject", cLib.PlaceableObject) -Bridge.RegisterModule("Point", cLib.Point) -Bridge.RegisterModule("Object", cLib.Object) -Bridge.RegisterModule("Particle", cLib.Particle) -Bridge.RegisterModule("ClientEntity", cLib.ClientEntity) -Bridge.RegisterModule("ClientEntityActions", cLib.ClientEntityActions) - -- Fill the bridge tables with player data. function FillBridgeTables() PlayerLoaded = true diff --git a/lib/anim/client/client.lua b/lib/anim/client/client.lua new file mode 100644 index 0000000..b809317 --- /dev/null +++ b/lib/anim/client/client.lua @@ -0,0 +1,161 @@ +Anim = Anim or {} +Ids = Ids or Require("lib/utility/shared/ids.lua") +Anim.Active = Anim.Active or {} +Anim.isUpdateLoopRunning = Anim.isUpdateLoopRunning or false + +--- This will request the animation dictionary. +--- @param animDict string +--- @return boolean +function Anim.RequestDict(animDict) + if not animDict or type(animDict) ~= "string" then + return false + end + + if HasAnimDictLoaded(animDict) then + return true + end + + RequestAnimDict(animDict) + local timeout = GetGameTimer() + 2000 + while not HasAnimDictLoaded(animDict) and GetGameTimer() < timeout do + Wait(50) + end + + return HasAnimDictLoaded(animDict) +end + +--- This will start the animation update loop. +--- @return void +function Anim.Start() + if Anim.isUpdateLoopRunning then return end + Anim.isUpdateLoopRunning = true + CreateThread(function() + while Anim.isUpdateLoopRunning do + local idsToProcess = {} + for idKey, _ in pairs(Anim.Active) do + table.insert(idsToProcess, idKey) + end + + if #idsToProcess == 0 then + Wait(750) + else + for _, id in ipairs(idsToProcess) do + local animData = Anim.Active[id] + + if animData then + local entity = animData.entity + local onComplete = animData.onComplete + + if not DoesEntityExist(entity) then + if onComplete then onComplete(false, "despawned") end + Anim.Active[id] = nil + elseif animData.status == "pending_task" then + TaskPlayAnim(entity, animData.animDict, animData.animName, animData.blendIn, animData.blendOut, animData.duration, animData.flag, animData.playbackRate, false, false, false) + animData.startTime = GetGameTimer() + animData.animEndTime = animData.duration > 0 and (animData.startTime + animData.duration) or -1 + animData.status = "playing" + + elseif animData.status == "playing" then + local animationCompletedNaturally = false + + if animData.duration == -1 then + if not IsEntityPlayingAnim(entity, animData.animDict, animData.animName, 3) and GetEntityAnimCurrentTime(entity, animData.animDict, animData.animName) > 0.8 then + animationCompletedNaturally = true + end + elseif animData.animEndTime ~= -1 and GetGameTimer() >= animData.animEndTime then + animationCompletedNaturally = true + end + + if animationCompletedNaturally then + if onComplete then onComplete(true, "completed") end + Anim.Active[id] = nil + end + end + end + end + Wait(100) + end + end + end) +end + +--- This will play an animation on the specified ped. +--- @param id string | nil +--- @param entity number +--- @param animDict string +--- @param animName string +--- @param blendIn number | nil +--- @param blendOut number | nil +--- @param duration number | nil +--- @param flag number | nil +--- @param playbackRate number | nil +--- @param onComplete function | nil +--- @return string | nil +function Anim.Play(id, entity, animDict, animName, blendIn, blendOut, duration, flag, playbackRate, onComplete) + local newId = id or Ids.CreateUniqueId(Anim.Active) + if Anim.Active[newId] then + if onComplete then + onComplete(false, "id_in_use") + end + return newId + end + + if not entity or not DoesEntityExist(entity) or not IsEntityAPed(entity) then + if onComplete then + onComplete(false, "invalid_entity") + end + return nil + end + + if not Anim.RequestDict(animDict) then + if onComplete then + onComplete(false, "dict_load_failed") + end + return nil + end + + Anim.Active[newId] = { + entity = entity, + animDict = animDict, + animName = animName, + blendIn = blendIn or 8.0, + blendOut = blendOut or -8.0, + duration = duration or -1, + flag = flag or 1, + playbackRate = playbackRate or 0.0, + onComplete = onComplete, + status = "pending_task", + startTime = 0, + animEndTime = 0 + } + + Anim.Start() + return newId +end + +function Anim.Stop(id) + if not id or not Anim.Active or not Anim.Active[id] then + return false + end + + local animData = Anim.Active[id] + + if animData.entity and DoesEntityExist(animData.entity) and IsEntityAPed(animData.entity) then + if animData.status == "playing" or animData.status == "pending_task" then + StopAnimTask(animData.entity, animData.animDict, animData.animName, 1.0) + end + end + + if animData.onComplete then + animData.onComplete(false, "stopped_by_id") + end + + Anim.Active[id] = nil + local anyLeft = Anim.Active and next(Anim.Active) ~= nil + if not anyLeft then + Anim.isUpdateLoopRunning = false + end + return true +end + +return Anim \ No newline at end of file diff --git a/lib/batch/shared/events.lua b/lib/batch/shared/events.lua new file mode 100644 index 0000000..f88fb86 --- /dev/null +++ b/lib/batch/shared/events.lua @@ -0,0 +1,65 @@ +Batch = Batch or {} +Batch.Event = Batch.Event or {} +Batch.Event.Queued = Batch.Event.Queued or {} +Batch.Event.IsQueued = Batch.Event.IsQueued or false + +local SERVER = IsDuplicityVersion() + +-- could do a callback from client to server back to client with a time stamp. Use that timestamp to generate some random string/number and use that fo +-- this event name. Would help by masking from exploits. Thinking about making a module out of it + +--- This is used to batch single events together to reduce network strain +--- +if SERVER then + function Batch.Event.Queue(src, event, ...) + if src == -1 then + src = GetPlayers() + for k, v in pairs(src) do + local strSrc = tostring(v) + Batch.Event.Queued[strSrc] = Batch.Event.Queued[strSrc] or {} + table.insert(Batch.Event.Queued[strSrc], { + src = v, + event = event, + args = {...} + }) + end + else + local strSrc = tostring(src) + Batch.Event.Queued[strSrc] = Batch.Event.Queued[strSrc] or {} + table.insert(Batch.Event.Queued[strSrc], { + src = src, + event = event, + args = {...} + }) + end + + if Batch.Event.IsQueued then return end + Batch.Event.IsQueued = true + SetTimeout(100, function() + for k, v in pairs(Batch.Event.Queued) do + TriggerClientEvent('community_bridge:client:BatchEvents', v.src, v) + end + Batch.Event.IsQueued = false + Batch.Event.Queued = {} + end) + end + return Batch +else + + Batch.Event.Fire = function(array) + local playerSrc = PlayerId() + for k, v in pairs(array) do + if v.src == playerSrc then + local event = v.event + local args = v.args + TriggerEvent(event, table.unpack(args)) + end + end + end + + RegisterNetEvent('community_bridge:client:BatchEvents', function(array) + Batch.Event.Fire(array) + end) + + return Batch +end \ No newline at end of file diff --git a/lib/entities/client/client_entity.lua b/lib/entities/client/client_entity.lua index 59af37b..29c8e82 100644 --- a/lib/entities/client/client_entity.lua +++ b/lib/entities/client/client_entity.lua @@ -35,10 +35,11 @@ local function SpawnEntity(entityData) print(string.format("[ClientEntity] Unknown entity type '%s' for entity %s", entityData.entityType, entityData.id)) end if entity then + -- print(string.format("[ClientEntity] Spawned %s entity %s (GameID: %s)", entityData.entityType, entityData.id, entity)) entityData.spawned = entity SetModelAsNoLongerNeeded(model) SetEntityAsMissionEntity(entity, true, true) -- Keep entity from being deleted by game engine - FreezeEntityPosition(entity, entityData.freeze or false) -- Optional freeze based on meta + FreezeEntityPosition(entity, true) -- Optional freeze based on meta if entityData.OnSpawn and type(entityData.OnSpawn) == 'function' then entityData.OnSpawn(entityData) end @@ -75,7 +76,7 @@ function ClientEntity.Register(entityData) -- print(string.format("[ClientEntity] Registering %s entity %s", entityData.entityType, entityData.id)) -- Use Point system for proximity checks - print(string.format("[ClientEntity] Registering entity %s at %s", entityData.id, json.encode(entityData))) + -- print(string.format("[ClientEntity] Registering entity %s at %s", entityData.id, json.encode(entityData))) Point.Register(entityData.id, entityData.coords, entityData.spawnDistance or 50.0, entityData, SpawnEntity, RemoveEntity, function() end) end @@ -96,13 +97,13 @@ end -- @param data table The data fields to update. function ClientEntity.Update(id, data) local entityData = Entities[id] - print(string.format("[ClientEntity] Updating entity %s", id)) + -- print(string.format("[ClientEntity] Updating entity %s", id)) if not entityData then return end local needsPointUpdate = false for key, value in pairs(data) do if key == 'coords' and #(entityData.coords - value) > 0.1 then - print(string.format("[ClientEntity] Updating coords for entity %s", id)) + -- print(string.format("[ClientEntity] Updating coords for entity %s", id)) needsPointUpdate = true end if key == 'spawnDistance' and entityData.spawnDistance ~= value then @@ -176,7 +177,6 @@ end) -- New handler for entity actions RegisterNetEvent("community_bridge:client:TriggerEntityAction", function(entityId, actionName, ...) local entityData = Entities[entityId] - print("here", json.encode(entityData)) -- Check if entity exists locally (it doesn't need to be spawned to queue actions) if entityData then if actionName == "Stop" then diff --git a/lib/entities/client/client_entity_actions.lua b/lib/entities/client/client_entity_actions.lua index b8ffd67..31b66b3 100644 --- a/lib/entities/client/client_entity_actions.lua +++ b/lib/entities/client/client_entity_actions.lua @@ -12,7 +12,6 @@ ClientEntityActions.RegisteredActions = {} -- New: Registry for action implemen -- @param entityId string|number The ID of the entity. function ClientEntityActions.ProcessNextAction(entityId) if ClientEntityActions.IsActionRunning [entityId] then return end -- Already running something - print(string.format("[ClientEntityActions] Processing next action for entity %s", entityId)) local queue = ClientEntityActions.ActionQueue[entityId] if not queue or #queue == 0 then return end -- Queue is empty @@ -27,7 +26,6 @@ function ClientEntityActions.ProcessNextAction(entityId) -- Look up the action in the registry local actionFunc = ClientEntityActions.RegisteredActions [nextAction.name] - print(string.format("[ClientEntityActions] Action '%s' dequeued for entity %s", nextAction.name, entityId)) if actionFunc then -- print(string.format("[ClientEntityActions] Starting action '%s' for entity %s", nextAction.name, entityId)) ClientEntityActions.IsActionRunning [entityId] = true diff --git a/lib/entities/client/client_entity_actions_ext.lua b/lib/entities/client/client_entity_actions_ext.lua index 73dc7b5..8c03bad 100644 --- a/lib/entities/client/client_entity_actions_ext.lua +++ b/lib/entities/client/client_entity_actions_ext.lua @@ -4,7 +4,6 @@ LA = LA or Require("lib/utility/shared/la.lua") --- Internal implementation for walking. Registered via RegisterAction. function DefaultActions.WalkTo(entityData, coords, speed, timeout) - print("[ClientEntityActions] WalkTo action called", coords, speed, timeout) local entity = entityData.spawned local entityId = entityData.id -- Store ID locally for safety in thread @@ -179,9 +178,7 @@ function DefaultActions.AttachProp(entityData, propModel, boneName, offsetPos, o end local modelHash = Utility.GetEntityHashFromModel(propModel) - print(modelHash, propModel) if not Utility.LoadModel(modelHash) then - print(string.format("[ClientEntityActions] Failed to load prop model '%s' for entity %s", propModel, entityId)) ClientEntityActions.IsActionRunning[entityId] = false ClientEntityActions.ProcessNextAction(entityId) return @@ -196,7 +193,6 @@ function DefaultActions.AttachProp(entityData, propModel, boneName, offsetPos, o if boneIndex == -1 then boneIndex = 0 end -- Default to root if bone not found or not ped offsetPos = offsetPos or vector3(0.0, 0.0, 0.0) offsetRot = offsetRot or vector3(0.0, 0.0, 0.0) - print(string.format("[ClientEntityActions] Attaching prop '%s' to entity %s at bone %d", propModel, entityId, boneIndex)) AttachEntityToEntity(prop, entity, boneIndex, offsetPos.x, offsetPos.y, offsetPos.z, offsetRot.x, offsetRot.y, offsetRot.z, false, useSoftPinning or false, collision or false, isPed or false, vertexIndex or 2, fixedRot == nil and true or fixedRot) entityData.props = entityData.props or {} -- Ensure props table exists table.insert(entityData.props, prop) -- Store the prop handle in the entity data @@ -351,6 +347,11 @@ function DefaultActions.Circle(entityData, radius, speed) -- ClientEntityActions.ProcessNextAction(entityId) -- Try next action if this one failed immediately end +function DefaultActions.Collisions(entityData, enable, keepPhysics) + local entity = entityData.spawned + SetEntityCollision(entity, enable, keepPhysics) +end + for name, func in pairs(DefaultActions) do ClientEntityActions.RegisterAction(name, func) end diff --git a/lib/init.lua b/lib/init.lua index 3d3df81..b877f42 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -58,7 +58,7 @@ cLib.ItemsBuilder = ItemsBuilder or Require("lib/generators/server/ItemsBuilder. cLib.LootTables = LootTables or Require("lib/generators/server/lootTables.lua") cLib.Cache = Cache or Require("lib/cache/shared/cache.lua") cLib.ServerEntity = ServerEntity or Require("lib/entities/server/server_entity.lua") - +cLib.Marker = Marker or Require("lib/markers/server/server.lua") if IsDuplicityVersion() then return cLib end ::client:: @@ -74,4 +74,7 @@ cLib.Cache = Cache or Require("lib/cache/client/cache.lua") cLib.ClientEntity = ClientEntity or Require("lib/entities/client/client_entity.lua") cLib.ClientEntityActions = ClientEntityActions or Require("lib/entities/client/client_entity_actions.lua") cLib.ClientStateBag = ClientStateBag or Require("lib/statebags/client/client.lua") +cLib.Marker = Marker or Require("lib/markers/client/markers.lua") +cLib.Anim = Anim or Require("lib/anim/client/client.lua") + return cLib diff --git a/lib/markers/client/markers.lua b/lib/markers/client/markers.lua index c83dc60..fe42f79 100644 --- a/lib/markers/client/markers.lua +++ b/lib/markers/client/markers.lua @@ -1,8 +1,10 @@ -Marker = { - -} -local Created = setmetatable({}, { __mode = "k" }) -local id = Require("lib/utility/shared/ids") +---@diagnostic disable: duplicate-set-field +Marker = {} +local Created = setmetatable({}, { __mode = "k" }) --what is mode? +local id = Ids or Require("lib/utility/shared/ids.lua") +local point = Require("lib/points/client/points.lua") +local loopRunning = false +local Drawing = {} --- This will validate the marker data. --- @param data table{position: vector3, offset: vector3, rotation: vector3, size: vector3, color: vector3, alpha: number, bobUpAndDown: boolean, marker: number, interaction: function} @@ -23,91 +25,150 @@ local function validateMarkerData(data) return true end -AddEventHandler("community_bridge:client:marker", function(data) - if not validateMarkerData(data) then return end - if source == "" then return end - Marker.DrawMarker(data) -end) - --- This will create a marker. --- @param data table{position: vector3, offset: vector3, rotation: vector3, size: vector3, color: vector3, alpha: number, bobUpAndDown: boolean, marker: number, interaction: function} ----@return number -function Marker.DrawMarker(data) +--- @return string|nil +function Marker.Create(data) local _id = data.id or id.Random() - local position = data.position or vector3(0.0, 0.0, 0.0) - local offset = data.offset or vector3(0.0, 0.0, 0.0) - local marker = data.marker or 1 - local pos = vector3(position.x + offset.x, position.y + offset.y, position.z + offset.z) - local rotation = data.rotation or vector3(0, 0, 0) - local size = data.size or vector3(1.0, 1.0, 1.0) - local color = data.color or vector3(0, 255, 0) - local alpha = data.alpha or 255 - local bobUpAndDown = data.bobUpAndDown - local interaction = data.interaction or false - Created[_id] = { - position = pos, - rotation = rotation, - size = size, - color = color, - alpha = alpha, - bobUpAndDown = - bobUpAndDown, - marker = marker, - offset = offset, - interaction = interaction, + if not validateMarkerData(data) then return end + local basePosition = data.position or vector3(0.0, 0.0, 0.0) + local baseOffset = data.offset or vector3(0.0, 0.0, 0.0) + + local data = { id = _id, + position = vector3(basePosition.x + baseOffset.x, basePosition.y + baseOffset.y, basePosition.z + baseOffset.z), + offset = baseOffset, + marker = data.marker or 1, + rotation = data.rotation or vector3(0, 0, 0), + size = data.size or vector3(1.0, 1.0, 1.0), + color = data.color or vector3(0, 255, 0), + alpha = data.alpha or 255, + bobUpAndDown = data.bobUpAndDown, + -- interaction = data.interaction or false, -- Uncomment if you re-implement interaction logic + rotate = data.rotate, + textureDict = data.textureDict, + textureName = data.textureName, + drawOnEnts = data.drawOnEnts, } + Created[_id] = data + + point.Register( + _id, data.position, data.drawDistance or 50.0, data, + function(_) + if not Created[_id] then return point.Remove(_id) end + Drawing[_id] = Created[_id] + Marker.Run(Drawing[_id]) + end, + function(markerData) + Drawing[_id] = nil + end + ) return _id end -function Marker.RemoveMarker(id) - if Created[id] then +--- This will remove a marker. +--- @param id string +--- @return boolean +function Marker.Remove(id) + if not Created[id] then return false end + point.Remove(id) + Drawing[id] = nil + Created[id] = nil + return true +end + +--- This will remove all markers. +--- @param id string +function Marker.RemoveAll() + for id, _ in pairs(Created) do + point.Remove(id) Created[id] = nil - return true - end - return false + end end -function Marker.Draw() - while true do - Wait(0) - if not next(Created) then - Wait(1000) -- Reduce CPU usage when no markers are present - goto continue - end - - for id, _ in pairs(Created) do - if Created[id] then - local data = Created[id] - if #(data.position - GetEntityCoords(PlayerPedId())) > 100.0 then +-- This will loop through all marker(points) in range and draw them. +-- @param data table{marker: number, position: vector3, rotation: vector3, size: vector3, color: vector3, alpha: number, bobUpAndDown: boolean, faceCamera: boolean, rotate: boolean, textureDict: string, textureName: string, drawOnEnts: boolean} +-- @return nil +function Marker.Run(data) + if loopRunning then return end + loopRunning = true + CreateThread(function() + while loopRunning do + for drawingId, drawingData in pairs(Drawing) do + if not Created[drawingId] then + Drawing[drawingId] = nil goto continue - else - DrawMarker( - data.marker, - data.position.x, data.position.y, data.position.z, - 0.0, 0.0, 0.0, - data.rotation.x, data.rotation.y, data.rotation.z, - data.size.x, data.size.y, data.size.z, - data.color.x, data.color.y, data.color.z, data.alpha, - data.bobUpAndDown, false, false - ) - if data.interaction then - local playerCoords = GetEntityCoords(PlayerPedId()) - local distance = #(data.position - playerCoords) - if distance < 2.0 then - if IsControlJustReleased(0, 38) then -- E key - data.interaction(data.id) - end - end - end end + DrawMarker( + data.marker, + data.position.x, data.position.y, data.position.z, + 0.0, 0.0, 0.0, + data.rotation.x, data.rotation.y, data.rotation.z, + data.size.x, data.size.y, data.size.z, + data.color.x, data.color.y, data.color.z, data.alpha, + data.bobUpAndDown, data.faceCamera, false, + data.rotate, data.textureDict, data.textureName, data.drawOnEnts + ) + ::continue:: end + Wait(3) end - ::continue:: - end + end) end -Marker.Draw() -- Start the marker drawing loop +RegisterNetEvent("community_bridge:Client:Marker", function(data) + print("community_bridge:Client:Marker") + Marker.Create(data) +end) + +RegisterNetEvent("community_bridge:Client:MarkerRemove", function(id) + Marker.Remove(id) +end) + +-- local loopRunning = false +-- function Marker.Draw() +-- if loopRunning then return end +-- loopRunning = true +-- while loopRunning do +-- Wait(0) +-- if not next(Created) then +-- Wait(1000) -- Reduce CPU usage when no markers are present +-- goto continue +-- end + +-- for id, _ in pairs(Created) do +-- if Created[id] then +-- local data = Created[id] +-- if #(data.position - GetEntityCoords(PlayerPedId())) > 100.0 then +-- goto continue +-- else +-- DrawMarker( +-- data.marker, +-- data.position.x, data.position.y, data.position.z, +-- 0.0, 0.0, 0.0, +-- data.rotation.x, data.rotation.y, data.rotation.z, +-- data.size.x, data.size.y, data.size.z, +-- data.color.x, data.color.y, data.color.z, data.alpha, +-- data.bobUpAndDown, data.faceCamera, false, +-- data.rotate, data.textureDict, data.textureName, data.drawOnEnts +-- ) +-- -- if data.interaction then +-- -- local playerCoords = GetEntityCoords(PlayerPedId()) +-- -- local distance = #(data.position - playerCoords) +-- -- if distance < 2.0 then +-- -- if IsControlJustReleased(0, 38) then -- E key +-- -- data.interaction(data.id) +-- -- end +-- -- end +-- -- end +-- end +-- end +-- end +-- ::continue:: +-- end +-- end + +-- Marker.Draw() -- Start the marker drawing loop exports("Marker", Marker) diff --git a/lib/markers/server/server.lua b/lib/markers/server/server.lua index c009c7d..5a31e9f 100644 --- a/lib/markers/server/server.lua +++ b/lib/markers/server/server.lua @@ -1,4 +1,9 @@ -local function RegisterNewMarker(data) +---@diagnostic disable: duplicate-set-field +local id = Ids or Require("lib/utility/shared/ids.lua") +Marker = {} +local Created = {} + +function Marker.Create(data) if not data.position or not data.position.x or not data.position.y or not data.position.z then print("Invalid marker position. Must be a vector3 with x, y, and z coordinates.") return @@ -17,8 +22,37 @@ local function RegisterNewMarker(data) return end - TriggerClientEvent("community_bridge:client:marker", source, data) + local _id = id.CreateUniqueId(Created) + local data = { + id = _id, + position = data.position, + offset = data.offset or vector3(0.0, 0.0, 0.0), + marker = data.marker or 1, + rotation = data.rotation or vector3(0, 0, 0), + size = data.size or vector3(1.0, 1.0, 1.0), + color = data.color or vector3(0, 255, 0), + alpha = data.alpha or 255, + bobUpAndDown = data.bobUpAndDown, + -- interaction = data.interaction or false, -- Uncomment if you re-implement interaction logic + rotate = data.rotate, + textureDict = data.textureDict, + textureName = data.textureName, + drawOnEnts = data.drawOnEnts, + } + Created[_id] = data + TriggerClientEvent("community_bridge:Client:Marker", -1, data) + return _id end -RegisterNetEvent("community_bridge:server:createMarker", RegisterNewMarker) -exports("RegisterNewMarker", RegisterNewMarker) +function Marker.Remove(id) + if not Created[id] then return end + TriggerClientEvent("community_bridge:Client:MarkerRemove", -1, id) + Created[id] = nil +end + +RegisterNetEvent("community_bridge:Server:MarkerRemove", function(id) + Marker.Remove(id) +end) + +exports("Marker", Marker) +return Marker diff --git a/lib/utility/shared/ids.lua b/lib/utility/shared/ids.lua index f0ae840..e7cdba8 100644 --- a/lib/utility/shared/ids.lua +++ b/lib/utility/shared/ids.lua @@ -2,9 +2,9 @@ Ids = Ids or {} ---This will generate a unique id. ----@param tbl table ----@param len number ----@param pattern string +---@param tbl table | nil +---@param len number | nil +---@param pattern string | nil ---@return string Ids.CreateUniqueId = function(tbl, len, pattern) -- both optional tbl = tbl or {} -- table to check uniqueness. Ids to check against must be the key to the tables value diff --git a/modules/framework/_default/server.lua b/modules/framework/_default/server.lua new file mode 100644 index 0000000..4fff4d4 --- /dev/null +++ b/modules/framework/_default/server.lua @@ -0,0 +1,2 @@ +Framework = Framework or {} + diff --git a/modules/framework/es_extended/client.lua b/modules/framework/es_extended/client.lua index ea14754..99b070a 100644 --- a/modules/framework/es_extended/client.lua +++ b/modules/framework/es_extended/client.lua @@ -3,7 +3,6 @@ if GetResourceState('es_extended') ~= 'started' then return end ESX = exports["es_extended"]:getSharedObject() -Framework = {} Framework.GetFrameworkName = function() return 'es_extended' diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index 4a1cfea..cb85e2f 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -3,7 +3,7 @@ if GetResourceState('es_extended') ~= 'started' then return end ESX = exports["es_extended"]:getSharedObject() -Framework = {} +Framework = Framework or {} Framework.GetFrameworkName = function() return 'es_extended' @@ -140,6 +140,17 @@ Framework.GetIsPlayerDead = function(src) return xPlayer.get("is_dead") or false end +Framework.RevivePlayer = function(src) + src = tonumber(src) + + if not src then return false end + TriggerEvent('esx_ambulancejob:revive', src) -- FIXME: deprecate + -- TriggerEvent('txAdmin:events:playerHealed', { + -- target = src, + -- }) + return true +end + -- Framework.AddThirst(src, value) -- Adds the specified value from the player's thirst level. Framework.AddThirst = function(src, value) diff --git a/modules/framework/qb-core/client.lua b/modules/framework/qb-core/client.lua index f1ab2e9..9d70865 100644 --- a/modules/framework/qb-core/client.lua +++ b/modules/framework/qb-core/client.lua @@ -4,7 +4,7 @@ if GetResourceState('qbx_core') == 'started' then return end QBCore = exports['qb-core']:GetCoreObject() -Framework = {} +Framework = Framework or {} ---This will get the name of the framework being used (if a supported framework). ---@return string diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index fa9028f..d3824c8 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -4,7 +4,7 @@ if GetResourceState('qbx_core') == 'started' then return end QBCore = exports['qb-core']:GetCoreObject() -Framework = {} +Framework = Framework or {} Framework.Shared = QBCore.Shared Framework.GetFrameworkName = function() return 'qb-core' @@ -265,6 +265,17 @@ Framework.GetIsPlayerDead = function(src) return playerData.metadata.isdead or playerData.metadata.inlaststand or false end +Framework.RevivePlayer = function(src) + src = tonumber(src) + + if not src then return false end + TriggerClientEvent('hospital:client:Revive', src) -- FIXME: deprecate + -- TriggerEvent('txAdmin:events:playerHealed', { + -- target = src, + -- }) + return true +end + ---This will get the thirst of a player ---@param src any diff --git a/modules/framework/qbx_core/client.lua b/modules/framework/qbx_core/client.lua index da1b25c..e1d0f51 100644 --- a/modules/framework/qbx_core/client.lua +++ b/modules/framework/qbx_core/client.lua @@ -3,7 +3,7 @@ if GetResourceState('qbx_core') ~= 'started' then return end QBox = exports.qbx_core -Framework = {} +Framework = Framework or {} Framework.GetFrameworkName = function() return 'qbx_core' diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index aa614a6..7c36db3 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -3,7 +3,7 @@ if GetResourceState('qbx_core') ~= 'started' then return end local QBox = exports.qbx_core -Framework = {} +Framework = Framework or {} ---Returns the name of the framework being used (if a supported framework). ---@return string From 6f700ed7cf525fc434108f8f8c84540c9c522f68 Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Fri, 9 May 2025 19:07:17 -0500 Subject: [PATCH 11/38] Update client.lua --- modules/framework/es_extended/client.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/framework/es_extended/client.lua b/modules/framework/es_extended/client.lua index 99b070a..a970606 100644 --- a/modules/framework/es_extended/client.lua +++ b/modules/framework/es_extended/client.lua @@ -3,6 +3,7 @@ if GetResourceState('es_extended') ~= 'started' then return end ESX = exports["es_extended"]:getSharedObject() +Framework = Framework or {} Framework.GetFrameworkName = function() return 'es_extended' From 69edf6f6ab4a4bf457541acae5ebafa39147ee1c Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Fri, 9 May 2025 20:09:57 -0500 Subject: [PATCH 12/38] forgot qbox and did some cleanup --- modules/framework/es_extended/server.lua | 6 +----- modules/framework/qb-core/server.lua | 6 +----- modules/framework/qbx_core/server.lua | 7 +++++++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index cb85e2f..1c2a297 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -142,12 +142,8 @@ end Framework.RevivePlayer = function(src) src = tonumber(src) - if not src then return false end - TriggerEvent('esx_ambulancejob:revive', src) -- FIXME: deprecate - -- TriggerEvent('txAdmin:events:playerHealed', { - -- target = src, - -- }) + TriggerEvent('esx_ambulancejob:revive', src) return true end diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index d3824c8..c7f39ad 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -267,12 +267,8 @@ end Framework.RevivePlayer = function(src) src = tonumber(src) - if not src then return false end - TriggerClientEvent('hospital:client:Revive', src) -- FIXME: deprecate - -- TriggerEvent('txAdmin:events:playerHealed', { - -- target = src, - -- }) + TriggerClientEvent('hospital:client:Revive', src) return true end diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index 7c36db3..e6d349d 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -225,6 +225,13 @@ Framework.GetIsPlayerDead = function(src) return playerData.metadata.isdead or false end +Framework.RevivePlayer = function(src) + src = tonumber(src) + if not src then return false end + TriggerClientEvent('hospital:client:Revive', src) + return true +end + ---This will return the players thirst level. ---@param src number ---@return number From 1242d9ef7ccc0a6126deddac35285574f4add8d5 Mon Sep 17 00:00:00 2001 From: Johann Kraus <56100605+JericoFX@users.noreply.github.com> Date: Fri, 9 May 2025 23:06:01 -0300 Subject: [PATCH 13/38] Add GetPlayer functions to framework and New FUnctions to Utility --- lib/utility/client/utility.lua | 91 ++++++++++++++++++++++++ modules/framework/es_extended/server.lua | 9 +++ modules/framework/qb-core/server.lua | 9 +++ modules/framework/qbx_core/server.lua | 9 +++ 4 files changed, 118 insertions(+) diff --git a/lib/utility/client/utility.lua b/lib/utility/client/utility.lua index d9a87bd..14b4747 100644 --- a/lib/utility/client/utility.lua +++ b/lib/utility/client/utility.lua @@ -404,6 +404,97 @@ function Utility.RemovePoint(pointID) return Point.Remove(pointID) end +---Simple switch-case function +---@generic T +---@param value T The value to match against the cases +---@param cases table Table with case functions and an optional default (false key) +---@return any|false result The return value of the matched case function, or false if none matched +function Utility.Switch(value, cases) + local caseFunc = cases[value] or cases[false] + + if caseFunc and type(caseFunc) == "function" then + local ok, result = pcall(caseFunc) + return ok and result or false + end + + return false +end + +--[[ +local vehicleType = "boat" + +local result = Utility.Switch(vehicleType, { + car = function() + print("This is a Car") + -- Car-related logic here + return "Car logic executed" + end, + bike = function() + print("This is a Bike") + -- Bike-related logic here + return "Bike logic executed" + end, + [false] = function() + print("Unknown vehicle type. Running default logic.") + -- Default logic here + return "Default logic executed" + end, +}) + +print("Result:", result) + +]] + + +--- Pattern match-like function +---@generic T +---@param value T The value to match +---@param patterns table A list of matchers and their handlers +---@return any|false result The result of the first matched case, or false if none +function Utility.Match(value, patterns) + for pattern, handler in pairs(patterns) do + if type(pattern) == "function" then + local ok, matched = pcall(pattern, value) + if ok and matched then + local success, result = pcall(handler) + return success and result or false + end + elseif pattern == value then + local success, result = pcall(handler) + return success and result or false + end + end + + if patterns[false] then + local ok, result = pcall(patterns[false]) + return ok and result or false + end + + return false +end + +--[[ +local input = 42 + +local result = Utility.Match(input, { + [function(v) return v < 0 end] = function() + print("Negative number") + return "Negative" + end, + [function(v) return v % 2 == 0 end] = function() + print("Even number") + return "Even" + end, + [false] = function() + print("No match") + return "Default" + end, +}) + +print("Result:", result) + +]] + AddEventHandler('onResourceStop', function(resource) if resource ~= GetCurrentResourceName() then return end for _, blip in pairs(blipIDs) do diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index 1c2a297..899e945 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -16,6 +16,15 @@ Framework.GetPlayerDob = function(src) return dob end +--- This will return a table of the players data +---@param src any +---@return table | nil +Framework.GetPlayer = function(src) + local xPlayer = ESX.GetPlayerFromId(src) + if not xPlayer then return end + return xPlayer +end + -- Framework.GetPlayerIdentifier(src) -- Returns the citizen ID of the player. Framework.GetPlayerIdentifier = function(src) diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index c7f39ad..9316fae 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -19,6 +19,15 @@ Framework.GetPlayerIdentifier = function(src) return playerData.citizenid end +--- Returns the player data of the specified source. +---@param src any +---@return table | nil +Framework.GetPlayer = function(src) + local player = QBCore.Functions.GetPlayer(src) + if not player then return end + return player +end + Framework.GetFrameworkJobs = function() local jobs = {} for k, v in pairs(QBCore.Shared.Jobs) do diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index e6d349d..d47e1af 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -21,6 +21,15 @@ Framework.GetPlayerDob = function(src) return playerData.charinfo.birthdate end +--- Returns the player data of the specified source. +---@param src any +---@return table | nil +Framework.GetPlayer = function(src) + local player = QBox:GetPlayer(src) + if not player then return end + return player +end + ---Returns a table of the jobs in the framework. ---@return table Framework.GetFrameworkJobs = function() From 7e0124f02ee6820c77f26c47d9cc3d3b69b780bd Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Sat, 10 May 2025 00:01:56 -0400 Subject: [PATCH 14/38] returns added everywhere per crowleys request --- modules/accessibility/client.lua | 4 +++- modules/clothing/_default/client.lua | 6 +++--- modules/clothing/_default/server.lua | 4 +++- modules/dialogue/_default/client/client.lua | 4 +++- modules/dispatch/_default/client/client.lua | 4 +++- modules/dispatch/_default/server/server.lua | 4 +++- modules/dispatch/bub_mdt/client/client.lua | 4 +++- modules/dispatch/bub_mdt/server/server.lua | 4 +++- modules/dispatch/cd_dispatch/client/client.lua | 4 +++- modules/dispatch/cd_dispatch/server/server.lua | 2 ++ modules/dispatch/lb-tablet/client/client.lua | 4 +++- modules/dispatch/lb-tablet/server/server.lua | 4 +++- modules/dispatch/linden_outlawalert/client/client.lua | 4 +++- modules/dispatch/linden_outlawalert/server/server.lua | 4 +++- modules/dispatch/ps-dispatch/client/client.lua | 4 +++- modules/dispatch/ps-dispatch/server/server.lua | 2 ++ modules/dispatch/qs_dispatch/client/client.lua | 4 +++- modules/dispatch/qs_dispatch/server/server.lua | 4 +++- modules/dispatch/redutzu-mdt/client/client.lua | 4 +++- modules/dispatch/redutzu-mdt/server/server.lua | 4 +++- modules/dispatch/tk_dispatch/client/client.lua | 4 +++- modules/dispatch/tk_dispatch/server/server.lua | 4 +++- modules/doorlock/doors_creator/client.lua | 4 +++- modules/doorlock/doors_creator/server.lua | 4 +++- modules/doorlock/ox_doorlock/client.lua | 2 ++ modules/doorlock/ox_doorlock/server.lua | 4 +++- modules/doorlock/qb-doorlock/client.lua | 4 +++- modules/doorlock/qb-doorlock/server.lua | 4 +++- modules/doorlock/rcore_doorlock/client.lua | 4 +++- modules/doorlock/rcore_doorlock/server.lua | 3 ++- modules/framework/_default/server.lua | 1 + modules/framework/es_extended/client.lua | 4 +++- modules/framework/es_extended/server.lua | 4 +++- modules/framework/qb-core/client.lua | 2 ++ modules/framework/qb-core/server.lua | 1 + modules/framework/qbx_core/client.lua | 4 +++- modules/framework/qbx_core/server.lua | 4 +++- modules/fuel/_default/client.lua | 4 +++- modules/fuel/bigDaddy-Fuel/client.lua | 2 ++ modules/fuel/cdn-fuel/client.lua | 4 +++- modules/fuel/esx-sna-fuel/client.lua | 4 +++- modules/fuel/lc_fuel/client.lua | 4 +++- modules/fuel/legacyfuel/client.lua | 4 +++- modules/fuel/okokGasStation/client.lua | 4 +++- modules/fuel/ox_fuel/client.lua | 4 +++- modules/fuel/ps-fuel/client.lua | 4 +++- modules/fuel/qs-fuelstations/client.lua | 4 +++- modules/fuel/renewed-Fuel/client.lua | 4 +++- modules/fuel/ti_fuel/client.lua | 4 +++- modules/fuel/x-fuel/client.lua | 4 +++- modules/helptext/_default/client.lua | 4 +++- modules/helptext/_default/server.lua | 4 +++- modules/helptext/cd_drawtextui/client.lua | 4 +++- modules/helptext/jg-textui/client.lua | 4 +++- modules/helptext/lab-HintUI/client.lua | 4 +++- modules/helptext/okokTextUI/client.lua | 4 +++- modules/helptext/ox_lib/client.lua | 4 +++- modules/housing/_default/client.lua | 4 +++- modules/housing/_default/server.lua | 4 +++- modules/housing/bcs-housing/client.lua | 4 +++- modules/housing/bcs-housing/server.lua | 4 +++- modules/housing/esx_property/client.lua | 4 +++- modules/housing/esx_property/server.lua | 4 +++- modules/housing/ps-housing/client.lua | 4 +++- modules/housing/ps-housing/server.lua | 4 +++- modules/housing/qb-appartments/client.lua | 4 +++- modules/housing/qb-appartments/server.lua | 4 +++- modules/housing/qb-houses/client.lua | 4 +++- modules/housing/qb-houses/server.lua | 4 +++- modules/input/client.lua | 3 +++ modules/inventory/_default/client.lua | 4 +++- modules/inventory/_default/server.lua | 4 +++- modules/inventory/codem-inventory/client.lua | 4 +++- modules/inventory/codem-inventory/server.lua | 4 +++- modules/inventory/core_inventory/client.lua | 4 +++- modules/inventory/core_inventory/server.lua | 4 +++- modules/inventory/jpr-inventory/client.lua | 4 +++- modules/inventory/jpr-inventory/server.lua | 4 +++- modules/inventory/origen_inventory/client.lua | 2 ++ modules/inventory/origen_inventory/server.lua | 3 +++ modules/inventory/ox_inventory/client.lua | 4 +++- modules/inventory/ox_inventory/server.lua | 4 +++- modules/inventory/ps-inventory/client.lua | 4 +++- modules/inventory/ps-inventory/server.lua | 4 +++- modules/inventory/qb-inventory/client.lua | 4 +++- modules/inventory/qb-inventory/server.lua | 4 +++- modules/inventory/qs-inventory/client.lua | 2 ++ modules/inventory/qs-inventory/server.lua | 4 +++- modules/inventory/tgiann-inventory/client.lua | 4 +++- modules/inventory/tgiann-inventory/server.lua | 4 +++- modules/managment/Renewed-Banking/server.lua | 4 +++- modules/managment/_default/server.lua | 4 +++- modules/managment/okokBanking/server.lua | 4 +++- modules/managment/qb-banking/server.lua | 4 +++- modules/math/computation.lua | 2 ++ modules/menu/client.lua | 1 + modules/notify/_default/client.lua | 4 +++- modules/notify/_default/server.lua | 4 +++- modules/notify/mythic_notify/client.lua | 4 +++- modules/notify/okokNotify/client.lua | 4 +++- modules/notify/ox_lib/client.lua | 4 +++- modules/notify/pNotify/client.lua | 4 +++- modules/notify/r_notify/client.lua | 4 +++- modules/notify/t-notify/client.lua | 4 +++- modules/notify/wasabi_notify/client.lua | 4 +++- modules/phone/_default/client.lua | 4 +++- modules/phone/_default/server.lua | 4 +++- modules/phone/gksphone/client.lua | 4 +++- modules/phone/gksphone/server.lua | 4 +++- modules/phone/lb-phone/client.lua | 4 +++- modules/phone/lb-phone/server.lua | 4 +++- modules/phone/okokPhone/client.lua | 2 ++ modules/phone/okokPhone/server.lua | 2 ++ modules/phone/qs-smartphone/client.lua | 4 +++- modules/phone/qs-smartphone/server.lua | 4 +++- modules/progressbar/ox_lib/client.lua | 2 ++ modules/progressbar/qb-progressbar/client.lua | 2 ++ modules/shops/_default/client.lua | 2 ++ modules/shops/_default/server.lua | 4 +++- modules/skills/OT_skills/client.lua | 4 +++- modules/skills/OT_skills/server.lua | 4 +++- modules/skills/_default/client.lua | 4 +++- modules/skills/_default/server.lua | 4 +++- modules/skills/evolent_skills/client.lua | 4 +++- modules/skills/evolent_skills/server.lua | 4 +++- modules/skills/pickle_xp/client.lua | 4 +++- modules/skills/pickle_xp/server.lua | 4 +++- modules/target/_default/client.lua | 4 +++- modules/target/ox_target/client.lua | 2 ++ modules/target/qb-target/client.lua | 4 +++- modules/target/sleepless_interact/client.lua | 2 ++ modules/vehicleKey/F_RealCarKeysSystem/client/client.lua | 2 ++ modules/vehicleKey/MrNewbVehicleKeys/client/client.lua | 4 +++- modules/vehicleKey/Renewed-Vehiclekeys/client/client.lua | 4 +++- modules/vehicleKey/_default/client/client.lua | 4 +++- modules/vehicleKey/cd_garage/client/client.lua | 4 +++- modules/vehicleKey/jacksam/client.lua | 4 +++- modules/vehicleKey/mk_vehiclekeys/client/client.lua | 4 +++- modules/vehicleKey/mono_carkeys/client/client.lua | 2 ++ modules/vehicleKey/okokGarage/client/client.lua | 4 +++- modules/vehicleKey/qb-vehiclekeys/client/client.lua | 4 +++- modules/vehicleKey/qbx_vehiclekeys/client/client.lua | 4 +++- modules/vehicleKey/qs-vehiclekeys/client/client.lua | 4 +++- modules/vehicleKey/t1ger_keys/client/client.lua | 4 +++- modules/vehicleKey/wasabi_carlock/client/client.lua | 4 +++- modules/version/server/VersionChecker.lua | 4 +++- modules/weather/_default/client.lua | 4 +++- modules/weather/cd_easytime/client.lua | 4 +++- modules/weather/qb-weathersync/client/client.lua | 4 +++- modules/weather/renewed-weathersync/client/client.lua | 4 +++- 150 files changed, 426 insertions(+), 130 deletions(-) diff --git a/modules/accessibility/client.lua b/modules/accessibility/client.lua index a284ca6..5aa0851 100644 --- a/modules/accessibility/client.lua +++ b/modules/accessibility/client.lua @@ -207,4 +207,6 @@ Accessibility.getAdjustedColour = function(colourName, returnAsRGB) Prints.Error("Invalid Colour Name^0] [^3"..colourName.."^0") return "#FFFFFF" -- Default to white if the colour name is invalid end -end \ No newline at end of file +end + +return Accessibility \ No newline at end of file diff --git a/modules/clothing/_default/client.lua b/modules/clothing/_default/client.lua index bd35793..47b89d4 100644 --- a/modules/clothing/_default/client.lua +++ b/modules/clothing/_default/client.lua @@ -34,8 +34,6 @@ Clothing.ReloadSkin = function() return true end - - Clothing.UpdateAppearanceBackup = function(data) ClothingBackup = data end @@ -58,4 +56,6 @@ end) RegisterNetEvent('community_bridge:client:ReloadSkin', function() Clothing.ReloadSkin() -end) \ No newline at end of file +end) + +return Clothing \ No newline at end of file diff --git a/modules/clothing/_default/server.lua b/modules/clothing/_default/server.lua index 8689800..d02f61f 100644 --- a/modules/clothing/_default/server.lua +++ b/modules/clothing/_default/server.lua @@ -29,4 +29,6 @@ end) RegisterNetEvent('community_bridge:client:ReloadSkin', function() Clothing.ReloadSkin() -end) \ No newline at end of file +end) + +return Clothing \ No newline at end of file diff --git a/modules/dialogue/_default/client/client.lua b/modules/dialogue/_default/client/client.lua index 97ce769..1f91e0e 100644 --- a/modules/dialogue/_default/client/client.lua +++ b/modules/dialogue/_default/client/client.lua @@ -161,4 +161,6 @@ if BridgeSharedConfig.DebugLevel >= 1 then end end) end) -end \ No newline at end of file +end + +return Dialogue \ No newline at end of file diff --git a/modules/dispatch/_default/client/client.lua b/modules/dispatch/_default/client/client.lua index eeffe67..16f4c99 100644 --- a/modules/dispatch/_default/client/client.lua +++ b/modules/dispatch/_default/client/client.lua @@ -26,4 +26,6 @@ RegisterNetEvent('community_bridge:Client:DispatchAlert', function(alert) local blip = Bridge.Utility.CreateBlip(alert.coords, alert.sprite, alert.color, alert.scale, alert.code, true) Wait(alert.time) Bridge.Utility.RemoveBlip(blip) -end) \ No newline at end of file +end) + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/_default/server/server.lua b/modules/dispatch/_default/server/server.lua index 4296918..31d76e4 100644 --- a/modules/dispatch/_default/server/server.lua +++ b/modules/dispatch/_default/server/server.lua @@ -8,4 +8,6 @@ RegisterNetEvent("community_bridge:Server:DispatchAlert", function(data) TriggerClientEvent('community_bridge:Client:DispatchAlert', src, data) end end -end) \ No newline at end of file +end) + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/bub_mdt/client/client.lua b/modules/dispatch/bub_mdt/client/client.lua index 999ff62..f5850f2 100644 --- a/modules/dispatch/bub_mdt/client/client.lua +++ b/modules/dispatch/bub_mdt/client/client.lua @@ -12,4 +12,6 @@ Dispatch.SendAlert = function(data) blipCoords = data.coords or cache.ped and GetEntityCoords(cache.ped) or { x = 0, y = 0}, } exports["bub-mdt"]:CustomAlert(alertData) -end \ No newline at end of file +end + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/bub_mdt/server/server.lua b/modules/dispatch/bub_mdt/server/server.lua index 13c866f..60cd14c 100644 --- a/modules/dispatch/bub_mdt/server/server.lua +++ b/modules/dispatch/bub_mdt/server/server.lua @@ -1,2 +1,4 @@ if GetResourceState('bub-mdt') ~= 'started' then return end -Dispatch = Dispatch or {} \ No newline at end of file +Dispatch = Dispatch or {} + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/cd_dispatch/client/client.lua b/modules/dispatch/cd_dispatch/client/client.lua index b9e0aa2..c37ff1e 100644 --- a/modules/dispatch/cd_dispatch/client/client.lua +++ b/modules/dispatch/cd_dispatch/client/client.lua @@ -21,4 +21,6 @@ Dispatch.SendAlert = function(data) radius = 0, } }) -end \ No newline at end of file +end + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/cd_dispatch/server/server.lua b/modules/dispatch/cd_dispatch/server/server.lua index 364e335..20f62c3 100644 --- a/modules/dispatch/cd_dispatch/server/server.lua +++ b/modules/dispatch/cd_dispatch/server/server.lua @@ -1,2 +1,4 @@ if GetResourceState('cd_dispatch') ~= 'started' then return end Dispatch = Dispatch or {} + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/lb-tablet/client/client.lua b/modules/dispatch/lb-tablet/client/client.lua index 83aabee..28483ab 100644 --- a/modules/dispatch/lb-tablet/client/client.lua +++ b/modules/dispatch/lb-tablet/client/client.lua @@ -37,4 +37,6 @@ Dispatch.SendAlert = function(data) job = data.jobs, } TriggerServerEvent("community_bridge:server:dispatch:sendAlert", alertData) -end \ No newline at end of file +end + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/lb-tablet/server/server.lua b/modules/dispatch/lb-tablet/server/server.lua index ec8befc..b4806d8 100644 --- a/modules/dispatch/lb-tablet/server/server.lua +++ b/modules/dispatch/lb-tablet/server/server.lua @@ -3,4 +3,6 @@ Dispatch = Dispatch or {} RegisterNetEvent("community_bridge:server:dispatch:sendAlert", function(data) exports["lb-tablet"]:AddDispatch(data) -- this has a return value but we dont really have a use for it atm. -end) \ No newline at end of file +end) + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/linden_outlawalert/client/client.lua b/modules/dispatch/linden_outlawalert/client/client.lua index 3b936e0..eed7de0 100644 --- a/modules/dispatch/linden_outlawalert/client/client.lua +++ b/modules/dispatch/linden_outlawalert/client/client.lua @@ -15,4 +15,6 @@ Dispatch.SendAlert = function(data) caller = 'Anonymous', coords = data.coords or GetEntityCoords(cache.ped) }) -end \ No newline at end of file +end + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/linden_outlawalert/server/server.lua b/modules/dispatch/linden_outlawalert/server/server.lua index 1824ed4..4e58535 100644 --- a/modules/dispatch/linden_outlawalert/server/server.lua +++ b/modules/dispatch/linden_outlawalert/server/server.lua @@ -1,2 +1,4 @@ if GetResourceState('linden_outlawalert') ~= 'started' then return end -Dispatch = Dispatch or {} \ No newline at end of file +Dispatch = Dispatch or {} + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/ps-dispatch/client/client.lua b/modules/dispatch/ps-dispatch/client/client.lua index cbf06a3..a4eb7d8 100644 --- a/modules/dispatch/ps-dispatch/client/client.lua +++ b/modules/dispatch/ps-dispatch/client/client.lua @@ -27,4 +27,6 @@ Dispatch.SendAlert = function(data) jobs = data.jobs } exports["ps-dispatch"]:CustomAlert(alertData) -end \ No newline at end of file +end + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/ps-dispatch/server/server.lua b/modules/dispatch/ps-dispatch/server/server.lua index b75b55e..dde11f4 100644 --- a/modules/dispatch/ps-dispatch/server/server.lua +++ b/modules/dispatch/ps-dispatch/server/server.lua @@ -1,3 +1,5 @@ if GetResourceState('ps-dispatch') ~= 'started' then return end if GetResourceState('lb-tablet') == 'started' then return end Dispatch = Dispatch or {} + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/qs_dispatch/client/client.lua b/modules/dispatch/qs_dispatch/client/client.lua index 3656cc7..f68f798 100644 --- a/modules/dispatch/qs_dispatch/client/client.lua +++ b/modules/dispatch/qs_dispatch/client/client.lua @@ -35,4 +35,6 @@ Dispatch.SendAlert = function(data) customData.image = image or customData.image TriggerServerEvent('qs-dispatch:server:CreateDispatchCall', customData) end) -end \ No newline at end of file +end + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/qs_dispatch/server/server.lua b/modules/dispatch/qs_dispatch/server/server.lua index 238df5e..46fa79a 100644 --- a/modules/dispatch/qs_dispatch/server/server.lua +++ b/modules/dispatch/qs_dispatch/server/server.lua @@ -1,2 +1,4 @@ if GetResourceState('qs-dispatch') ~= 'started' then return end -Dispatch = Dispatch or {} \ No newline at end of file +Dispatch = Dispatch or {} + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/redutzu-mdt/client/client.lua b/modules/dispatch/redutzu-mdt/client/client.lua index 2314a7d..895de7b 100644 --- a/modules/dispatch/redutzu-mdt/client/client.lua +++ b/modules/dispatch/redutzu-mdt/client/client.lua @@ -11,4 +11,6 @@ Dispatch.SendAlert = function(data) coords = data.coords, } TriggerServerEvent("community_bridge:server:dispatch:sendAlert", alertData) -end \ No newline at end of file +end + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/redutzu-mdt/server/server.lua b/modules/dispatch/redutzu-mdt/server/server.lua index e07d799..ea72477 100644 --- a/modules/dispatch/redutzu-mdt/server/server.lua +++ b/modules/dispatch/redutzu-mdt/server/server.lua @@ -9,4 +9,6 @@ RegisterNetEvent("community_bridge:server:dispatch:sendAlert", function(data) duration = data.time, coords = data.coords }) -end) \ No newline at end of file +end) + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/tk_dispatch/client/client.lua b/modules/dispatch/tk_dispatch/client/client.lua index 7d112fb..edfa708 100644 --- a/modules/dispatch/tk_dispatch/client/client.lua +++ b/modules/dispatch/tk_dispatch/client/client.lua @@ -17,4 +17,6 @@ Dispatch.SendAlert = function(data) }, jobs = data.jobs or {'police'}, }) -end \ No newline at end of file +end + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/tk_dispatch/server/server.lua b/modules/dispatch/tk_dispatch/server/server.lua index 43020fb..688895d 100644 --- a/modules/dispatch/tk_dispatch/server/server.lua +++ b/modules/dispatch/tk_dispatch/server/server.lua @@ -1,2 +1,4 @@ if GetResourceState('tk_dispatch') ~= 'started' then return end -Dispatch = Dispatch or {} \ No newline at end of file +Dispatch = Dispatch or {} + +return Dispatch \ No newline at end of file diff --git a/modules/doorlock/doors_creator/client.lua b/modules/doorlock/doors_creator/client.lua index 4d11da1..26a691b 100644 --- a/modules/doorlock/doors_creator/client.lua +++ b/modules/doorlock/doors_creator/client.lua @@ -7,4 +7,6 @@ Doorlock = Doorlock or {} ---@return string | nil Doorlock.GetClosestDoor = function() return exports["doors_creator"]:getClosestActiveDoor() -end \ No newline at end of file +end + +return Doorlock \ No newline at end of file diff --git a/modules/doorlock/doors_creator/server.lua b/modules/doorlock/doors_creator/server.lua index c45de2e..ed9a0b1 100644 --- a/modules/doorlock/doors_creator/server.lua +++ b/modules/doorlock/doors_creator/server.lua @@ -16,4 +16,6 @@ Doorlock.ToggleDoorLock = function(doorID, toggle) exports["doors_creator"]:setDoorState(doorID, 0) end return true -end \ No newline at end of file +end + +return Doorlock \ No newline at end of file diff --git a/modules/doorlock/ox_doorlock/client.lua b/modules/doorlock/ox_doorlock/client.lua index 738cdf7..04a2d31 100644 --- a/modules/doorlock/ox_doorlock/client.lua +++ b/modules/doorlock/ox_doorlock/client.lua @@ -10,3 +10,5 @@ Doorlock.GetClosestDoor = function() if not doorData then return end return tostring(doorData.id) or nil end + +return Doorlock \ No newline at end of file diff --git a/modules/doorlock/ox_doorlock/server.lua b/modules/doorlock/ox_doorlock/server.lua index 3c0ff18..132efa1 100644 --- a/modules/doorlock/ox_doorlock/server.lua +++ b/modules/doorlock/ox_doorlock/server.lua @@ -15,4 +15,6 @@ Doorlock.ToggleDoorLock = function(doorID, toggle) exports.ox_doorlock:setDoorState(doorID, 0) end return true -end \ No newline at end of file +end + +return Doorlock \ No newline at end of file diff --git a/modules/doorlock/qb-doorlock/client.lua b/modules/doorlock/qb-doorlock/client.lua index 5c7c92b..b5275b9 100644 --- a/modules/doorlock/qb-doorlock/client.lua +++ b/modules/doorlock/qb-doorlock/client.lua @@ -20,4 +20,6 @@ Doorlock.GetClosestDoor = function() end end return door -end \ No newline at end of file +end + +return Doorlock \ No newline at end of file diff --git a/modules/doorlock/qb-doorlock/server.lua b/modules/doorlock/qb-doorlock/server.lua index 59e19cf..5fd74c9 100644 --- a/modules/doorlock/qb-doorlock/server.lua +++ b/modules/doorlock/qb-doorlock/server.lua @@ -10,4 +10,6 @@ Doorlock = Doorlock or {} Doorlock.ToggleDoorLock = function(doorID, toggle) TriggerClientEvent('qb-doorlock:client:setState', -1, 0, doorID, toggle, false, false, false) return true -end \ No newline at end of file +end + +return Doorlock \ No newline at end of file diff --git a/modules/doorlock/rcore_doorlock/client.lua b/modules/doorlock/rcore_doorlock/client.lua index ceb596b..11860b1 100644 --- a/modules/doorlock/rcore_doorlock/client.lua +++ b/modules/doorlock/rcore_doorlock/client.lua @@ -18,4 +18,6 @@ Doorlock.GetClosestDoor = function() end end return door -end \ No newline at end of file +end + +return Doorlock \ No newline at end of file diff --git a/modules/doorlock/rcore_doorlock/server.lua b/modules/doorlock/rcore_doorlock/server.lua index c7190c8..016f952 100644 --- a/modules/doorlock/rcore_doorlock/server.lua +++ b/modules/doorlock/rcore_doorlock/server.lua @@ -15,4 +15,5 @@ Doorlock.ToggleDoorLock = function(doorID, toggle) exports.rcore_doorlock:changeDoorState(doorID, 1) end return true -end \ No newline at end of file +end +return Doorlock \ No newline at end of file diff --git a/modules/framework/_default/server.lua b/modules/framework/_default/server.lua index 4fff4d4..5d895be 100644 --- a/modules/framework/_default/server.lua +++ b/modules/framework/_default/server.lua @@ -1,2 +1,3 @@ Framework = Framework or {} +return Framework \ No newline at end of file diff --git a/modules/framework/es_extended/client.lua b/modules/framework/es_extended/client.lua index a970606..cea9a41 100644 --- a/modules/framework/es_extended/client.lua +++ b/modules/framework/es_extended/client.lua @@ -133,4 +133,6 @@ RegisterNetEvent('esx:setJob', function(data) PlayerJobGradeName = data.grade_label PlayerJobGradeLevel = data.grade TriggerEvent('community_bridge:Client:OnPlayerJobUpdate',PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel) -end) \ No newline at end of file +end) + +return Framework \ No newline at end of file diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index 899e945..2597fcd 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -350,4 +350,6 @@ Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, help = help, arguments = arguments }) -end \ No newline at end of file +end + +return Framework \ No newline at end of file diff --git a/modules/framework/qb-core/client.lua b/modules/framework/qb-core/client.lua index 9d70865..71639aa 100644 --- a/modules/framework/qb-core/client.lua +++ b/modules/framework/qb-core/client.lua @@ -175,3 +175,5 @@ RegisterNetEvent('QBCore:Client:OnGangUpdate', function(data) TriggerEvent('community_bridge:Client:OnPlayerGangUpdate', PlayerGangName, PlayerGangLabel, PlayerGangGradeName, PlayerGangGradeLevel) --]] end) + +return Framework \ No newline at end of file diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index 9316fae..736278e 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -494,3 +494,4 @@ Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...) end +return Framework \ No newline at end of file diff --git a/modules/framework/qbx_core/client.lua b/modules/framework/qbx_core/client.lua index e1d0f51..2fee358 100644 --- a/modules/framework/qbx_core/client.lua +++ b/modules/framework/qbx_core/client.lua @@ -89,4 +89,6 @@ RegisterNetEvent('QBCore:Client:OnJobUpdate', function(data) PlayerJobGradeName = data.grade.name PlayerJobGradeLevel = data.grade.level TriggerEvent('community_bridge:Client:OnPlayerJobUpdate',PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel) -end) \ No newline at end of file +end) + +return Framework \ No newline at end of file diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index d47e1af..f536597 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -448,4 +448,6 @@ end) AddEventHandler("playerDropped", function() local src = source TriggerEvent("community_bridge:Server:OnPlayerUnload", src) -end) \ No newline at end of file +end) + +return Framework \ No newline at end of file diff --git a/modules/fuel/_default/client.lua b/modules/fuel/_default/client.lua index 681b2e4..731ace5 100644 --- a/modules/fuel/_default/client.lua +++ b/modules/fuel/_default/client.lua @@ -21,4 +21,6 @@ end Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return SetVehicleFuelLevel(vehicle, fuel) -end \ No newline at end of file +end + +return Fuel \ No newline at end of file diff --git a/modules/fuel/bigDaddy-Fuel/client.lua b/modules/fuel/bigDaddy-Fuel/client.lua index daa86a6..00f8f75 100644 --- a/modules/fuel/bigDaddy-Fuel/client.lua +++ b/modules/fuel/bigDaddy-Fuel/client.lua @@ -26,3 +26,5 @@ Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end exports['BigDaddy-Fuel']:SetFuel(vehicle, fuel) end + +return Fuel \ No newline at end of file diff --git a/modules/fuel/cdn-fuel/client.lua b/modules/fuel/cdn-fuel/client.lua index 093987f..1dba7dd 100644 --- a/modules/fuel/cdn-fuel/client.lua +++ b/modules/fuel/cdn-fuel/client.lua @@ -25,4 +25,6 @@ end Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return exports['cdn-fuel']:SetFuel(vehicle, fuel) -end \ No newline at end of file +end + +return Fuel \ No newline at end of file diff --git a/modules/fuel/esx-sna-fuel/client.lua b/modules/fuel/esx-sna-fuel/client.lua index 3309621..cc15388 100644 --- a/modules/fuel/esx-sna-fuel/client.lua +++ b/modules/fuel/esx-sna-fuel/client.lua @@ -25,4 +25,6 @@ end Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end exports['esx-sna-fuel']:SetFuel(vehicle, fuel) -end \ No newline at end of file +end + +return Fuel \ No newline at end of file diff --git a/modules/fuel/lc_fuel/client.lua b/modules/fuel/lc_fuel/client.lua index 3048cb9..551aef2 100644 --- a/modules/fuel/lc_fuel/client.lua +++ b/modules/fuel/lc_fuel/client.lua @@ -26,4 +26,6 @@ end Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports["lc_fuel"]:SetFuel(vehicle, fuel) -end \ No newline at end of file +end + +return Fuel \ No newline at end of file diff --git a/modules/fuel/legacyfuel/client.lua b/modules/fuel/legacyfuel/client.lua index 6c64d4f..4903687 100644 --- a/modules/fuel/legacyfuel/client.lua +++ b/modules/fuel/legacyfuel/client.lua @@ -25,4 +25,6 @@ end Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports['LegacyFuel']:SetFuel(vehicle, fuel) -end \ No newline at end of file +end + +return Fuel \ No newline at end of file diff --git a/modules/fuel/okokGasStation/client.lua b/modules/fuel/okokGasStation/client.lua index 02c5ed0..42785fe 100644 --- a/modules/fuel/okokGasStation/client.lua +++ b/modules/fuel/okokGasStation/client.lua @@ -25,4 +25,6 @@ end Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports['okokGasStation']:SetFuel(vehicle, fuel) -end \ No newline at end of file +end + +return Fuel \ No newline at end of file diff --git a/modules/fuel/ox_fuel/client.lua b/modules/fuel/ox_fuel/client.lua index 16d7772..1001582 100644 --- a/modules/fuel/ox_fuel/client.lua +++ b/modules/fuel/ox_fuel/client.lua @@ -27,4 +27,6 @@ Fuel.SetFuel = function(vehicle, fuel, type) local currentFuel = Entity(vehicle).state.fuel Entity(vehicle).state.fuel = currentFuel + fuel return Entity(vehicle).state.fuel -end \ No newline at end of file +end + +return Fuel \ No newline at end of file diff --git a/modules/fuel/ps-fuel/client.lua b/modules/fuel/ps-fuel/client.lua index 8f28f7e..ee84b1a 100644 --- a/modules/fuel/ps-fuel/client.lua +++ b/modules/fuel/ps-fuel/client.lua @@ -25,4 +25,6 @@ end Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports["ps-fuel"]:SetFuel(vehicle, fuel) -end \ No newline at end of file +end + +return Fuel \ No newline at end of file diff --git a/modules/fuel/qs-fuelstations/client.lua b/modules/fuel/qs-fuelstations/client.lua index 8b3827f..ab5c571 100644 --- a/modules/fuel/qs-fuelstations/client.lua +++ b/modules/fuel/qs-fuelstations/client.lua @@ -25,4 +25,6 @@ end Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return exports['qs-fuelstations']:SetFuel(vehicle, fuel) -end \ No newline at end of file +end + +return Fuel \ No newline at end of file diff --git a/modules/fuel/renewed-Fuel/client.lua b/modules/fuel/renewed-Fuel/client.lua index 262740e..8ed1f66 100644 --- a/modules/fuel/renewed-Fuel/client.lua +++ b/modules/fuel/renewed-Fuel/client.lua @@ -25,4 +25,6 @@ end Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports['Renewed-Fuel']:SetFuel(vehicle, fuel) -end \ No newline at end of file +end + +return Fuel \ No newline at end of file diff --git a/modules/fuel/ti_fuel/client.lua b/modules/fuel/ti_fuel/client.lua index d0fdcef..54471e2 100644 --- a/modules/fuel/ti_fuel/client.lua +++ b/modules/fuel/ti_fuel/client.lua @@ -26,4 +26,6 @@ end Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return exports['ti_fuel']:setFuel(vehicle, fuel, "RON91") -end \ No newline at end of file +end + +return Fuel \ No newline at end of file diff --git a/modules/fuel/x-fuel/client.lua b/modules/fuel/x-fuel/client.lua index 1011e3b..b00f604 100644 --- a/modules/fuel/x-fuel/client.lua +++ b/modules/fuel/x-fuel/client.lua @@ -26,4 +26,6 @@ end Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return exports['x-fuel']:SetFuel(vehicle, fuel) -end \ No newline at end of file +end + +return Fuel \ No newline at end of file diff --git a/modules/helptext/_default/client.lua b/modules/helptext/_default/client.lua index c1e4ea1..bfab021 100644 --- a/modules/helptext/_default/client.lua +++ b/modules/helptext/_default/client.lua @@ -22,4 +22,6 @@ end) RegisterNetEvent('community_bridge:Client:HideHelpText', function() HelpText.HideHelpText() -end) \ No newline at end of file +end) + +return HelpText \ No newline at end of file diff --git a/modules/helptext/_default/server.lua b/modules/helptext/_default/server.lua index 448e815..c670c93 100644 --- a/modules/helptext/_default/server.lua +++ b/modules/helptext/_default/server.lua @@ -14,4 +14,6 @@ end ---@diagnostic disable-next-line: duplicate-set-field HelpText.HideHelpText = function(src) TriggerClientEvent('community_bridge:Client:HideHelpText', src) -end \ No newline at end of file +end + +return HelpText \ No newline at end of file diff --git a/modules/helptext/cd_drawtextui/client.lua b/modules/helptext/cd_drawtextui/client.lua index 4ae1271..9d55f2e 100644 --- a/modules/helptext/cd_drawtextui/client.lua +++ b/modules/helptext/cd_drawtextui/client.lua @@ -18,4 +18,6 @@ end ---@diagnostic disable-next-line: duplicate-set-field HelpText.HideHelpText = function() return TriggerEvent('cd_drawtextui:HideUI') -end \ No newline at end of file +end + +return HelpText \ No newline at end of file diff --git a/modules/helptext/jg-textui/client.lua b/modules/helptext/jg-textui/client.lua index bd2d9d6..cc6d4f8 100644 --- a/modules/helptext/jg-textui/client.lua +++ b/modules/helptext/jg-textui/client.lua @@ -17,4 +17,6 @@ end ---@diagnostic disable-next-line: duplicate-set-field HelpText.HideHelpText = function() return exports['jg-textui']:HideText() -end \ No newline at end of file +end + +return HelpText \ No newline at end of file diff --git a/modules/helptext/lab-HintUI/client.lua b/modules/helptext/lab-HintUI/client.lua index c6e42bc..0ddccb9 100644 --- a/modules/helptext/lab-HintUI/client.lua +++ b/modules/helptext/lab-HintUI/client.lua @@ -17,4 +17,6 @@ end ---@diagnostic disable-next-line: duplicate-set-field HelpText.HideHelpText = function() return exports['lab-HintUI']:Hide() -end \ No newline at end of file +end + +return HelpText \ No newline at end of file diff --git a/modules/helptext/okokTextUI/client.lua b/modules/helptext/okokTextUI/client.lua index f2614d2..fec30be 100644 --- a/modules/helptext/okokTextUI/client.lua +++ b/modules/helptext/okokTextUI/client.lua @@ -17,4 +17,6 @@ end ---@diagnostic disable-next-line: duplicate-set-field HelpText.HideHelpText = function() return exports['okokTextUI']:Close() -end \ No newline at end of file +end + +return HelpText \ No newline at end of file diff --git a/modules/helptext/ox_lib/client.lua b/modules/helptext/ox_lib/client.lua index 171fe98..4fe01d3 100644 --- a/modules/helptext/ox_lib/client.lua +++ b/modules/helptext/ox_lib/client.lua @@ -18,4 +18,6 @@ end ---@diagnostic disable-next-line: duplicate-set-field HelpText.HideHelpText = function() return exports.ox_lib:hideTextUI() -end \ No newline at end of file +end + +return HelpText \ No newline at end of file diff --git a/modules/housing/_default/client.lua b/modules/housing/_default/client.lua index 4e660db..ae77287 100644 --- a/modules/housing/_default/client.lua +++ b/modules/housing/_default/client.lua @@ -1 +1,3 @@ -Housing = Housing or {} \ No newline at end of file +Housing = Housing or {} + +return Housing \ No newline at end of file diff --git a/modules/housing/_default/server.lua b/modules/housing/_default/server.lua index dcfb42b..4566d0a 100644 --- a/modules/housing/_default/server.lua +++ b/modules/housing/_default/server.lua @@ -9,4 +9,6 @@ RegisterNetEvent('community_bridge:Server:_OnPlayerInside', function(src, inside local playerEntity = GetPlayerPed(src) local playerCoords = GetEntityCoords(playerEntity) TriggerEvent('community_bridge:Client:OnPlayerInside', src, insideId, currentBucket, playerCoords) -end) \ No newline at end of file +end) + +return Housing \ No newline at end of file diff --git a/modules/housing/bcs-housing/client.lua b/modules/housing/bcs-housing/client.lua index d5d2396..398b713 100644 --- a/modules/housing/bcs-housing/client.lua +++ b/modules/housing/bcs-housing/client.lua @@ -8,4 +8,6 @@ end) RegisterNetEvent("Housing:client:DeleteFurnitures", function() TriggerServerEvent('community_bridge:Server:_OnPlayerInside', false) -end) \ No newline at end of file +end) + +return Housing \ No newline at end of file diff --git a/modules/housing/bcs-housing/server.lua b/modules/housing/bcs-housing/server.lua index f4263c0..7a8f747 100644 --- a/modules/housing/bcs-housing/server.lua +++ b/modules/housing/bcs-housing/server.lua @@ -1,3 +1,5 @@ if GetResourceState('bcs-housing') ~= 'started' then return end -Housing = Housing or {} \ No newline at end of file +Housing = Housing or {} + +return Housing \ No newline at end of file diff --git a/modules/housing/esx_property/client.lua b/modules/housing/esx_property/client.lua index 3d3238f..dc61c00 100644 --- a/modules/housing/esx_property/client.lua +++ b/modules/housing/esx_property/client.lua @@ -1,3 +1,5 @@ if GetResourceState('esx_property') ~= 'started' then return end -Housing = Housing or {} \ No newline at end of file +Housing = Housing or {} + +return Housing \ No newline at end of file diff --git a/modules/housing/esx_property/server.lua b/modules/housing/esx_property/server.lua index 5243ae7..118fa7a 100644 --- a/modules/housing/esx_property/server.lua +++ b/modules/housing/esx_property/server.lua @@ -10,4 +10,6 @@ end) RegisterNetEvent('esx_property:leave', function(insideId) local src = source TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) -end) \ No newline at end of file +end) + +return Housing \ No newline at end of file diff --git a/modules/housing/ps-housing/client.lua b/modules/housing/ps-housing/client.lua index a40ae1c..b7f5d8e 100644 --- a/modules/housing/ps-housing/client.lua +++ b/modules/housing/ps-housing/client.lua @@ -1,3 +1,5 @@ if GetResourceState('ps-housing') ~= 'started' then return end -Housing = Housing or {} \ No newline at end of file +Housing = Housing or {} + +return Housing \ No newline at end of file diff --git a/modules/housing/ps-housing/server.lua b/modules/housing/ps-housing/server.lua index d364c2e..52a2e48 100644 --- a/modules/housing/ps-housing/server.lua +++ b/modules/housing/ps-housing/server.lua @@ -10,4 +10,6 @@ end) RegisterNetEvent('ps-housing:server:leaveProperty', function(insideId) local src = source TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) -end) \ No newline at end of file +end) + +return Housing \ No newline at end of file diff --git a/modules/housing/qb-appartments/client.lua b/modules/housing/qb-appartments/client.lua index 5d6b7f8..2ce29c9 100644 --- a/modules/housing/qb-appartments/client.lua +++ b/modules/housing/qb-appartments/client.lua @@ -1,3 +1,5 @@ if GetResourceState('qb-appartments') ~= 'started' then return end -Housing = Housing or {} \ No newline at end of file +Housing = Housing or {} + +return Housing \ No newline at end of file diff --git a/modules/housing/qb-appartments/server.lua b/modules/housing/qb-appartments/server.lua index 6c5f6c5..cfd0982 100644 --- a/modules/housing/qb-appartments/server.lua +++ b/modules/housing/qb-appartments/server.lua @@ -6,4 +6,6 @@ RegisterNetEvent('qb-apartments:server:SetInsideMeta', function(house, insideId, local src = source insideId = bool and house .. '-' .. insideId or nil TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) -end) \ No newline at end of file +end) + +return Housing \ No newline at end of file diff --git a/modules/housing/qb-houses/client.lua b/modules/housing/qb-houses/client.lua index e1e61cf..4208627 100644 --- a/modules/housing/qb-houses/client.lua +++ b/modules/housing/qb-houses/client.lua @@ -1,3 +1,5 @@ if GetResourceState('qb-houses') ~= 'started' then return end -Housing = Housing or {} \ No newline at end of file +Housing = Housing or {} + +return Housing \ No newline at end of file diff --git a/modules/housing/qb-houses/server.lua b/modules/housing/qb-houses/server.lua index 7fac010..a06d537 100644 --- a/modules/housing/qb-houses/server.lua +++ b/modules/housing/qb-houses/server.lua @@ -6,4 +6,6 @@ RegisterNetEvent('qb-houses:server:SetInsideMeta', function(insideId, bool) local src = source insideId = bool and insideId or nil TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) -end) \ No newline at end of file +end) + +return Housing \ No newline at end of file diff --git a/modules/input/client.lua b/modules/input/client.lua index a5b86d1..1650cce 100644 --- a/modules/input/client.lua +++ b/modules/input/client.lua @@ -107,6 +107,9 @@ function Input.Open(title, data, isQBFormat, submitText) return OpenInput(title, data, isQBFormat, submitText) end +return Input + + --[[ -- Unit tests local thisIsQB = { diff --git a/modules/inventory/_default/client.lua b/modules/inventory/_default/client.lua index 42853d9..7f460c5 100644 --- a/modules/inventory/_default/client.lua +++ b/modules/inventory/_default/client.lua @@ -40,4 +40,6 @@ Inventory.StripPNG = function(item) item = string.gsub(item, ".png", "") end return item -end \ No newline at end of file +end + +return Inventory \ No newline at end of file diff --git a/modules/inventory/_default/server.lua b/modules/inventory/_default/server.lua index eac7130..ebde24c 100644 --- a/modules/inventory/_default/server.lua +++ b/modules/inventory/_default/server.lua @@ -151,4 +151,6 @@ Inventory.StripPNG = function(item) item = string.gsub(item, ".png", "") end return item -end \ No newline at end of file +end + +return Inventory \ No newline at end of file diff --git a/modules/inventory/codem-inventory/client.lua b/modules/inventory/codem-inventory/client.lua index 4893b37..ffe00a5 100644 --- a/modules/inventory/codem-inventory/client.lua +++ b/modules/inventory/codem-inventory/client.lua @@ -54,4 +54,6 @@ end RegisterNetEvent('community_bridge:client:codem-inventory:openStash', function(id, data) if source ~= 65535 then return end TriggerServerEvent('codem-inventory:server:openstash', id, data.slots, data.weight, data.label) -end) \ No newline at end of file +end) + +return Inventory \ No newline at end of file diff --git a/modules/inventory/codem-inventory/server.lua b/modules/inventory/codem-inventory/server.lua index 4f68f4b..0718c83 100644 --- a/modules/inventory/codem-inventory/server.lua +++ b/modules/inventory/codem-inventory/server.lua @@ -171,4 +171,6 @@ end -- @param shopGroups table Inventory.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups) return true, print("Unable to Create Shop for codem-inventory, I do not have access to a copy of this inventory to bridge the feature.") -end \ No newline at end of file +end + +return Inventory \ No newline at end of file diff --git a/modules/inventory/core_inventory/client.lua b/modules/inventory/core_inventory/client.lua index f31858c..e1d877c 100644 --- a/modules/inventory/core_inventory/client.lua +++ b/modules/inventory/core_inventory/client.lua @@ -61,4 +61,6 @@ Inventory.GetPlayerInventory = function() }) end return repackedTable -end \ No newline at end of file +end + +return Inventory \ No newline at end of file diff --git a/modules/inventory/core_inventory/server.lua b/modules/inventory/core_inventory/server.lua index d9869fa..0f24af5 100644 --- a/modules/inventory/core_inventory/server.lua +++ b/modules/inventory/core_inventory/server.lua @@ -225,4 +225,6 @@ end lib.callback.register('community_bridge:Callback:core_inventory', function(source) local items = core:getItemsList() return items or {} -end) \ No newline at end of file +end) + +return Inventory \ No newline at end of file diff --git a/modules/inventory/jpr-inventory/client.lua b/modules/inventory/jpr-inventory/client.lua index a2b0422..34fc32d 100644 --- a/modules/inventory/jpr-inventory/client.lua +++ b/modules/inventory/jpr-inventory/client.lua @@ -41,4 +41,6 @@ RegisterNetEvent('community_bridge:client:jpr-inventory:openStash', function(id, if source ~= 65535 then return end TriggerEvent("inventory:client:SetCurrentStash", id) TriggerServerEvent('inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots }) -end) \ No newline at end of file +end) + +return Inventory \ No newline at end of file diff --git a/modules/inventory/jpr-inventory/server.lua b/modules/inventory/jpr-inventory/server.lua index df331af..81f4dc0 100644 --- a/modules/inventory/jpr-inventory/server.lua +++ b/modules/inventory/jpr-inventory/server.lua @@ -154,4 +154,6 @@ Inventory.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups jpr:CreateShop(repackedShopItems) registeredShops[shopTitle] = true return true -end \ No newline at end of file +end + +return Inventory \ No newline at end of file diff --git a/modules/inventory/origen_inventory/client.lua b/modules/inventory/origen_inventory/client.lua index 88f1a59..fe44011 100644 --- a/modules/inventory/origen_inventory/client.lua +++ b/modules/inventory/origen_inventory/client.lua @@ -69,3 +69,5 @@ end Inventory.OpenStash = function(id) origin:openInventory('stash', id, { label = id, weight = 400000, slots = 100, }) end + +return Inventory \ No newline at end of file diff --git a/modules/inventory/origen_inventory/server.lua b/modules/inventory/origen_inventory/server.lua index 11d4cfa..19ec807 100644 --- a/modules/inventory/origen_inventory/server.lua +++ b/modules/inventory/origen_inventory/server.lua @@ -181,3 +181,6 @@ end Inventory.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups) return true, print("Currently runtime shops are not supported in origen_inventory") end + + +return Inventory \ No newline at end of file diff --git a/modules/inventory/ox_inventory/client.lua b/modules/inventory/ox_inventory/client.lua index 1fcbaea..17bbcd6 100644 --- a/modules/inventory/ox_inventory/client.lua +++ b/modules/inventory/ox_inventory/client.lua @@ -52,4 +52,6 @@ end Inventory.OpenShop = function(shopTitle, shopInventory) ox_inventory:openInventory("shop", { type = shopTitle, id = 1 }) -end \ No newline at end of file +end + +return Inventory \ No newline at end of file diff --git a/modules/inventory/ox_inventory/server.lua b/modules/inventory/ox_inventory/server.lua index 02e6cfb..6e3ec45 100644 --- a/modules/inventory/ox_inventory/server.lua +++ b/modules/inventory/ox_inventory/server.lua @@ -182,4 +182,6 @@ end ---@return table Inventory.GetItem = function(src, item, metadata) return ox_inventory:GetItem(src, item, metadata, false) -end \ No newline at end of file +end + +return Inventory \ No newline at end of file diff --git a/modules/inventory/ps-inventory/client.lua b/modules/inventory/ps-inventory/client.lua index b56364d..fa55848 100644 --- a/modules/inventory/ps-inventory/client.lua +++ b/modules/inventory/ps-inventory/client.lua @@ -41,4 +41,6 @@ RegisterNetEvent('community_bridge:client:ps-inventory:openStash', function(id, if source ~= 65535 then return end TriggerEvent('ps-inventory:client:SetCurrentStash', id) TriggerServerEvent('ps-inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots }) -end) \ No newline at end of file +end) + +return Inventory \ No newline at end of file diff --git a/modules/inventory/ps-inventory/server.lua b/modules/inventory/ps-inventory/server.lua index 879312e..2dc105c 100644 --- a/modules/inventory/ps-inventory/server.lua +++ b/modules/inventory/ps-inventory/server.lua @@ -176,4 +176,6 @@ Inventory.CreateShop = function(src, shopTitle, shopInventory, shopCoords, shopG sloth:CreateShop(repackedShopItems) registeredShops[shopTitle] = true return true -end \ No newline at end of file +end + +return Inventory \ No newline at end of file diff --git a/modules/inventory/qb-inventory/client.lua b/modules/inventory/qb-inventory/client.lua index ef831f0..6870be1 100644 --- a/modules/inventory/qb-inventory/client.lua +++ b/modules/inventory/qb-inventory/client.lua @@ -41,4 +41,6 @@ RegisterNetEvent('community_bridge:client:qb-inventory:openStash', function(id, if source ~= 65535 then return end TriggerEvent("inventory:client:SetCurrentStash", id) TriggerServerEvent('inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots }) -end) \ No newline at end of file +end) + +return Inventory \ No newline at end of file diff --git a/modules/inventory/qb-inventory/server.lua b/modules/inventory/qb-inventory/server.lua index adb6418..8df9850 100644 --- a/modules/inventory/qb-inventory/server.lua +++ b/modules/inventory/qb-inventory/server.lua @@ -202,4 +202,6 @@ Inventory.CreateShop = function(src, shopTitle, shopInventory, shopCoords, shopG v1ShopData[shopTitle] = shopData print("QB-INVENTORY: You are using an outdated version of qb-inventory, please update to the latest version. Stuff will still work but you are using litterally the most exploitable inventory in fivem.") end -end \ No newline at end of file +end + +return Inventory \ No newline at end of file diff --git a/modules/inventory/qs-inventory/client.lua b/modules/inventory/qs-inventory/client.lua index 384710a..d309ddd 100644 --- a/modules/inventory/qs-inventory/client.lua +++ b/modules/inventory/qs-inventory/client.lua @@ -74,3 +74,5 @@ end Inventory.OpenStash = function(id) quasar:RegisterStash(id, 50, 50000) end + +return Inventory \ No newline at end of file diff --git a/modules/inventory/qs-inventory/server.lua b/modules/inventory/qs-inventory/server.lua index a792c4f..ddb2d3b 100644 --- a/modules/inventory/qs-inventory/server.lua +++ b/modules/inventory/qs-inventory/server.lua @@ -198,4 +198,6 @@ end -- @param shopGroups table Inventory.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups) return false, print("Currently qs shop is not bridged") -end \ No newline at end of file +end + +return Inventory \ No newline at end of file diff --git a/modules/inventory/tgiann-inventory/client.lua b/modules/inventory/tgiann-inventory/client.lua index a658878..cc230c3 100644 --- a/modules/inventory/tgiann-inventory/client.lua +++ b/modules/inventory/tgiann-inventory/client.lua @@ -70,4 +70,6 @@ end ---@return nil Inventory.OpenStash = function(id) tgiann:OpenInventory('stash', id, { maxweight = 400000, slots = 100 }) -end \ No newline at end of file +end + +return Inventory \ No newline at end of file diff --git a/modules/inventory/tgiann-inventory/server.lua b/modules/inventory/tgiann-inventory/server.lua index 995d989..f72cff6 100644 --- a/modules/inventory/tgiann-inventory/server.lua +++ b/modules/inventory/tgiann-inventory/server.lua @@ -204,4 +204,6 @@ Inventory.GetItem = function(src, item, metadata) item.count = item.amount item.metadata = item.info return item -end \ No newline at end of file +end + +return Inventory \ No newline at end of file diff --git a/modules/managment/Renewed-Banking/server.lua b/modules/managment/Renewed-Banking/server.lua index 3c4bf5b..a4683fb 100644 --- a/modules/managment/Renewed-Banking/server.lua +++ b/modules/managment/Renewed-Banking/server.lua @@ -22,4 +22,6 @@ end ---@return boolean Managment.RemoveAccountMoney = function(account, amount) return exports['Renewed-Banking']:removeAccountMoney(account, amount) -end \ No newline at end of file +end + +return Managment \ No newline at end of file diff --git a/modules/managment/_default/server.lua b/modules/managment/_default/server.lua index 26593d6..80cf953 100644 --- a/modules/managment/_default/server.lua +++ b/modules/managment/_default/server.lua @@ -10,4 +10,6 @@ end Managment.RemoveAccountMoney = function(account, amount) return false, print("The resource you are using does not support this function.") -end \ No newline at end of file +end + +return Managment \ No newline at end of file diff --git a/modules/managment/okokBanking/server.lua b/modules/managment/okokBanking/server.lua index 34582c3..60a32b4 100644 --- a/modules/managment/okokBanking/server.lua +++ b/modules/managment/okokBanking/server.lua @@ -22,4 +22,6 @@ end ---@return boolean Managment.RemoveAccountMoney = function(account, amount) return exports['okokBanking']:RemoveMoney(account, amount) -end \ No newline at end of file +end + +return Managment \ No newline at end of file diff --git a/modules/managment/qb-banking/server.lua b/modules/managment/qb-banking/server.lua index 25d168a..da26df1 100644 --- a/modules/managment/qb-banking/server.lua +++ b/modules/managment/qb-banking/server.lua @@ -22,4 +22,6 @@ end ---@return boolean Managment.RemoveAccountMoney = function(account, amount) return exports['qb-banking']:RemoveMoney(account, amount) -end \ No newline at end of file +end + +return Managment \ No newline at end of file diff --git a/modules/math/computation.lua b/modules/math/computation.lua index 1e6ef28..f007806 100644 --- a/modules/math/computation.lua +++ b/modules/math/computation.lua @@ -66,3 +66,5 @@ end function Math.Map(value, inMin, inMax, outMin, outMax) return (value - inMin) / (inMax - inMin) * (outMax - outMin) + outMin end + +return Math \ No newline at end of file diff --git a/modules/menu/client.lua b/modules/menu/client.lua index dbb41f9..26b2713 100644 --- a/modules/menu/client.lua +++ b/modules/menu/client.lua @@ -23,6 +23,7 @@ RegisterNetEvent('community_bridge:client:MenuCallback', function(_args) onSelect(args) end) +return Menu --[[ diff --git a/modules/notify/_default/client.lua b/modules/notify/_default/client.lua index c016d61..72a5c40 100644 --- a/modules/notify/_default/client.lua +++ b/modules/notify/_default/client.lua @@ -35,4 +35,6 @@ end ---@diagnostic disable-next-line: duplicate-set-field Notify.ShowHelpText = function(message, position) return HelpText.ShowHelpText(message, position) -end \ No newline at end of file +end + +return Notify \ No newline at end of file diff --git a/modules/notify/_default/server.lua b/modules/notify/_default/server.lua index a299eae..a6f5d41 100644 --- a/modules/notify/_default/server.lua +++ b/modules/notify/_default/server.lua @@ -30,4 +30,6 @@ end ---@diagnostic disable-next-line: duplicate-set-field Notify.HideHelpText = function(src) return HelpText.HideHelpText(src) -end \ No newline at end of file +end + +return Notify \ No newline at end of file diff --git a/modules/notify/mythic_notify/client.lua b/modules/notify/mythic_notify/client.lua index 378ce39..b276ef5 100644 --- a/modules/notify/mythic_notify/client.lua +++ b/modules/notify/mythic_notify/client.lua @@ -17,4 +17,6 @@ end Notify.SendNotify = function(message, _type, time) time = time or 3000 return exports['mythic_notify']:SendAlert('inform', message, time) -end \ No newline at end of file +end + +return Notify \ No newline at end of file diff --git a/modules/notify/okokNotify/client.lua b/modules/notify/okokNotify/client.lua index 78c28a5..6375bab 100644 --- a/modules/notify/okokNotify/client.lua +++ b/modules/notify/okokNotify/client.lua @@ -17,4 +17,6 @@ end Notify.SendNotify = function(message, _type, time) time = time or 3000 return exports['okokNotify']:Alert('Notification', message, time, _type, false) -end \ No newline at end of file +end + +return Notify \ No newline at end of file diff --git a/modules/notify/ox_lib/client.lua b/modules/notify/ox_lib/client.lua index fe28910..037dc95 100644 --- a/modules/notify/ox_lib/client.lua +++ b/modules/notify/ox_lib/client.lua @@ -18,4 +18,6 @@ end Notify.SendNotify = function(message, _type, time) time = time or 3000 return exports.ox_lib:notify({ description = message, type = _type, position = 'center-left' }) -end \ No newline at end of file +end + +return Notify \ No newline at end of file diff --git a/modules/notify/pNotify/client.lua b/modules/notify/pNotify/client.lua index e5ee328..7cbf356 100644 --- a/modules/notify/pNotify/client.lua +++ b/modules/notify/pNotify/client.lua @@ -17,4 +17,6 @@ end Notify.SendNotify = function(message, _type, time) time = time or 3000 return exports['pNotify']:SendNotification({ text = message, type = _type, timeout = time, layout = 'centerRight' }) -end \ No newline at end of file +end + +return Notify \ No newline at end of file diff --git a/modules/notify/r_notify/client.lua b/modules/notify/r_notify/client.lua index a3dc5b6..4b12e9e 100644 --- a/modules/notify/r_notify/client.lua +++ b/modules/notify/r_notify/client.lua @@ -17,4 +17,6 @@ end Notify.SendNotify = function(message, _type, time) time = time or 3000 return exports.r_notify:notify({title = 'Notification', content = message, type = _type, icon = "fas fa-check", duration = time, position = 'top-right', sound = false}) -end \ No newline at end of file +end + +return Notify \ No newline at end of file diff --git a/modules/notify/t-notify/client.lua b/modules/notify/t-notify/client.lua index f11e863..0dcc4c4 100644 --- a/modules/notify/t-notify/client.lua +++ b/modules/notify/t-notify/client.lua @@ -17,4 +17,6 @@ end Notify.SendNotify = function(message, _type, time) time = time or 3000 return exports['t-notify']:Alert({ style = 'info', message = message, duration = time, }) -end \ No newline at end of file +end + +return Notify \ No newline at end of file diff --git a/modules/notify/wasabi_notify/client.lua b/modules/notify/wasabi_notify/client.lua index 52998c8..f4d83f5 100644 --- a/modules/notify/wasabi_notify/client.lua +++ b/modules/notify/wasabi_notify/client.lua @@ -17,4 +17,6 @@ end Notify.SendNotify = function(message, _type, time) time = time or 3000 return exports.wasabi_notify:notify(_type, message, time, _type) -end \ No newline at end of file +end + +return Notify \ No newline at end of file diff --git a/modules/phone/_default/client.lua b/modules/phone/_default/client.lua index 3337b0c..b05bde5 100644 --- a/modules/phone/_default/client.lua +++ b/modules/phone/_default/client.lua @@ -3,4 +3,6 @@ Phone = Phone or {} ---@diagnostic disable-next-line: duplicate-set-field Phone.SendEmail = function(email, title, message) return false, Print.Error('There Is No Phone Bridged.') -end \ No newline at end of file +end + +return Phone \ No newline at end of file diff --git a/modules/phone/_default/server.lua b/modules/phone/_default/server.lua index 51b2402..899d30e 100644 --- a/modules/phone/_default/server.lua +++ b/modules/phone/_default/server.lua @@ -8,4 +8,6 @@ end ---@diagnostic disable-next-line: duplicate-set-field Phone.SendEmail = function(src, email, title, message) return false, Print.Error('There Is No Phone Bridged.') -end \ No newline at end of file +end + +return Phone \ No newline at end of file diff --git a/modules/phone/gksphone/client.lua b/modules/phone/gksphone/client.lua index 7bae1cb..ead89bb 100644 --- a/modules/phone/gksphone/client.lua +++ b/modules/phone/gksphone/client.lua @@ -12,4 +12,6 @@ Phone = Phone or {} ---@diagnostic disable-next-line: duplicate-set-field Phone.SendEmail = function(email, title, message) return exports["gksphone"]:SendNewMail({ sender = email, image = '/html/static/img/icons/mail.png', subject = title, message = message }) -end \ No newline at end of file +end + +return Phone \ No newline at end of file diff --git a/modules/phone/gksphone/server.lua b/modules/phone/gksphone/server.lua index 828696b..8d72d62 100644 --- a/modules/phone/gksphone/server.lua +++ b/modules/phone/gksphone/server.lua @@ -26,4 +26,6 @@ Phone.SendEmail = function(src, email, title, message) data.message = message exports["gksphone"]:SendNewMail(src, data) return true -end \ No newline at end of file +end + +return Phone \ No newline at end of file diff --git a/modules/phone/lb-phone/client.lua b/modules/phone/lb-phone/client.lua index 2964856..450f364 100644 --- a/modules/phone/lb-phone/client.lua +++ b/modules/phone/lb-phone/client.lua @@ -11,4 +11,6 @@ Phone = Phone or {} ---@diagnostic disable-next-line: duplicate-set-field Phone.SendEmail = function(email, title, message) TriggerServerEvent('community_bridge:Server:genericEmail', {email = email, title = title, message = message}) -end \ No newline at end of file +end + +return Phone \ No newline at end of file diff --git a/modules/phone/lb-phone/server.lua b/modules/phone/lb-phone/server.lua index 748741f..6545f23 100644 --- a/modules/phone/lb-phone/server.lua +++ b/modules/phone/lb-phone/server.lua @@ -33,4 +33,6 @@ RegisterNetEvent('community_bridge:Server:genericEmail', function(data) local src = source Prints.Debug('community_bridge:Server:genericEmail Hit') return Phone.SendEmail(src, data.email, data.title, data.message) -end) \ No newline at end of file +end) + +return Phone \ No newline at end of file diff --git a/modules/phone/okokPhone/client.lua b/modules/phone/okokPhone/client.lua index 623b01a..5fd5def 100644 --- a/modules/phone/okokPhone/client.lua +++ b/modules/phone/okokPhone/client.lua @@ -14,3 +14,5 @@ Phone.SendEmail = function(email, title, message) local success = lib.callback.await('community_bridge:Callback:okokPhone:sendEmail', false, email, title, message) --[[ @as boolean ]] return success end + +return Phone \ No newline at end of file diff --git a/modules/phone/okokPhone/server.lua b/modules/phone/okokPhone/server.lua index 67643cb..4897937 100644 --- a/modules/phone/okokPhone/server.lua +++ b/modules/phone/okokPhone/server.lua @@ -53,3 +53,5 @@ end lib.callback.registry('community_bridge:Callback:okokPhone:sendEmail', function(src, email, title, message) return Phone.SendEmail(src, email, title, message) end) + +return Phone \ No newline at end of file diff --git a/modules/phone/qs-smartphone/client.lua b/modules/phone/qs-smartphone/client.lua index 2f797e6..f0466a3 100644 --- a/modules/phone/qs-smartphone/client.lua +++ b/modules/phone/qs-smartphone/client.lua @@ -15,4 +15,6 @@ end RegisterNetEvent('community_bridge:Server:genericEmail', function(data) TriggerServerEvent('qs-smartphone:server:sendNewMail', { sender = data.email, subject = data.title, message = data.message, button = {} }) -end) \ No newline at end of file +end) + +return Phone \ No newline at end of file diff --git a/modules/phone/qs-smartphone/server.lua b/modules/phone/qs-smartphone/server.lua index 167bacc..792674a 100644 --- a/modules/phone/qs-smartphone/server.lua +++ b/modules/phone/qs-smartphone/server.lua @@ -20,4 +20,6 @@ end Phone.SendEmail = function(src, email, title, message) TriggerClientEvent('community_bridge:Server:genericEmail', src, { sender = email, subject = title, message = message, button = {} }) return true -end \ No newline at end of file +end + +return Phone \ No newline at end of file diff --git a/modules/progressbar/ox_lib/client.lua b/modules/progressbar/ox_lib/client.lua index 080e067..c7bdb21 100644 --- a/modules/progressbar/ox_lib/client.lua +++ b/modules/progressbar/ox_lib/client.lua @@ -62,6 +62,8 @@ function ProgressBar.Open(options, cb, isQBInput) return success end +return ProgressBar + --[[ RegisterCommand("progressbar", function() ProgressBar.Open({ diff --git a/modules/progressbar/qb-progressbar/client.lua b/modules/progressbar/qb-progressbar/client.lua index 73dd034..4908ff1 100644 --- a/modules/progressbar/qb-progressbar/client.lua +++ b/modules/progressbar/qb-progressbar/client.lua @@ -60,6 +60,8 @@ function ProgressBar.Open(options, cb, qbFormat) return Citizen.Await(prom) end +return ProgressBar + -- Example usage: --[[ diff --git a/modules/shops/_default/client.lua b/modules/shops/_default/client.lua index 02e774d..c8512db 100644 --- a/modules/shops/_default/client.lua +++ b/modules/shops/_default/client.lua @@ -76,3 +76,5 @@ Shops.OpenShop = function(title, shopData) end Menu.Open({ id = generatedID, title = title, options = buildMenu }, false) end + +return Shops \ No newline at end of file diff --git a/modules/shops/_default/server.lua b/modules/shops/_default/server.lua index 09a84fa..a4ac7b4 100644 --- a/modules/shops/_default/server.lua +++ b/modules/shops/_default/server.lua @@ -60,4 +60,6 @@ RegisterNetEvent("community_bridge:completeCheckout", function(shopName, item, a if not shopName and not item and not paymentType then return end if not paymentType == "money" or not paymentType == "bank" then return end Shops.CompleteCheckout(src, shopName, item, amount, paymentType) -end) \ No newline at end of file +end) + +return Shops \ No newline at end of file diff --git a/modules/skills/OT_skills/client.lua b/modules/skills/OT_skills/client.lua index cac7757..4d0e9f1 100644 --- a/modules/skills/OT_skills/client.lua +++ b/modules/skills/OT_skills/client.lua @@ -12,4 +12,6 @@ end Skills.GetSkillLevel = function(skillName) local skillData = exports.OT_skills:getSkill(skillName) return skillData.level or 0 -end \ No newline at end of file +end + +return Skills \ No newline at end of file diff --git a/modules/skills/OT_skills/server.lua b/modules/skills/OT_skills/server.lua index c5be3f1..7685012 100644 --- a/modules/skills/OT_skills/server.lua +++ b/modules/skills/OT_skills/server.lua @@ -26,4 +26,6 @@ Skills.RemoveXp = function(src, skillName, amount) if not skillData then return false, print("Skill not found") end exports.OT_skills:removeXP(src, skillName, amount) return true -end \ No newline at end of file +end + +return Skills \ No newline at end of file diff --git a/modules/skills/_default/client.lua b/modules/skills/_default/client.lua index 9b26b0a..74f9d3e 100644 --- a/modules/skills/_default/client.lua +++ b/modules/skills/_default/client.lua @@ -12,4 +12,6 @@ end ---@diagnostic disable-next-line: duplicate-set-field Skills.GetSkillLevel = function(skillName) return 0, warnUser() -end \ No newline at end of file +end + +return Skills \ No newline at end of file diff --git a/modules/skills/_default/server.lua b/modules/skills/_default/server.lua index a5ae846..e1b2302 100644 --- a/modules/skills/_default/server.lua +++ b/modules/skills/_default/server.lua @@ -22,4 +22,6 @@ end ---@diagnostic disable-next-line: duplicate-set-field Skills.RemoveXp = function(src, skillName, amount) return false, warnUser() -end \ No newline at end of file +end + +return Skills \ No newline at end of file diff --git a/modules/skills/evolent_skills/client.lua b/modules/skills/evolent_skills/client.lua index 7ee1e0f..745b5a8 100644 --- a/modules/skills/evolent_skills/client.lua +++ b/modules/skills/evolent_skills/client.lua @@ -12,4 +12,6 @@ end Skills.GetSkillLevel = function(skillName) local skillData = exports.evolent_skills:getSkillLevel(skillName) return skillData or 0 -end \ No newline at end of file +end + +return Skills \ No newline at end of file diff --git a/modules/skills/evolent_skills/server.lua b/modules/skills/evolent_skills/server.lua index 05f960a..935a184 100644 --- a/modules/skills/evolent_skills/server.lua +++ b/modules/skills/evolent_skills/server.lua @@ -28,4 +28,6 @@ Skills.RemoveXp = function(src, skillName, amount) if not skillData then return false, print("Skill not found") end exports.evolent_skills:removeXp(src, skillName, amount) return true -end \ No newline at end of file +end + +return Skills \ No newline at end of file diff --git a/modules/skills/pickle_xp/client.lua b/modules/skills/pickle_xp/client.lua index c21f010..4692acc 100644 --- a/modules/skills/pickle_xp/client.lua +++ b/modules/skills/pickle_xp/client.lua @@ -12,4 +12,6 @@ end Skills.GetSkillLevel = function(skillName) local skillData = exports.OT_skills:GetLevel(skillName) return skillData or 0 -end \ No newline at end of file +end + +return Skills \ No newline at end of file diff --git a/modules/skills/pickle_xp/server.lua b/modules/skills/pickle_xp/server.lua index b7234f3..82ef781 100644 --- a/modules/skills/pickle_xp/server.lua +++ b/modules/skills/pickle_xp/server.lua @@ -26,4 +26,6 @@ Skills.RemoveXp = function(src, skillName, amount) if not skillData then return false, print("Skill not found") end exports.pickle_xp:RemovePlayerXP(src, skillName, amount) return true -end \ No newline at end of file +end + +return Skills \ No newline at end of file diff --git a/modules/target/_default/client.lua b/modules/target/_default/client.lua index 710c524..37581d7 100644 --- a/modules/target/_default/client.lua +++ b/modules/target/_default/client.lua @@ -135,4 +135,6 @@ end Target.RemoveZone = function(name) warnUser() -end \ No newline at end of file +end + +return Target \ No newline at end of file diff --git a/modules/target/ox_target/client.lua b/modules/target/ox_target/client.lua index fb06fd0..d65b7e6 100644 --- a/modules/target/ox_target/client.lua +++ b/modules/target/ox_target/client.lua @@ -157,3 +157,5 @@ AddEventHandler('onResourceStop', function(resource) end targetZones = {} end) + +return Target \ No newline at end of file diff --git a/modules/target/qb-target/client.lua b/modules/target/qb-target/client.lua index dccdb64..516b4e8 100644 --- a/modules/target/qb-target/client.lua +++ b/modules/target/qb-target/client.lua @@ -170,4 +170,6 @@ AddEventHandler('onResourceStop', function(resource) end end targetZones = {} -end) \ No newline at end of file +end) + +return Target \ No newline at end of file diff --git a/modules/target/sleepless_interact/client.lua b/modules/target/sleepless_interact/client.lua index c3cc9f0..0e924b2 100644 --- a/modules/target/sleepless_interact/client.lua +++ b/modules/target/sleepless_interact/client.lua @@ -139,3 +139,5 @@ AddEventHandler('onResourceStop', function(resource) targetZones = {} end end) + +return Target \ No newline at end of file diff --git a/modules/vehicleKey/F_RealCarKeysSystem/client/client.lua b/modules/vehicleKey/F_RealCarKeysSystem/client/client.lua index 6013011..5ba0f96 100644 --- a/modules/vehicleKey/F_RealCarKeysSystem/client/client.lua +++ b/modules/vehicleKey/F_RealCarKeysSystem/client/client.lua @@ -12,3 +12,5 @@ end VehicleKey.RemoveKeys = function(vehicle, plate) return true end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/MrNewbVehicleKeys/client/client.lua b/modules/vehicleKey/MrNewbVehicleKeys/client/client.lua index 7cf6df9..2790419 100644 --- a/modules/vehicleKey/MrNewbVehicleKeys/client/client.lua +++ b/modules/vehicleKey/MrNewbVehicleKeys/client/client.lua @@ -12,4 +12,6 @@ end VehicleKey.RemoveKeys = function(vehicle, plate) if not plate then return false end return exports.MrNewbVehicleKeys:RemoveKeysByPlate(plate) -end \ No newline at end of file +end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/Renewed-Vehiclekeys/client/client.lua b/modules/vehicleKey/Renewed-Vehiclekeys/client/client.lua index 4344bb7..baf44c4 100644 --- a/modules/vehicleKey/Renewed-Vehiclekeys/client/client.lua +++ b/modules/vehicleKey/Renewed-Vehiclekeys/client/client.lua @@ -12,4 +12,6 @@ end VehicleKey.RemoveKeys = function(vehicle, plate) if not plate then return false end return exports['Renewed-Vehiclekeys']:removeKey(plate) -end \ No newline at end of file +end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/_default/client/client.lua b/modules/vehicleKey/_default/client/client.lua index df07dc4..283a143 100644 --- a/modules/vehicleKey/_default/client/client.lua +++ b/modules/vehicleKey/_default/client/client.lua @@ -13,4 +13,6 @@ end ---@return boolean | nil VehicleKey.RemoveKeys = function(vehicle, plate) return true, Prints.Error("There Is No Vehicle Key System Installed") -end \ No newline at end of file +end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/cd_garage/client/client.lua b/modules/vehicleKey/cd_garage/client/client.lua index 936e1d0..7250703 100644 --- a/modules/vehicleKey/cd_garage/client/client.lua +++ b/modules/vehicleKey/cd_garage/client/client.lua @@ -11,4 +11,6 @@ end VehicleKey.RemoveKeys = function(vehicle, plate) return true -end \ No newline at end of file +end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/jacksam/client.lua b/modules/vehicleKey/jacksam/client.lua index 2b2f643..4259aa4 100644 --- a/modules/vehicleKey/jacksam/client.lua +++ b/modules/vehicleKey/jacksam/client.lua @@ -13,4 +13,6 @@ end VehicleKey.RemoveKeys = function(vehicle, plate) if not plate then return false end return TriggerServerEvent("vehicles_keys:selfRemoveKeys", plate) -end \ No newline at end of file +end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/mk_vehiclekeys/client/client.lua b/modules/vehicleKey/mk_vehiclekeys/client/client.lua index c39def4..58227de 100644 --- a/modules/vehicleKey/mk_vehiclekeys/client/client.lua +++ b/modules/vehicleKey/mk_vehiclekeys/client/client.lua @@ -12,4 +12,6 @@ end VehicleKey.RemoveKeys = function(vehicle, plate) if not vehicle and not DoesEntityExist(vehicle) then return false end return exports["mk_vehiclekeys"]:RemoveKey(vehicle) -end \ No newline at end of file +end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/mono_carkeys/client/client.lua b/modules/vehicleKey/mono_carkeys/client/client.lua index 03790d3..793bd5a 100644 --- a/modules/vehicleKey/mono_carkeys/client/client.lua +++ b/modules/vehicleKey/mono_carkeys/client/client.lua @@ -12,3 +12,5 @@ VehicleKey.RemoveKeys = function(vehicle, plate) if not plate then return false end TriggerServerEvent('mono_carkeys:DeleteKey', 1, plate) end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/okokGarage/client/client.lua b/modules/vehicleKey/okokGarage/client/client.lua index 3d62e22..27dba9a 100644 --- a/modules/vehicleKey/okokGarage/client/client.lua +++ b/modules/vehicleKey/okokGarage/client/client.lua @@ -11,4 +11,6 @@ end VehicleKey.RemoveKeys = function(vehicle, plate) return true -end \ No newline at end of file +end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/qb-vehiclekeys/client/client.lua b/modules/vehicleKey/qb-vehiclekeys/client/client.lua index 3ab78a2..f553cea 100644 --- a/modules/vehicleKey/qb-vehiclekeys/client/client.lua +++ b/modules/vehicleKey/qb-vehiclekeys/client/client.lua @@ -12,4 +12,6 @@ end VehicleKey.RemoveKeys = function(vehicle, plate) if not plate then return false end TriggerEvent("qb-vehiclekeys:client:RemoveKeys", plate) -end \ No newline at end of file +end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/qbx_vehiclekeys/client/client.lua b/modules/vehicleKey/qbx_vehiclekeys/client/client.lua index 8e554a8..a815939 100644 --- a/modules/vehicleKey/qbx_vehiclekeys/client/client.lua +++ b/modules/vehicleKey/qbx_vehiclekeys/client/client.lua @@ -11,4 +11,6 @@ end VehicleKey.RemoveKeys = function(vehicle, plate) return true -end \ No newline at end of file +end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/qs-vehiclekeys/client/client.lua b/modules/vehicleKey/qs-vehiclekeys/client/client.lua index d9a4423..6f8c3e0 100644 --- a/modules/vehicleKey/qs-vehiclekeys/client/client.lua +++ b/modules/vehicleKey/qs-vehiclekeys/client/client.lua @@ -16,4 +16,6 @@ VehicleKey.RemoveKeys = function(vehicle, plate) local model = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle)) local verifiedPlate = GetVehicleNumberPlateText(vehicle) return exports['qs-vehiclekeys']:RemoveKeys(verifiedPlate, model) -end \ No newline at end of file +end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/t1ger_keys/client/client.lua b/modules/vehicleKey/t1ger_keys/client/client.lua index 23dd224..e2107b4 100644 --- a/modules/vehicleKey/t1ger_keys/client/client.lua +++ b/modules/vehicleKey/t1ger_keys/client/client.lua @@ -12,4 +12,6 @@ end VehicleKey.RemoveKeys = function(vehicle, plate) -end \ No newline at end of file +end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/wasabi_carlock/client/client.lua b/modules/vehicleKey/wasabi_carlock/client/client.lua index 8f03b0f..a66377a 100644 --- a/modules/vehicleKey/wasabi_carlock/client/client.lua +++ b/modules/vehicleKey/wasabi_carlock/client/client.lua @@ -12,4 +12,6 @@ end VehicleKey.RemoveKeys = function(vehicle, plate) if not plate and vehicle then plate = GetVehicleNumberPlateText(vehicle) end exports.wasabi_carlock:RemoveKey(plate) -end \ No newline at end of file +end + +return VehicleKey \ No newline at end of file diff --git a/modules/version/server/VersionChecker.lua b/modules/version/server/VersionChecker.lua index 6d5fe2a..35ea71a 100644 --- a/modules/version/server/VersionChecker.lua +++ b/modules/version/server/VersionChecker.lua @@ -31,4 +31,6 @@ end AddEventHandler('onResourceStart', function(resourceName) if GetCurrentResourceName() ~= resourceName then return end Version.VersionChecker("The-Order-Of-The-Sacred-Framework/community_bridge") -end) \ No newline at end of file +end) + +return Version \ No newline at end of file diff --git a/modules/weather/_default/client.lua b/modules/weather/_default/client.lua index 93a508a..095bf46 100644 --- a/modules/weather/_default/client.lua +++ b/modules/weather/_default/client.lua @@ -5,4 +5,6 @@ Weather = Weather or {} ---@return nil Weather.ToggleSync = function(toggle) -end \ No newline at end of file +end + +return Weather \ No newline at end of file diff --git a/modules/weather/cd_easytime/client.lua b/modules/weather/cd_easytime/client.lua index e3740dc..7808160 100644 --- a/modules/weather/cd_easytime/client.lua +++ b/modules/weather/cd_easytime/client.lua @@ -5,4 +5,6 @@ Weather = Weather or {} ---@param toggle boolean Weather.ToggleSync = function(toggle) TriggerEvent('cd_easytime:PauseSync', toggle) -end \ No newline at end of file +end + +return Weather \ No newline at end of file diff --git a/modules/weather/qb-weathersync/client/client.lua b/modules/weather/qb-weathersync/client/client.lua index d6eb030..df628c7 100644 --- a/modules/weather/qb-weathersync/client/client.lua +++ b/modules/weather/qb-weathersync/client/client.lua @@ -9,4 +9,6 @@ Weather.ToggleSync = function(toggle) else TriggerEvent("qb-weathersync:client:DisableSync") end -end \ No newline at end of file +end + +return Weather \ No newline at end of file diff --git a/modules/weather/renewed-weathersync/client/client.lua b/modules/weather/renewed-weathersync/client/client.lua index 66bb585..d531bee 100644 --- a/modules/weather/renewed-weathersync/client/client.lua +++ b/modules/weather/renewed-weathersync/client/client.lua @@ -5,4 +5,6 @@ Weather = Weather or {} ---@param toggle boolean Weather.ToggleSync = function(toggle) LocalPlayer.state.syncWeather = toggle -end \ No newline at end of file +end + +return Weather \ No newline at end of file From e6feb5cde36f8ce5b364d35c53bf6cf7b81bc4d7 Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Fri, 9 May 2025 23:05:44 -0500 Subject: [PATCH 15/38] marker and a fixiewixie oppsie doopsies --- init.lua | 3 ++- lib/markers/server/server.lua | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 1c6163b..9ecdcc6 100644 --- a/init.lua +++ b/init.lua @@ -55,6 +55,7 @@ Bridge.RegisterModule("Phone", Phone) Bridge.RegisterModule("Dispatch", Dispatch) Bridge.RegisterModule("Shops", Shops) Bridge.RegisterModule("Housing", Housing) +Bridge.RegisterModule("Version", Version) --lib -- Bridge.RegisterModule("Tables", cLib.Tables) @@ -86,7 +87,7 @@ end) -- ▄▀▀ ██▀ █▀▄ █ █ ██▀ █▀▄ -- ▄█▀ █▄▄ █▀▄ ▀▄▀ █▄▄ █▀▄ if not IsDuplicityVersion() then goto client end - +Bridge.RegisterModule('Version', Version) -- ▄▀▀ █ █ ██▀ █▄ █ ▀█▀ -- ▀▄▄ █▄▄ █ █▄▄ █ ▀█ █ diff --git a/lib/markers/server/server.lua b/lib/markers/server/server.lua index 5a31e9f..c281d61 100644 --- a/lib/markers/server/server.lua +++ b/lib/markers/server/server.lua @@ -22,7 +22,7 @@ function Marker.Create(data) return end - local _id = id.CreateUniqueId(Created) + local _id = data.id or id.CreateUniqueId(Created) local data = { id = _id, position = data.position, From 498f8670eea7006f88fb9f01f6c7422852e64ceb Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Sun, 11 May 2025 00:47:33 -0500 Subject: [PATCH 16/38] Bazinga Scenes I bring you bazinga scenes. These are regular cutscenes but here now. Okay good bye --- lib/cutscenes/client/cutscene.lua | 348 ++++++++++++++++++++++++++ lib/entities/client/client_entity.lua | 20 +- lib/init.lua | 4 +- 3 files changed, 360 insertions(+), 12 deletions(-) create mode 100644 lib/cutscenes/client/cutscene.lua diff --git a/lib/cutscenes/client/cutscene.lua b/lib/cutscenes/client/cutscene.lua new file mode 100644 index 0000000..5e5bc7e --- /dev/null +++ b/lib/cutscenes/client/cutscene.lua @@ -0,0 +1,348 @@ +Cutscenes = Cutscenes or {} +Cutscene = Cutscene or {} +Cutscene.done = true + +local names = { + {male = 'MP_1'}, + {male = 'MP_2'}, + {male = 'MP_3'}, + {male = 'MP_4'}, + {male = 'MP_Male_Character', female = 'MP_Female_Character'}, + {male = 'MP_Male_Character_1', female = 'MP_Female_Character_1'}, + {male = 'MP_Male_Character_2', female = 'MP_Female_Character_2'}, + {male = 'MP_Male_Character_3', female = 'MP_Female_Character_3'}, + {male = 'MP_Male_Character_4', female = 'MP_Female_Character_4'}, + {male = 'MP_Plane_Passenger_1'}, + {male = 'MP_Plane_Passenger_2'}, + {male = 'MP_Plane_Passenger_3'}, + {male = 'MP_Plane_Passenger_4'}, + {male = 'MP_Plane_Passenger_5'}, + {male = 'MP_Plane_Passenger_6'}, + {male = 'MP_Plane_Passenger_7'}, + {male = 'MP_Plane_Passenger_8'}, + {male = 'MP_Plane_Passenger_9'}, +} + +function Cutscene.GetTags(cutscene) + if not Cutscene.Load(cutscene) then return end + StartCutscene(0) + Wait(1000) + local tags = {} + for k, tag in pairs(names) do + if DoesCutsceneEntityExist(tag.male, 0) or DoesCutsceneEntityExist(tag.female, 0) then + table.insert(tags, tag) + end + end + StopCutsceneImmediately() + Wait(2000) + return tags +end + +function Cutscene.Load(cutscene) + assert(cutscene, "Cutscene.Load called without a cutscene name.") + if IsPedMale(PlayerPedId()) then + RequestCutsceneWithPlaybackList(cutscene, 31, 8) + else + RequestCutsceneWithPlaybackList(cutscene, 103, 8) + end + local timeout = GetGameTimer() + 10000 + while not (HasCutsceneLoaded()) and GetGameTimer() < timeout do + Wait(0) + end + if not HasCutsceneLoaded() then + print("Cutscene failed to load: ", cutscene) + return false + end + + return true +end + +function Cutscene.SavePedOutfit(ped) + local outfitData = {} + local componentsToSave = { + -- Components + { name = "head", id = 0, type = "drawable" }, + { name = "beard", id = 1, type = "drawable" }, + { name = "hair", id = 2, type = "drawable" }, + { name = "arms", id = 3, type = "drawable" }, + { name = "pants", id = 4, type = "drawable" }, + { name = "parachute", id = 5, type = "drawable" }, + { name = "feet", id = 6, type = "drawable" }, + { name = "accessories", id = 7, type = "drawable" }, + { name = "undershirt", id = 8, type = "drawable" }, + { name = "vest", id = 9, type = "drawable" }, + { name = "decals", id = 10, type = "drawable" }, + { name = "jacket", id = 11, type = "drawable" }, + + -- Props + { name = "hat", id = 0, type = "prop" }, + { name = "glasses", id = 1, type = "prop" }, + { name = "ears", id = 2, type = "prop" }, + { name = "watch", id = 3, type = "prop" }, + { name = "bracelet", id = 4, type = "prop" }, + { name = "misc", id = 5, type = "prop" }, + { name = "left_wrist", id = 6, type = "prop" }, + { name = "right_wrist", id = 7, type = "prop" }, + { name = "prop8", id = 8, type = "prop" }, + { name = "prop9", id = 9, type = "prop" }, + } + + for _, component in ipairs(componentsToSave) do + if component.type == "drawable" then + local drawable = GetPedDrawableVariation(ped, component.id) + local texture = GetPedTextureVariation(ped, component.id) + local palette = GetPedPaletteVariation(ped, component.id) + outfitData[component.name] = { + id = component.id, + type = component.type, + drawable = drawable, + texture = texture, + palette = palette, + } + elseif component.type == "prop" then + local propIndex = GetPedPropIndex(ped, component.id) + local propTexture = GetPedPropTextureIndex(ped, component.id) + outfitData[component.name] = { + id = component.id, + type = component.type, + propIndex = propIndex, + propTexture = propTexture, + } + end + end + + return outfitData +end + +function Cutscene.ApplyPedOutfit(ped, outfitData) + if not outfitData or type(outfitData) ~= "table" then + print("ApplyPedOutfit: Invalid outfitData provided.") + return + end + + for componentName, data in pairs(outfitData) do + if data.type == "drawable" then + -- Ensure all values are present before applying + local drawable = data.drawable or 0 + local texture = data.texture or 0 + local palette = data.palette or 0 + SetPedComponentVariation(ped, data.id, drawable, texture, palette) + elseif data.type == "prop" then + -- Clear prop if it's marked as not present (-1 index) + if data.propIndex == -1 or data.propIndex == nil then + ClearPedProp(ped, data.id) + else + local propTexture = data.propTexture or 0 + SetPedPropIndex(ped, data.id, data.propIndex, propTexture, true) + end + end + end +end + +function Cutscene.Create(cutscene, coords, srcs) + local lastCoords = coords or GetEntityCoords(PlayerPedId()) + DoScreenFadeOut(0) + local tagsFromCutscene = Cutscene.GetTags(cutscene) + + if not Cutscene.Load(cutscene) then + print("Cutscene.Create: Failed to load cutscene", cutscene) + DoScreenFadeIn(0) + return false + end + + srcs = srcs or {} + local clothes = {} + + local localped = PlayerPedId() + + local playersToProcess = {} + table.insert(playersToProcess, { ped = localped, identifier = "localplayer", coords = lastCoords}) + for i, src_raw in ipairs(srcs) do + if type(src_raw) == 'number' then + if src_raw and not DoesEntityExist(src_raw) then + local playerPed = GetPlayerPed(GetPlayerFromServerId(src_raw)) -- Assuming GetPlayerPed takes server ID + if DoesEntityExist(playerPed) then + local ped = ClonePed(playerPed, false, false, true) + table.insert(playersToProcess, { ped = ped, identifier = "player" }) + else + print("Cutscene.Create: Ped for src " .. src_raw .. " does not exist.") + end + else + table.insert(playersToProcess, { ped = src_raw, identifier = "user"}) --developer passed a ped + end + elseif type(src_raw) == 'string' then + -- impliment creating a ped by model name + local model = GetHashKey(src_raw) + RequestModel(model) + local timeout = GetGameTimer() + 10000 + while not HasModelLoaded(model) and GetGameTimer() < timeout do + Wait(0) + end + if not HasModelLoaded(model) then + print("Cutscene.Create: Failed to load model " .. src_raw) + return false + end + local pos = GetEntityCoords(localped) + local ped = CreatePed(0, model, pos.x, pos.y, pos.z, 0.0, true, false) + + if ped and DoesEntityExist(ped) then + table.insert(playersToProcess, { ped = ped, identifier = 'script' }) + else + print("Cutscene.Create: Failed to create ped for src " .. src_raw) + end + elseif type(src_raw) == 'boolean' and src_raw then + print("Cutscene.Create: src_raw is a boolean, creating random ped currently not implimented.") + -- local pos = GetEntityCoords(localped) + -- local ped = CreateRandomPed(pos.x, pos.y, pos.z) + + -- if ped and DoesEntityExist(ped)then + -- table.insert(playersToProcess, { ped = ped, identifier = 'script' }) + -- else + -- print("Cutscene.Create: Failed to create random ped for src " ) + -- end + end + end + + local availableTags = {} -- Create a mutable copy of tags + for _, tagName in ipairs(tagsFromCutscene or {}) do + table.insert(availableTags, tagName) + end + + local usedTags = {} + local cleanupTags = {} + + for _, playerData in ipairs(playersToProcess) do + local currentPed = playerData.ped + local isPedMale = IsPedMale(currentPed) + local tagTable = availableTags[1] + if not tagTable then + print("Cutscene.Create: No available tags for player", playerData.identifier) + break + end + + local tag = not isPedMale and tagTable.female or tagTable.male + local unusedTag = nil + if isPedMale and tagTable.female then + unusedTag = isPedMale and tagTable.female or tagTable.male + end + SetCutsceneEntityStreamingFlags(tag, 0, 1) + RegisterEntityForCutscene(currentPed, tag, 0, GetEntityModel(currentPed), 64) + SetCutscenePedComponentVariationFromPed(tag, currentPed, 0) + clothes[tag] = { clothing = Cutscene.SavePedOutfit(currentPed), ped = currentPed } + table.insert(usedTags, tag) -- Track used tags + table.insert(cleanupTags, unusedTag) -- Track tags to be cleaned up later + table.remove(availableTags, 1) -- Remove used tag + end + for _, tag in ipairs(cleanupTags) do + local ped = RegisterEntityForCutscene(0, tag, 3, 0, 64) + NetworkSetEntityInvisibleToNetwork(ped, true) + end + + for _, tag in ipairs(availableTags) do + local ped1 = RegisterEntityForCutscene(0, tag.male, 3, 0, 64) + NetworkSetEntityInvisibleToNetwork(ped1, true) + local ped2 = RegisterEntityForCutscene(0, tag.female, 3, 0, 64) + NetworkSetEntityInvisibleToNetwork(ped2, true) + end + + local data = { + cutscene = cutscene, + coords = coords, + tags = usedTags, + srcs = srcs, + peds = playersToProcess, + clothes = clothes, + } + Cutscene.done = false + return data +end + +function Cutscene.Start(cutsceneData) + DoScreenFadeIn(1000) + Cutscene.done = false + if not cutsceneData then + print("Cutscene.Start: Cutscene data is nil.") + return + end + local clothes = cutsceneData.clothes + local coords = cutsceneData.coords + if coords then + if type(coords) == 'boolean' then + coords = GetEntityCoords(PlayerPedId()) + end + StartCutsceneAtCoords(coords.x, coords.y, coords.z, 0 ) + else + StartCutscene(0) + end + + Wait(100) + for k, datam in pairs(clothes) do + local ped = datam.ped + if DoesEntityExist(ped) then + SetCutscenePedComponentVariationFromPed(k, ped, 0) + Cutscene.ApplyPedOutfit(ped, datam.clothing) + else + print("Cutscene.Create: Ped " .. k .. " does not exist.") + end + end + + local lastCoords = nil + CreateThread(function() + while not Cutscene.done do + local coords = GetWorldCoordFromScreenCoord(0.5, 0.5) + if not lastCoords or (lastCoords and #(lastCoords - coords) > 100) then + NewLoadSceneStartSphere(coords.x, coords.y, coords.z, 2000, 0) + lastCoords = coords + end + Wait(500) + end + end) + + CreateThread(function() + while not Cutscene.done do + DisableAllControlActions(0) + DisableFrontendThisFrame() + Wait(3) + end + end) + + while not HasCutsceneFinished() and not Cutscene.done do + Wait(0) + if IsDisabledControlJustPressed(0, 200) then + DoScreenFadeOut(1000) + Wait(1000) + StopCutsceneImmediately() + Wait(500) + Cutscene.done = true + break + end + end + DoScreenFadeIn(1000) + -- clean up any peds marked as 'script' + for _, playerData in ipairs(cutsceneData.peds) do + local ped = playerData.ped + if ped and DoesEntityExist(ped) and playerData.identifier == 'script' then + DeleteEntity(ped) + end + if ped and DoesEntityExist(ped) and playerData.identifier == 'localplayer' then + SetEntityCoords(ped, playerData.coords.x, playerData.coords.y, playerData.coords.z) + end + end + Cutscene.done = true +end + +-- RegisterCommand('cutscene', function(source, args, rawCommand) +-- if not Cutscene.done then return end +-- local cutscene = args[1] +-- if not cutscene then return print("Usage: /cutscene ") end + + +-- local cutsceneData = Cutscene.Create(cutscene, nil, {1, 1, 1 }) +-- Cutscene.Start(cutsceneData) + + +-- end, false) + + + +return Cutscene \ No newline at end of file diff --git a/lib/entities/client/client_entity.lua b/lib/entities/client/client_entity.lua index 29c8e82..7835763 100644 --- a/lib/entities/client/client_entity.lua +++ b/lib/entities/client/client_entity.lua @@ -50,17 +50,14 @@ local function SpawnEntity(entityData) end local function RemoveEntity(entityData) - entityData = entityData and entityData.args - if not entityData then return end -- Added safety check - - ClientEntityActions.StopAction(entityData.id) -- Stop any ongoing action AND clear queue before despawning - + entityData = entityData and entityData.args or entityData + if not entityData then return end + ClientEntityActions.StopAction(entityData.id) if entityData.spawned and DoesEntityExist(entityData.spawned) then local entityHandle = entityData.spawned - entityData.spawned = nil -- Clear handle first - SetEntityAsMissionEntity(entityHandle, false, false) -- Allow game engine to delete if needed, though we delete manually + entityData.spawned = nil + SetEntityAsMissionEntity(entityHandle, false, false) DeleteEntity(entityHandle) - -- print(string.format("[ClientEntity] Removed %s entity %s (GameID: %s)", entityData.entityType, entityData.id, entityHandle)) end if entityData.OnRemove and type(entityData.OnRemove) == 'function' then entityData.OnRemove(entityData) @@ -86,9 +83,8 @@ function ClientEntity.Unregister(id) local entityData = Entities[id] if not entityData then return end - -- print(string.format("[ClientEntity] Unregistering entity %s", id)) - Point.Remove(id) -- Remove from proximity checks (this will call RemoveEntity if currently in range) - RemoveEntity(entityData) -- Ensure it's removed even if Point.Remove didn't trigger it + Point.Remove(id) + RemoveEntity(entityData) Entities[id] = nil end @@ -163,10 +159,12 @@ end -- Network Event Handlers RegisterNetEvent("community_bridge:client:CreateEntity", function(entityData) + print(string.format("[ClientEntity] Received entity %s", entityData.id)) ClientEntity.Register(entityData) end) RegisterNetEvent("community_bridge:client:DeleteEntity", function(id) + print(string.format("[ClientEntity] Deleting entity %s", id)) ClientEntity.Unregister(id) end) diff --git a/lib/init.lua b/lib/init.lua index b877f42..e67a311 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -35,6 +35,8 @@ function Require(modulePath, resourceName) return result end + + cLib = { Require = Require, Callback = Callback or Require("lib/utility/shared/callbacks.lua"), @@ -76,5 +78,5 @@ cLib.ClientEntityActions = ClientEntityActions or Require("lib/entities/client/c cLib.ClientStateBag = ClientStateBag or Require("lib/statebags/client/client.lua") cLib.Marker = Marker or Require("lib/markers/client/markers.lua") cLib.Anim = Anim or Require("lib/anim/client/client.lua") - +cLib.Cutscene = Cutscene or Require("lib/cutscenes/client/cutscene.lua") return cLib From 78bb1f8c05d4816b8e3f2e4aedf691d1e27b2f8b Mon Sep 17 00:00:00 2001 From: JericoFX Date: Fri, 9 May 2025 22:27:48 -0300 Subject: [PATCH 17/38] Add utility functions for player data retrieval and enhance existing functions --- lib/utility/client/utility.lua | 1 + modules/framework/es_extended/server.lua | 39 ++++++++++++------------ modules/framework/qb-core/server.lua | 19 ++++++------ modules/framework/qbx_core/server.lua | 17 ++++++----- 4 files changed, 40 insertions(+), 36 deletions(-) diff --git a/lib/utility/client/utility.lua b/lib/utility/client/utility.lua index 14b4747..3f410c3 100644 --- a/lib/utility/client/utility.lua +++ b/lib/utility/client/utility.lua @@ -495,6 +495,7 @@ print("Result:", result) ]] + AddEventHandler('onResourceStop', function(resource) if resource ~= GetCurrentResourceName() then return end for _, blip in pairs(blipIDs) do diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index 2597fcd..faf8e02 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -103,14 +103,14 @@ Framework.GetPlayerInventory = function(src) local playerItems = xPlayer.getInventory() local repackedTable = {} for _, v in pairs(playerItems) do - if v.count > 0 then - table.insert(repackedTable, { - name = v.name, - count = v.count, - --metadata = v.metadata, - --slot = v.slot, - }) - end + if v.count > 0 then + table.insert(repackedTable, { + name = v.name, + count = v.count, + --metadata = v.metadata, + --slot = v.slot, + }) + end end return repackedTable end @@ -133,9 +133,9 @@ Framework.GetPlayerMetadata = function(src, metadata) end -- defualt esx Available tables are --- identifier, accounts, group, inventory, job, job_grade, loadout, --- metadata, position, firstname, lastname, dateofbirth, sex, height, --- skin, status, is_dead, id, disabled, last_property, created_at, last_seen, +-- identifier, accounts, group, inventory, job, job_grade, loadout, +-- metadata, position, firstname, lastname, dateofbirth, sex, height, +-- skin, status, is_dead, id, disabled, last_property, created_at, last_seen, -- phone_number, pincode Framework.GetStatus = function(src, column) local xPlayer = ESX.GetPlayerFromId(src) @@ -250,7 +250,10 @@ end Framework.SetPlayerJob = function(src, name, grade) local xPlayer = ESX.GetPlayerFromId(src) if not xPlayer then return end - if not ESX.DoesJobExist(name, grade) then lib.print.error("Job Does Not Exsist In Framework :NAME "..name.." Grade:"..grade) return end + if not ESX.DoesJobExist(name, grade) then + lib.print.error("Job Does Not Exsist In Framework :NAME " .. name .. " Grade:" .. grade) + return + end return xPlayer.setJob(name, grade, true) end @@ -301,14 +304,14 @@ end Framework.GetOwnedVehicles = function(src) local citizenId = Framework.GetPlayerIdentifier(src) local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM owned_vehicles WHERE owner = '" .. citizenId .. "'") - local vehicles = {} - for i=1, #result do + local vehicles = {} + for i = 1, #result do local vehicle = result[i].vehicle local plate = result[i].plate local model = json.decode(vehicle).model - table.insert(vehicles, {vehicle = model, plate = plate}) + table.insert(vehicles, { vehicle = model, plate = plate }) end - return vehicles + return vehicles end -- Framework.RegisterUsableItem(item, cb) @@ -339,7 +342,7 @@ AddEventHandler("playerDropped", function() end) lib.callback.register('community_bridge:Callback:GetFrameworkJobs', function(source) - return Framework.GetFrameworkJobs() or {} + return Framework.GetFrameworkJobs() or {} end) Framework.Commands = {} @@ -351,5 +354,3 @@ Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, arguments = arguments }) end - -return Framework \ No newline at end of file diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index 736278e..707d1c6 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -238,7 +238,7 @@ Framework.AddHunger = function(src, value) player.Functions.SetMetaData('hunger', Math.Clamp(newHunger, 0, 100)) TriggerClientEvent('hud:client:UpdateNeeds', src, newHunger, playerData.metadata.thirst) --TriggerClientEvent('hud:client:UpdateStress', src, newStress) - + return newHunger end @@ -277,7 +277,7 @@ end Framework.RevivePlayer = function(src) src = tonumber(src) if not src then return false end - TriggerClientEvent('hospital:client:Revive', src) + TriggerClientEvent('hospital:client:Revive', src) return true end @@ -413,7 +413,8 @@ end Framework.AddItem = function(src, item, amount, slot, metadata) local player = QBCore.Functions.GetPlayer(src) if not player then return end - TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = amount, slot = slot, metadata = metadata}) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, + { action = "add", item = item, count = amount, slot = slot, metadata = metadata }) return player.Functions.AddItem(item, amount, slot, metadata) end @@ -422,7 +423,8 @@ end Framework.RemoveItem = function(src, item, amount, slot, metadata) local player = QBCore.Functions.GetPlayer(src) if not player then return end - TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = amount, slot = slot, metadata = metadata}) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, + { action = "remove", item = item, count = amount, slot = slot, metadata = metadata }) return player.Functions.RemoveItem(item, amount, slot or nil) end @@ -452,12 +454,13 @@ end ---@return table Framework.GetOwnedVehicles = function(src) local citizenId = Framework.GetPlayerIdentifier(src) - local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" .. citizenId .. "'") + local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" .. + citizenId .. "'") local vehicles = {} - for i=1, #result do + for i = 1, #result do local vehicle = result[i].vehicle local plate = result[i].plate - table.insert(vehicles, {vehicle = vehicle, plate = plate}) + table.insert(vehicles, { vehicle = vehicle, plate = plate }) end return vehicles end @@ -493,5 +496,3 @@ Framework.Commands = {} Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...) QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...) end - -return Framework \ No newline at end of file diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index f536597..6845f27 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -237,7 +237,7 @@ end Framework.RevivePlayer = function(src) src = tonumber(src) if not src then return false end - TriggerClientEvent('hospital:client:Revive', src) + TriggerClientEvent('hospital:client:Revive', src) return true end @@ -375,7 +375,8 @@ end Framework.AddItem = function(src, item, amount, slot, metadata) local player = QBox:GetPlayer(src) if not player then return end - TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = amount, slot = slot, metadata = metadata}) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, + { action = "add", item = item, count = amount, slot = slot, metadata = metadata }) return player.Functions.AddItem(item, amount, slot, metadata) end @@ -389,7 +390,8 @@ end Framework.RemoveItem = function(src, item, amount, slot, metadata) local player = QBox:GetPlayer(src) if not player then return end - TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = amount, slot = slot, metadata = metadata}) + TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, + { action = "remove", item = item, count = amount, slot = slot, metadata = metadata }) return player.Functions.RemoveItem(item, amount, slot) end @@ -411,12 +413,13 @@ end ---@return table Framework.GetOwnedVehicles = function(src) local citizenId = Framework.GetPlayerIdentifier(src) - local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" .. citizenId .. "'") + local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" .. + citizenId .. "'") local vehicles = {} - for i=1, #result do + for i = 1, #result do local vehicle = result[i].vehicle local plate = result[i].plate - table.insert(vehicles, {vehicle = vehicle, plate = plate}) + table.insert(vehicles, { vehicle = vehicle, plate = plate }) end return vehicles end @@ -449,5 +452,3 @@ AddEventHandler("playerDropped", function() local src = source TriggerEvent("community_bridge:Server:OnPlayerUnload", src) end) - -return Framework \ No newline at end of file From 67c9fbf783843be71f3bc8e00c8bfac3861880a3 Mon Sep 17 00:00:00 2001 From: JericoFX Date: Sun, 11 May 2025 12:57:34 -0300 Subject: [PATCH 18/38] Implement DUI Manager with mouse support and instance management --- lib/dui/client/dui.lua | 329 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 329 insertions(+) create mode 100644 lib/dui/client/dui.lua diff --git a/lib/dui/client/dui.lua b/lib/dui/client/dui.lua new file mode 100644 index 0000000..7f0d7f0 --- /dev/null +++ b/lib/dui/client/dui.lua @@ -0,0 +1,329 @@ +-- DUI (Direct User Interface) Manager for FiveM +-- Basic table-based implementation with full mouse support + +---@class DUI +DUI = {} + +-- Constants +local DEFAULT_WIDTH = 1280 +local DEFAULT_HEIGHT = 720 + +-- Store active DUI instances +local activeInstances = {} +local instanceCounter = 0 + +-- Mouse tracking state +local mouseState = { + tracking = false, + activeId = nil, + lastX = 0, + lastY = 0, + isPressed = false, + currentButton = nil +} + +-- Mouse button constants +local MOUSE_BUTTONS = { + LEFT = "left", + MIDDLE = "middle", + RIGHT = "right" +} + +---@class DUIInstance +---@field id number Unique identifier for this DUI instance +---@field url string URL loaded in the DUI +---@field width number Width of the DUI +---@field height number Height of the DUI +---@field handle number DUI browser handle +---@field txd string Texture dictionary name +---@field txn string Texture name +---@field active boolean Whether the DUI is active +---@field trackMouse boolean Whether mouse tracking is enabled for this instance +---@field mouseScale table Scale factors for mouse coordinates + +-- Create a new DUI instance +---@param url string URL to load +---@param width? number Width of the DUI (default: 1280) +---@param height? number Height of the DUI (default: 720) +---@return number|nil id The DUI instance ID if successful, nil if failed +function DUI.Create(url, width, height) + if not url or type(url) ~= "string" then + return print("DUI.Create: URL is required and must be a string") + end + + width = width or DEFAULT_WIDTH + height = height or DEFAULT_HEIGHT + instanceCounter = instanceCounter + 1 + + local id = instanceCounter + local handle = CreateDui(url, width, height) + + if not handle then + return print("DUI.Create: Failed to create DUI instance") + end + + local instance = { + id = id, + url = url, + width = width, + height = height, + handle = handle, + txd = "dui_" .. id, + txn = "texture_" .. id, + active = true, + trackMouse = false, + mouseScale = { + x = 1.0, + y = 1.0 + } + } + + -- Create runtime texture + local duiHandle = GetDuiHandle(handle) + CreateRuntimeTextureFromDuiHandle(CreateRuntimeTxd(instance.txd), instance.txn, duiHandle) + + activeInstances[id] = instance + return id +end + +-- Destroy a DUI instance +---@param id number DUI instance ID +---@return boolean success Whether the operation was successful +function DUI.Destroy(id) + local instance = activeInstances[id] + if not instance then return false end + + if instance.handle then + DestroyDui(instance.handle) + end + + activeInstances[id] = nil + return true +end + +-- Set URL for a DUI instance +---@param id number DUI instance ID +---@param url string New URL to load +---@return boolean success Whether the operation was successful +function DUI.SetURL(id, url) + local instance = activeInstances[id] + if not instance then return false end + + SetDuiUrl(instance.handle, url) + instance.url = url + return true +end + +-- Send a message to the DUI +---@param id number DUI instance ID +---@param message table Message to send (will be JSON encoded) +---@return boolean success Whether the operation was successful +function DUI.SendMessage(id, message) + local instance = activeInstances[id] + if not instance then return false end + + SendDuiMessage(instance.handle, json.encode(message)) + return true +end + +-- Mouse interaction functions + +-- Move mouse cursor on DUI +---@param id number DUI instance ID +---@param x number X coordinate +---@param y number Y coordinate +---@return boolean success Whether the operation was successful +function DUI.MoveMouse(id, x, y) + local instance = activeInstances[id] + if not instance then return false end + + SendDuiMouseMove(instance.handle, x, y) + return true +end + +-- Simulate mouse button press +---@param id number DUI instance ID +---@param button "left"|"middle"|"right" Mouse button to simulate +---@return boolean success Whether the operation was successful +function DUI.MouseDown(id, button) + local instance = activeInstances[id] + if not instance then return false end + + if not MOUSE_BUTTONS[button:upper()] then + return print("DUI.MouseDown: Invalid button. Must be 'left', 'middle', or 'right'") + end + + -- Update mouse state + if instance.trackMouse then + mouseState.isPressed = true + mouseState.currentButton = button + end + + SendDuiMouseDown(instance.handle, button) + return true +end + +-- Simulate mouse button release +---@param id number DUI instance ID +---@param button "left"|"middle"|"right" Mouse button to simulate +---@return boolean success Whether the operation was successful +function DUI.MouseUp(id, button) + local instance = activeInstances[id] + if not instance then return false end + + if not MOUSE_BUTTONS[button:upper()] then + return print("DUI.MouseUp: Invalid button. Must be 'left', 'middle', or 'right'") + end + + -- Update mouse state + if instance.trackMouse then + mouseState.isPressed = false + mouseState.currentButton = nil + end + + SendDuiMouseUp(instance.handle, button) + return true +end + +-- Simulate mouse wheel movement +---@param id number DUI instance ID +---@param deltaY number Vertical scroll amount +---@param deltaX number Horizontal scroll amount +---@return boolean success Whether the operation was successful +function DUI.MouseWheel(id, deltaY, deltaX) + local instance = activeInstances[id] + if not instance then return false end + + SendDuiMouseWheel(instance.handle, deltaY, deltaX) + return true +end + +-- Click helper function (combines MoveMouse, MouseDown, and MouseUp) +---@param id number DUI instance ID +---@param x number X coordinate +---@param y number Y coordinate +---@param button? "left"|"middle"|"right" Mouse button to click (default: "left") +---@return boolean success Whether the operation was successful +function DUI.Click(id, x, y, button) + button = button or "left" + + if not DUI.MoveMouse(id, x, y) then return false end + if not DUI.MouseDown(id, button) then return false end + + -- Small delay to simulate real click + Citizen.Wait(50) + + return DUI.MouseUp(id, button) +end + +-- Enable or disable mouse tracking for a DUI instance +---@param id number DUI instance ID +---@param enabled boolean Whether to enable mouse tracking +---@param scaleX? number Scale factor for X coordinates (default: 1.0) +---@param scaleY? number Scale factor for Y coordinates (default: 1.0) +---@return boolean success Whether the operation was successful +function DUI.TrackMouse(id, enabled, scaleX, scaleY) + local instance = activeInstances[id] + if not instance then return false end + + instance.trackMouse = enabled + instance.mouseScale.x = scaleX or 1.0 + instance.mouseScale.y = scaleY or 1.0 + + if enabled then + mouseState.tracking = true + mouseState.activeId = id + elseif mouseState.activeId == id then + mouseState.tracking = false + mouseState.activeId = nil + end + + return true +end + +-- Update mouse coordinates from screen position +---@param screenX number Screen X coordinate +---@param screenY number Screen Y coordinate +---@return boolean updated Whether coordinates were updated +local function UpdateMousePosition(screenX, screenY) + if not mouseState.tracking or not mouseState.activeId then return false end + + local instance = activeInstances[mouseState.activeId] + if not instance or not instance.trackMouse then return false end + + -- Scale coordinates based on DUI dimensions and scale factors + local scaledX = screenX * instance.mouseScale.x + local scaledY = screenY * instance.mouseScale.y + + -- Only update if position changed + if scaledX ~= mouseState.lastX or scaledY ~= mouseState.lastY then + mouseState.lastX = scaledX + mouseState.lastY = scaledY + DUI.MoveMouse(mouseState.activeId, scaledX, scaledY) + return true + end + + return false +end + +-- Mouse tracking thread +Citizen.CreateThread(function() + while true do + if mouseState.tracking and mouseState.activeId then + local instance = activeInstances[mouseState.activeId] + if instance and instance.trackMouse then + -- Get current cursor position + local screenX, screenY = GetNuiCursorPosition() + UpdateMousePosition(screenX, screenY) + + -- Handle held mouse buttons + if mouseState.isPressed and mouseState.currentButton then + -- Keep the button pressed state + SendDuiMouseDown(instance.handle, mouseState.currentButton) + end + end + end + Citizen.Wait(0) + end +end) + +-- Utility functions + +-- Get textures for a DUI instance +---@param id number DUI instance ID +---@return string|nil txd, string|nil txn Texture dictionary and name, or nil if instance not found +function DUI.GetTextures(id) + local instance = activeInstances[id] + if not instance then return nil, nil end + + return instance.txd, instance.txn +end + +-- Check if a DUI instance exists +---@param id number DUI instance ID +---@return boolean exists Whether the instance exists and is active +function DUI.Exists(id) + local instance = activeInstances[id] + return instance ~= nil and instance.active +end + +-- Get all active DUI instances +---@return table instances Table of active DUI instances +function DUI.GetActiveInstances() + return activeInstances +end + +-- Cleanup all DUI instances +function DUI.CleanupAll() + for id in pairs(activeInstances) do + DUI.Destroy(id) + end +end + +-- Automatic cleanup on resource stop +AddEventHandler('onResourceStop', function(resourceName) + if GetCurrentResourceName() ~= resourceName then return end + DUI.CleanupAll() +end) + +return DUI From 78444c7aae5e74ffa87e70f036b3daab04b9fcfe Mon Sep 17 00:00:00 2001 From: JericoFX Date: Sun, 11 May 2025 12:58:01 -0300 Subject: [PATCH 19/38] Old Lady Cleaning --- lib/cutscenes/client/cutscene.lua | 415 ++++++++++++++++-------------- 1 file changed, 226 insertions(+), 189 deletions(-) diff --git a/lib/cutscenes/client/cutscene.lua b/lib/cutscenes/client/cutscene.lua index 5e5bc7e..2f12a1b 100644 --- a/lib/cutscenes/client/cutscene.lua +++ b/lib/cutscenes/client/cutscene.lua @@ -1,112 +1,158 @@ +-- Cutscene Manager for FiveM +-- Handles cutscene loading, playback, and character management + +---@class Cutscene Cutscenes = Cutscenes or {} Cutscene = Cutscene or {} Cutscene.done = true -local names = { - {male = 'MP_1'}, - {male = 'MP_2'}, - {male = 'MP_3'}, - {male = 'MP_4'}, - {male = 'MP_Male_Character', female = 'MP_Female_Character'}, - {male = 'MP_Male_Character_1', female = 'MP_Female_Character_1'}, - {male = 'MP_Male_Character_2', female = 'MP_Female_Character_2'}, - {male = 'MP_Male_Character_3', female = 'MP_Female_Character_3'}, - {male = 'MP_Male_Character_4', female = 'MP_Female_Character_4'}, - {male = 'MP_Plane_Passenger_1'}, - {male = 'MP_Plane_Passenger_2'}, - {male = 'MP_Plane_Passenger_3'}, - {male = 'MP_Plane_Passenger_4'}, - {male = 'MP_Plane_Passenger_5'}, - {male = 'MP_Plane_Passenger_6'}, - {male = 'MP_Plane_Passenger_7'}, - {male = 'MP_Plane_Passenger_8'}, - {male = 'MP_Plane_Passenger_9'}, +-- Constants +local LOAD_TIMEOUT = 10000 +local FADE_DURATION = 1000 +local CUTSCENE_WAIT = 1000 + +-- Character model definitions +local characterTags = { + { male = 'MP_1' }, + { male = 'MP_2' }, + { male = 'MP_3' }, + { male = 'MP_4' }, + { male = 'MP_Male_Character', female = 'MP_Female_Character' }, + { male = 'MP_Male_Character_1', female = 'MP_Female_Character_1' }, + { male = 'MP_Male_Character_2', female = 'MP_Female_Character_2' }, + { male = 'MP_Male_Character_3', female = 'MP_Female_Character_3' }, + { male = 'MP_Male_Character_4', female = 'MP_Female_Character_4' }, + { male = 'MP_Plane_Passenger_1' }, + { male = 'MP_Plane_Passenger_2' }, + { male = 'MP_Plane_Passenger_3' }, + { male = 'MP_Plane_Passenger_4' }, + { male = 'MP_Plane_Passenger_5' }, + { male = 'MP_Plane_Passenger_6' }, + { male = 'MP_Plane_Passenger_7' }, + { male = 'MP_Plane_Passenger_8' }, + { male = 'MP_Plane_Passenger_9' }, } -function Cutscene.GetTags(cutscene) - if not Cutscene.Load(cutscene) then return end - StartCutscene(0) - Wait(1000) - local tags = {} - for k, tag in pairs(names) do - if DoesCutsceneEntityExist(tag.male, 0) or DoesCutsceneEntityExist(tag.female, 0) then - table.insert(tags, tag) - end +-- Component definitions for character customization +local componentsToSave = { + -- Components + { name = "head", id = 0, type = "drawable" }, + { name = "beard", id = 1, type = "drawable" }, + { name = "hair", id = 2, type = "drawable" }, + { name = "arms", id = 3, type = "drawable" }, + { name = "pants", id = 4, type = "drawable" }, + { name = "parachute", id = 5, type = "drawable" }, + { name = "feet", id = 6, type = "drawable" }, + { name = "accessories", id = 7, type = "drawable" }, + { name = "undershirt", id = 8, type = "drawable" }, + { name = "vest", id = 9, type = "drawable" }, + { name = "decals", id = 10, type = "drawable" }, + { name = "jacket", id = 11, type = "drawable" }, + -- Props + { name = "hat", id = 0, type = "prop" }, + { name = "glasses", id = 1, type = "prop" }, + { name = "ears", id = 2, type = "prop" }, + { name = "watch", id = 3, type = "prop" }, + { name = "bracelet", id = 4, type = "prop" }, + { name = "misc", id = 5, type = "prop" }, + { name = "left_wrist", id = 6, type = "prop" }, + { name = "right_wrist", id = 7, type = "prop" }, + { name = "prop8", id = 8, type = "prop" }, + { name = "prop9", id = 9, type = "prop" }, +} + +-- Utility Functions + +function table.shallow_copy(t) + local t2 = {} + for k, v in pairs(t) do + t2[k] = v end - StopCutsceneImmediately() - Wait(2000) - return tags + return t2 end -function Cutscene.Load(cutscene) - assert(cutscene, "Cutscene.Load called without a cutscene name.") - if IsPedMale(PlayerPedId()) then - RequestCutsceneWithPlaybackList(cutscene, 31, 8) - else - RequestCutsceneWithPlaybackList(cutscene, 103, 8) - end - local timeout = GetGameTimer() + 10000 - while not (HasCutsceneLoaded()) and GetGameTimer() < timeout do +local function WaitForModelLoad(modelHash) + local timeout = GetGameTimer() + LOAD_TIMEOUT + while not HasModelLoaded(modelHash) and GetGameTimer() < timeout do Wait(0) end + return HasModelLoaded(modelHash) +end + +local function CreatePedFromModel(modelName, coords) + local model = GetHashKey(modelName) + RequestModel(model) + + if not WaitForModelLoad(model) then + print("Failed to load model: " .. modelName) + return nil + end + + local ped = CreatePed(0, model, coords.x, coords.y, coords.z, 0.0, true, false) + if not DoesEntityExist(ped) then + print("Failed to create ped from model: " .. modelName) + return nil + end + + return ped +end + +-- Cutscene Core Functions +local function LoadCutscene(cutscene) + assert(cutscene, "Cutscene.Load called without a cutscene name.") + local playbackList = IsPedMale(PlayerPedId()) and 31 or 103 + RequestCutsceneWithPlaybackList(cutscene, playbackList, 8) + + local timeout = GetGameTimer() + LOAD_TIMEOUT + while not HasCutsceneLoaded() and GetGameTimer() < timeout do + Wait(0) + end + if not HasCutsceneLoaded() then print("Cutscene failed to load: ", cutscene) return false end - + return true end -function Cutscene.SavePedOutfit(ped) - local outfitData = {} - local componentsToSave = { - -- Components - { name = "head", id = 0, type = "drawable" }, - { name = "beard", id = 1, type = "drawable" }, - { name = "hair", id = 2, type = "drawable" }, - { name = "arms", id = 3, type = "drawable" }, - { name = "pants", id = 4, type = "drawable" }, - { name = "parachute", id = 5, type = "drawable" }, - { name = "feet", id = 6, type = "drawable" }, - { name = "accessories", id = 7, type = "drawable" }, - { name = "undershirt", id = 8, type = "drawable" }, - { name = "vest", id = 9, type = "drawable" }, - { name = "decals", id = 10, type = "drawable" }, - { name = "jacket", id = 11, type = "drawable" }, +local function GetCutsceneTags(cutscene) + if not LoadCutscene(cutscene) then return end - -- Props - { name = "hat", id = 0, type = "prop" }, - { name = "glasses", id = 1, type = "prop" }, - { name = "ears", id = 2, type = "prop" }, - { name = "watch", id = 3, type = "prop" }, - { name = "bracelet", id = 4, type = "prop" }, - { name = "misc", id = 5, type = "prop" }, - { name = "left_wrist", id = 6, type = "prop" }, - { name = "right_wrist", id = 7, type = "prop" }, - { name = "prop8", id = 8, type = "prop" }, - { name = "prop9", id = 9, type = "prop" }, - } + StartCutscene(0) + Wait(CUTSCENE_WAIT) + + local tags = {} + for _, tag in pairs(characterTags) do + if DoesCutsceneEntityExist(tag.male, 0) or DoesCutsceneEntityExist(tag.female, 0) then + table.insert(tags, tag) + end + end + + StopCutsceneImmediately() + Wait(CUTSCENE_WAIT * 2) + return tags +end + +-- Character Outfit Management +local function SavePedOutfit(ped) + local outfitData = {} for _, component in ipairs(componentsToSave) do if component.type == "drawable" then - local drawable = GetPedDrawableVariation(ped, component.id) - local texture = GetPedTextureVariation(ped, component.id) - local palette = GetPedPaletteVariation(ped, component.id) outfitData[component.name] = { id = component.id, type = component.type, - drawable = drawable, - texture = texture, - palette = palette, + drawable = GetPedDrawableVariation(ped, component.id), + texture = GetPedTextureVariation(ped, component.id), + palette = GetPedPaletteVariation(ped, component.id), } elseif component.type == "prop" then - local propIndex = GetPedPropIndex(ped, component.id) - local propTexture = GetPedPropTextureIndex(ped, component.id) outfitData[component.name] = { id = component.id, type = component.type, - propIndex = propIndex, - propTexture = propTexture, + propIndex = GetPedPropIndex(ped, component.id), + propTexture = GetPedPropTextureIndex(ped, component.id), } end end @@ -114,7 +160,7 @@ function Cutscene.SavePedOutfit(ped) return outfitData end -function Cutscene.ApplyPedOutfit(ped, outfitData) +local function ApplyPedOutfit(ped, outfitData) if not outfitData or type(outfitData) ~= "table" then print("ApplyPedOutfit: Invalid outfitData provided.") return @@ -122,29 +168,40 @@ function Cutscene.ApplyPedOutfit(ped, outfitData) for componentName, data in pairs(outfitData) do if data.type == "drawable" then - -- Ensure all values are present before applying - local drawable = data.drawable or 0 - local texture = data.texture or 0 - local palette = data.palette or 0 - SetPedComponentVariation(ped, data.id, drawable, texture, palette) + SetPedComponentVariation(ped, data.id, data.drawable or 0, data.texture or 0, data.palette or 0) elseif data.type == "prop" then - -- Clear prop if it's marked as not present (-1 index) if data.propIndex == -1 or data.propIndex == nil then ClearPedProp(ped, data.id) else - local propTexture = data.propTexture or 0 - SetPedPropIndex(ped, data.id, data.propIndex, propTexture, true) + SetPedPropIndex(ped, data.id, data.propIndex, data.propTexture or 0, true) end end end end +-- Public Interface +function Cutscene.GetTags(cutscene) + return GetCutsceneTags(cutscene) +end + +function Cutscene.Load(cutscene) + return LoadCutscene(cutscene) +end + +function Cutscene.SavePedOutfit(ped) + return SavePedOutfit(ped) +end + +function Cutscene.ApplyPedOutfit(ped, outfitData) + return ApplyPedOutfit(ped, outfitData) +end + function Cutscene.Create(cutscene, coords, srcs) local lastCoords = coords or GetEntityCoords(PlayerPedId()) DoScreenFadeOut(0) - local tagsFromCutscene = Cutscene.GetTags(cutscene) - if not Cutscene.Load(cutscene) then + local tagsFromCutscene = GetCutsceneTags(cutscene) + if not LoadCutscene(cutscene) then print("Cutscene.Create: Failed to load cutscene", cutscene) DoScreenFadeIn(0) return false @@ -152,100 +209,85 @@ function Cutscene.Create(cutscene, coords, srcs) srcs = srcs or {} local clothes = {} - local localped = PlayerPedId() - - local playersToProcess = {} - table.insert(playersToProcess, { ped = localped, identifier = "localplayer", coords = lastCoords}) - for i, src_raw in ipairs(srcs) do - if type(src_raw) == 'number' then - if src_raw and not DoesEntityExist(src_raw) then - local playerPed = GetPlayerPed(GetPlayerFromServerId(src_raw)) -- Assuming GetPlayerPed takes server ID + + -- Process players and create necessary peds + local playersToProcess = { { ped = localped, identifier = "localplayer", coords = lastCoords } } + + for _, src_raw in ipairs(srcs) do + if type(src_raw) == 'number' then + if src_raw and not DoesEntityExist(src_raw) then + local playerPed = GetPlayerPed(GetPlayerFromServerId(src_raw)) if DoesEntityExist(playerPed) then local ped = ClonePed(playerPed, false, false, true) table.insert(playersToProcess, { ped = ped, identifier = "player" }) - else - print("Cutscene.Create: Ped for src " .. src_raw .. " does not exist.") end - else - table.insert(playersToProcess, { ped = src_raw, identifier = "user"}) --developer passed a ped + else + table.insert(playersToProcess, { ped = src_raw, identifier = "user" }) end elseif type(src_raw) == 'string' then - -- impliment creating a ped by model name - local model = GetHashKey(src_raw) - RequestModel(model) - local timeout = GetGameTimer() + 10000 - while not HasModelLoaded(model) and GetGameTimer() < timeout do - Wait(0) - end - if not HasModelLoaded(model) then - print("Cutscene.Create: Failed to load model " .. src_raw) - return false - end - local pos = GetEntityCoords(localped) - local ped = CreatePed(0, model, pos.x, pos.y, pos.z, 0.0, true, false) - - if ped and DoesEntityExist(ped) then + local ped = CreatePedFromModel(src_raw, GetEntityCoords(localped)) + if ped then table.insert(playersToProcess, { ped = ped, identifier = 'script' }) - else - print("Cutscene.Create: Failed to create ped for src " .. src_raw) end - elseif type(src_raw) == 'boolean' and src_raw then - print("Cutscene.Create: src_raw is a boolean, creating random ped currently not implimented.") - -- local pos = GetEntityCoords(localped) - -- local ped = CreateRandomPed(pos.x, pos.y, pos.z) - - -- if ped and DoesEntityExist(ped)then - -- table.insert(playersToProcess, { ped = ped, identifier = 'script' }) - -- else - -- print("Cutscene.Create: Failed to create random ped for src " ) - -- end end end - local availableTags = {} -- Create a mutable copy of tags - for _, tagName in ipairs(tagsFromCutscene or {}) do - table.insert(availableTags, tagName) - end - + -- Process available tags and assign to players + local availableTags = table.shallow_copy(tagsFromCutscene or {}) local usedTags = {} local cleanupTags = {} for _, playerData in ipairs(playersToProcess) do local currentPed = playerData.ped - local isPedMale = IsPedMale(currentPed) - local tagTable = availableTags[1] + if not currentPed or not DoesEntityExist(currentPed) then goto continue end + + local tagTable = table.remove(availableTags, 1) if not tagTable then print("Cutscene.Create: No available tags for player", playerData.identifier) break end - local tag = not isPedMale and tagTable.female or tagTable.male - local unusedTag = nil - if isPedMale and tagTable.female then - unusedTag = isPedMale and tagTable.female or tagTable.male - end + local isPedMale = IsPedMale(currentPed) + local tag = isPedMale and tagTable.male or tagTable.female + local unusedTag = isPedMale and tagTable.female or tagTable.male + SetCutsceneEntityStreamingFlags(tag, 0, 1) RegisterEntityForCutscene(currentPed, tag, 0, GetEntityModel(currentPed), 64) - SetCutscenePedComponentVariationFromPed(tag, currentPed, 0) - clothes[tag] = { clothing = Cutscene.SavePedOutfit(currentPed), ped = currentPed } - table.insert(usedTags, tag) -- Track used tags - table.insert(cleanupTags, unusedTag) -- Track tags to be cleaned up later - table.remove(availableTags, 1) -- Remove used tag + SetCutscenePedComponentVariationFromPed(tag, currentPed, 0) + + clothes[tag] = { + clothing = SavePedOutfit(currentPed), + ped = currentPed + } + + table.insert(usedTags, tag) + if unusedTag then table.insert(cleanupTags, unusedTag) end + + ::continue:: end + + -- Clean up unused tags for _, tag in ipairs(cleanupTags) do local ped = RegisterEntityForCutscene(0, tag, 3, 0, 64) - NetworkSetEntityInvisibleToNetwork(ped, true) + if ped then + SetEntityVisible(ped, false, false) + end end + -- Handle remaining unused tags for _, tag in ipairs(availableTags) do - local ped1 = RegisterEntityForCutscene(0, tag.male, 3, 0, 64) - NetworkSetEntityInvisibleToNetwork(ped1, true) - local ped2 = RegisterEntityForCutscene(0, tag.female, 3, 0, 64) - NetworkSetEntityInvisibleToNetwork(ped2, true) + for _, tagType in pairs({ tag.male, tag.female }) do + if tagType then + local ped = RegisterEntityForCutscene(0, tagType, 3, 0, 64) + if ped then + SetEntityVisible(ped, false, false) + end + end + end end - local data = { + return { cutscene = cutscene, coords = coords, tags = usedTags, @@ -253,44 +295,47 @@ function Cutscene.Create(cutscene, coords, srcs) peds = playersToProcess, clothes = clothes, } - Cutscene.done = false - return data end function Cutscene.Start(cutsceneData) - DoScreenFadeIn(1000) - Cutscene.done = false if not cutsceneData then print("Cutscene.Start: Cutscene data is nil.") return end + + DoScreenFadeIn(FADE_DURATION) + Cutscene.done = false + local clothes = cutsceneData.clothes local coords = cutsceneData.coords - if coords then + + -- Start cutscene + if coords then if type(coords) == 'boolean' then coords = GetEntityCoords(PlayerPedId()) end - StartCutsceneAtCoords(coords.x, coords.y, coords.z, 0 ) + StartCutsceneAtCoords(coords.x, coords.y, coords.z, 0) else StartCutscene(0) end Wait(100) + + -- Apply clothing to cutscene characters for k, datam in pairs(clothes) do local ped = datam.ped if DoesEntityExist(ped) then SetCutscenePedComponentVariationFromPed(k, ped, 0) - Cutscene.ApplyPedOutfit(ped, datam.clothing) - else - print("Cutscene.Create: Ped " .. k .. " does not exist.") + ApplyPedOutfit(ped, datam.clothing) end end - local lastCoords = nil + -- Scene loading thread CreateThread(function() - while not Cutscene.done do + local lastCoords + while not Cutscene.done do local coords = GetWorldCoordFromScreenCoord(0.5, 0.5) - if not lastCoords or (lastCoords and #(lastCoords - coords) > 100) then + if not lastCoords or #(lastCoords - coords) > 100 then NewLoadSceneStartSphere(coords.x, coords.y, coords.z, 2000, 0) lastCoords = coords end @@ -298,6 +343,7 @@ function Cutscene.Start(cutsceneData) end end) + -- Control blocking thread CreateThread(function() while not Cutscene.done do DisableAllControlActions(0) @@ -306,43 +352,34 @@ function Cutscene.Start(cutsceneData) end end) - while not HasCutsceneFinished() and not Cutscene.done do + -- Main cutscene loop + while not HasCutsceneFinished() and not Cutscene.done do Wait(0) if IsDisabledControlJustPressed(0, 200) then - DoScreenFadeOut(1000) - Wait(1000) + DoScreenFadeOut(FADE_DURATION) + Wait(FADE_DURATION) StopCutsceneImmediately() - Wait(500) + Wait(500) Cutscene.done = true break end end - DoScreenFadeIn(1000) - -- clean up any peds marked as 'script' + + -- Cleanup + DoScreenFadeIn(FADE_DURATION) for _, playerData in ipairs(cutsceneData.peds) do local ped = playerData.ped - if ped and DoesEntityExist(ped) and playerData.identifier == 'script' then + if not ped or not DoesEntityExist(ped) then goto continue end + + if playerData.identifier == 'script' then DeleteEntity(ped) + elseif playerData.identifier == 'localplayer' then + SetEntityCoords(ped, playerData.coords.x, playerData.coords.y, playerData.coords.z, false, false, false, + false) end - if ped and DoesEntityExist(ped) and playerData.identifier == 'localplayer' then - SetEntityCoords(ped, playerData.coords.x, playerData.coords.y, playerData.coords.z) - end + ::continue:: end Cutscene.done = true end --- RegisterCommand('cutscene', function(source, args, rawCommand) --- if not Cutscene.done then return end --- local cutscene = args[1] --- if not cutscene then return print("Usage: /cutscene ") end - - --- local cutsceneData = Cutscene.Create(cutscene, nil, {1, 1, 1 }) --- Cutscene.Start(cutsceneData) - - --- end, false) - - - -return Cutscene \ No newline at end of file +return Cutscene From 2687b8148896b96acac6d0d4ff74a10b9a414564 Mon Sep 17 00:00:00 2001 From: JericoFX Date: Sun, 11 May 2025 12:58:11 -0300 Subject: [PATCH 20/38] Old Lady cleaning v2 --- lib/scaleform/client/scaleform.lua | 121 ++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 35 deletions(-) diff --git a/lib/scaleform/client/scaleform.lua b/lib/scaleform/client/scaleform.lua index aeeb2fe..f59e659 100644 --- a/lib/scaleform/client/scaleform.lua +++ b/lib/scaleform/client/scaleform.lua @@ -1,40 +1,84 @@ -Scaleform = {} +---@class Scaleform +local Scaleform = {} -function SetupScaleform(scaleform, Buttons) - local scaleform = RequestScaleformMovie(scaleform) - local timeout = 5000 +-- Constants +local SCALEFORM_TIMEOUT = 5000 +local BACKGROUND_COLOR_VALUE = 80 +local CONTROL_TYPE = 2 +local RENDER_WAIT_TIME = 2 + +-- Local utility functions +local function setupButton(scaleform, button) + PushScaleformMovieFunction(scaleform, button.type) + + if button.int then + PushScaleformMovieFunctionParameterInt(button.int) + end + + -- Handle key index setup + if button.keyIndex then + if type(button.keyIndex) == "table" then + for _, keyCode in pairs(button.keyIndex) do + N_0xe83a3e3557a56640(GetControlInstructionalButton(CONTROL_TYPE, keyCode, true)) + end + else + ScaleformMovieMethodAddParamPlayerNameString(GetControlInstructionalButton(CONTROL_TYPE, button.keyIndex[1], + true)) + end + end + + -- Handle button name setup + if button.name then + BeginTextCommandScaleformString("STRING") + AddTextComponentScaleform(button.name) + EndTextCommandScaleformString() + end + + -- Handle background color + if button.type == 'SET_BACKGROUND_COLOUR' then + for _ = 1, 4 do + PushScaleformMovieFunctionParameterInt(BACKGROUND_COLOR_VALUE) + end + end + + PopScaleformMovieFunctionVoid() +end + +---Creates and sets up a scaleform movie +---@param scaleformName string The name of the scaleform to load +---@param buttons table Array of button configurations +---@return number scaleform The loaded scaleform handle +local function setupScaleform(scaleformName, buttons) + local scaleform = RequestScaleformMovie(scaleformName) + local timeout = SCALEFORM_TIMEOUT + + -- Wait for scaleform to load while not HasScaleformMovieLoaded(scaleform) and timeout > 0 do timeout = timeout - 1 Wait(0) end - assert(timeout > 0, 'Scaleform failed to load') + + if timeout <= 0 then + error('Scaleform failed to load: ' .. scaleformName) + end DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 0, 0) - for i = 1,#Buttons do - PushScaleformMovieFunction(scaleform, Buttons[i].type) - if Buttons[i].int then PushScaleformMovieFunctionParameterInt(Buttons[i].int) end - if Buttons[i].keyIndex then - if type(Buttons[i].keyIndex) == "table" then - for _, v in pairs(Buttons[i].keyIndex) do N_0xe83a3e3557a56640(GetControlInstructionalButton(2, v, true)) end - else - ScaleformMovieMethodAddParamPlayerNameString(GetControlInstructionalButton(2, Buttons[i].keyIndex[1], true)) - end - end - if Buttons[i].name then - BeginTextCommandScaleformString("STRING") - AddTextComponentScaleform(Buttons[i].name) - EndTextCommandScaleformString() - end - if Buttons[i].type == 'SET_BACKGROUND_COLOUR' then - for u = 1,4 do PushScaleformMovieFunctionParameterInt(80) end - end - PopScaleformMovieFunctionVoid() + + -- Setup each button + for _, button in ipairs(buttons) do + setupButton(scaleform, button) end + return scaleform end +---Sets up instructional buttons with default configuration +---@param buttons table Optional custom button configuration +---@return number scaleform The configured instructional buttons scaleform function Scaleform.SetupInstructionalButtons(buttons) buttons = buttons or { + -- Default button configuration commented out + -- Uncomment and modify as needed -- {type = "CLEAR_ALL"}, -- {type = "SET_CLEAR_SPACE", int = 200}, -- {type = "SET_DATA_SLOT", name = config?.place_object?.name or 'Place Object:', keyIndex = config?.place_object?.key or {223}, int = 5}, @@ -46,34 +90,41 @@ function Scaleform.SetupInstructionalButtons(buttons) -- {type = "DRAW_INSTRUCTIONAL_BUTTONS"}, -- {type = "SET_BACKGROUND_COLOUR"}, } - local scaleform = SetupScaleform("instructional_buttons", buttons) - return scaleform + return setupScaleform("instructional_buttons", buttons) end +-- Active scaleform tracking +local activeScaleform = nil -local runningScaleform = nil +---Runs a scaleform with optional update callback +---@param scaleform number The scaleform handle to run +---@param onUpdate function Optional callback for updates during runtime function Scaleform.Run(scaleform, onUpdate) - if runningScaleform then return end - runningScaleform = scaleform + if activeScaleform then return end + activeScaleform = scaleform + CreateThread(function() - while runningScaleform do + while activeScaleform do DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0) + if onUpdate then - shouldQuit = onUpdate() - if shouldQuit then + local shouldStop = onUpdate() + if shouldStop then Scaleform.Stop() break end end - Wait(2) + + Wait(RENDER_WAIT_TIME) end end) end +---Stops the currently running scaleform function Scaleform.Stop() - runningScaleform = nil + activeScaleform = nil end exports("Scaleform", Scaleform) -return Scaleform \ No newline at end of file +return Scaleform From 5e016afc25229e61c751b392c6d3ce9e7b375409 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Sun, 11 May 2025 20:18:46 -0400 Subject: [PATCH 21/38] fix sharedConfig load order --- fxmanifest.lua | 2 +- modules/framework/es_extended/server.lua | 6 +++++- modules/framework/qb-core/server.lua | 2 ++ modules/framework/qbx_core/server.lua | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index 4668f29..556bcf1 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -9,8 +9,8 @@ version '0.7.0' shared_scripts { '@ox_lib/init.lua', - 'lib/init.lua', 'settings/sharedConfig.lua', + 'lib/init.lua', 'modules/math/*.lua', 'modules/locales/*.lua', } diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index faf8e02..5e125d9 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -1,5 +1,6 @@ ---@diagnostic disable: duplicate-set-field if GetResourceState('es_extended') ~= 'started' then return end +Prints = Prints or Require("lib/utility/shared/prints.lua") ESX = exports["es_extended"]:getSharedObject() @@ -251,7 +252,7 @@ Framework.SetPlayerJob = function(src, name, grade) local xPlayer = ESX.GetPlayerFromId(src) if not xPlayer then return end if not ESX.DoesJobExist(name, grade) then - lib.print.error("Job Does Not Exsist In Framework :NAME " .. name .. " Grade:" .. grade) + Prints.Error("Job Does Not Exsist In Framework :NAME " .. name .. " Grade:" .. grade) return end return xPlayer.setJob(name, grade, true) @@ -341,6 +342,7 @@ AddEventHandler("playerDropped", function() TriggerEvent("community_bridge:Server:OnPlayerUnload", src) end) +--<-- TODO swap to internal callback system lib.callback.register('community_bridge:Callback:GetFrameworkJobs', function(source) return Framework.GetFrameworkJobs() or {} end) @@ -354,3 +356,5 @@ Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, arguments = arguments }) end + +return Framework \ No newline at end of file diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index 707d1c6..c94145f 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -496,3 +496,5 @@ Framework.Commands = {} Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...) QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...) end + +return Framework \ No newline at end of file diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index 6845f27..ddc1017 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -452,3 +452,5 @@ AddEventHandler("playerDropped", function() local src = source TriggerEvent("community_bridge:Server:OnPlayerUnload", src) end) + +return Framework \ No newline at end of file From 567bd7a82418e6d2525f9ff12f7a9d91c63918b3 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Sun, 11 May 2025 20:36:07 -0400 Subject: [PATCH 22/38] TODO --- modules/framework/es_extended/client.lua | 1 + modules/inventory/core_inventory/client.lua | 1 + modules/inventory/core_inventory/server.lua | 1 + modules/phone/okokPhone/client.lua | 1 + modules/phone/okokPhone/server.lua | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/framework/es_extended/client.lua b/modules/framework/es_extended/client.lua index cea9a41..b0e3fca 100644 --- a/modules/framework/es_extended/client.lua +++ b/modules/framework/es_extended/client.lua @@ -15,6 +15,7 @@ Framework.GetPlayerData = function() return ESX.PlayerData end +--<-- TODO swap to internal callback system ---This will return a table of all the jobs in the framework. ---@return table Framework.GetFrameworkJobs = function() diff --git a/modules/inventory/core_inventory/client.lua b/modules/inventory/core_inventory/client.lua index e1d877c..95a5d27 100644 --- a/modules/inventory/core_inventory/client.lua +++ b/modules/inventory/core_inventory/client.lua @@ -12,6 +12,7 @@ Inventory.GetItemInfo = function(item) if not frameworkName then return {} end local dataRepack = {} if frameworkName == 'es_extended' then + --<-- TODO swap to internal callback system local callbackData = lib.callback.await('community_bridge:Callback:core_inventory', false) -- really really wish this inventory allowed me to pull the item list client side.... dataRepack = callbackData[item] diff --git a/modules/inventory/core_inventory/server.lua b/modules/inventory/core_inventory/server.lua index 0f24af5..43f1a25 100644 --- a/modules/inventory/core_inventory/server.lua +++ b/modules/inventory/core_inventory/server.lua @@ -221,6 +221,7 @@ Inventory.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups end +--<-- TODO swap to internal callback system -- 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. lib.callback.register('community_bridge:Callback:core_inventory', function(source) local items = core:getItemsList() diff --git a/modules/phone/okokPhone/client.lua b/modules/phone/okokPhone/client.lua index 5fd5def..c6fd86d 100644 --- a/modules/phone/okokPhone/client.lua +++ b/modules/phone/okokPhone/client.lua @@ -11,6 +11,7 @@ Phone = Phone or {} ---@return boolean ---@diagnostic disable-next-line: duplicate-set-field Phone.SendEmail = function(email, title, message) + --<-- TODO swap to internal callback system local success = lib.callback.await('community_bridge:Callback:okokPhone:sendEmail', false, email, title, message) --[[ @as boolean ]] return success end diff --git a/modules/phone/okokPhone/server.lua b/modules/phone/okokPhone/server.lua index 4897937..d493309 100644 --- a/modules/phone/okokPhone/server.lua +++ b/modules/phone/okokPhone/server.lua @@ -49,7 +49,7 @@ Phone.SendEmail = function(src, email, title, message) return success end - +--<-- TODO swap to internal callback system lib.callback.registry('community_bridge:Callback:okokPhone:sendEmail', function(src, email, title, message) return Phone.SendEmail(src, email, title, message) end) From b3417f9fdec546efa3e0a18700391c3d8c468b57 Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Sun, 11 May 2025 20:14:35 -0500 Subject: [PATCH 23/38] fixed minor issue in cutscenes insert witty joke here --- lib/cutscenes/client/cutscene.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/cutscenes/client/cutscene.lua b/lib/cutscenes/client/cutscene.lua index 2f12a1b..f192fbc 100644 --- a/lib/cutscenes/client/cutscene.lua +++ b/lib/cutscenes/client/cutscene.lua @@ -250,7 +250,7 @@ function Cutscene.Create(cutscene, coords, srcs) local isPedMale = IsPedMale(currentPed) local tag = isPedMale and tagTable.male or tagTable.female - local unusedTag = isPedMale and tagTable.female or tagTable.male + local unusedTag = not isPedMale and tagTable.male or tagTable.female -- needs to be this way as default has to be null for missing female SetCutsceneEntityStreamingFlags(tag, 0, 1) RegisterEntityForCutscene(currentPed, tag, 0, GetEntityModel(currentPed), 64) @@ -374,12 +374,21 @@ function Cutscene.Start(cutsceneData) if playerData.identifier == 'script' then DeleteEntity(ped) elseif playerData.identifier == 'localplayer' then - SetEntityCoords(ped, playerData.coords.x, playerData.coords.y, playerData.coords.z, false, false, false, - false) + SetEntityCoords(ped, playerData.coords.x, playerData.coords.y, playerData.coords.z, false, false, false, false) end ::continue:: end Cutscene.done = true end + +-- RegisterCommand('cutscene', function(source, args, rawCommand) +-- local cutscene = args[1] +-- if cutscene then +-- local cutsceneData = Cutscene.Create(cutscene, false, { 1,1,1 }) +-- Cutscene.Start(cutsceneData) + +-- end +-- end, false) + return Cutscene From 5bff52034c3db0540c8c6b77edaebf7bc400564e Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Sun, 11 May 2025 22:30:25 -0400 Subject: [PATCH 24/38] Update init.lua --- lib/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/init.lua b/lib/init.lua index e67a311..85897be 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -79,4 +79,5 @@ cLib.ClientStateBag = ClientStateBag or Require("lib/statebags/client/client.lua cLib.Marker = Marker or Require("lib/markers/client/markers.lua") cLib.Anim = Anim or Require("lib/anim/client/client.lua") cLib.Cutscene = Cutscene or Require("lib/cutscenes/client/cutscene.lua") +cLib.DUI = DUI or Require("lib/dui/client/dui.lua") return cLib From 6b63c290eab022f1ac6333cebfe472121530f9b4 Mon Sep 17 00:00:00 2001 From: Johann Kraus <56100605+JericoFX@users.noreply.github.com> Date: Sun, 11 May 2025 23:50:48 -0300 Subject: [PATCH 25/38] Add the modules to the env This will allow to the others resources to use the modules from the ENV table. --- init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 9ecdcc6..8db2673 100644 --- a/init.lua +++ b/init.lua @@ -21,7 +21,8 @@ function Bridge.RegisterModule(moduleName, moduleTable) print("^2 Registering module:", moduleName, "^0") end Bridge[moduleName] = wrappedModule - + _ENV[moduleName] = wrappedModule -- Add to the ENV table the modules so is more easy and safe to call from inside + _ENV.Bridge = Bridge -- Add the bridge too to the _ENV exports(moduleName, function() return wrappedModule From 2f7c40e8095c787afa300874eabe3f5d5fdade9c Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Mon, 12 May 2025 00:58:25 -0500 Subject: [PATCH 26/38] Server-sided markers and particles --- lib/init.lua | 3 + lib/markers/client/markers.lua | 23 +++++-- lib/markers/server/server.lua | 44 ++++++++++-- lib/particles/client/particles.lua | 104 +++++++++++++++++++++++++++-- lib/particles/server/particles.lua | 72 ++++++++++++++++++++ 5 files changed, 230 insertions(+), 16 deletions(-) create mode 100644 lib/particles/server/particles.lua diff --git a/lib/init.lua b/lib/init.lua index 85897be..7aa6a34 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -61,6 +61,7 @@ cLib.LootTables = LootTables or Require("lib/generators/server/lootTables.lua") cLib.Cache = Cache or Require("lib/cache/shared/cache.lua") cLib.ServerEntity = ServerEntity or Require("lib/entities/server/server_entity.lua") cLib.Marker = Marker or Require("lib/markers/server/server.lua") +cLib.Particle = Particle or Require("lib/particles/server/particles.lua") if IsDuplicityVersion() then return cLib end ::client:: @@ -80,4 +81,6 @@ cLib.Marker = Marker or Require("lib/markers/client/markers.lua") cLib.Anim = Anim or Require("lib/anim/client/client.lua") cLib.Cutscene = Cutscene or Require("lib/cutscenes/client/cutscene.lua") cLib.DUI = DUI or Require("lib/dui/client/dui.lua") +cLib.Particle = Particle or Require("lib/particles/client/particles.lua") + return cLib diff --git a/lib/markers/client/markers.lua b/lib/markers/client/markers.lua index fe42f79..30de853 100644 --- a/lib/markers/client/markers.lua +++ b/lib/markers/client/markers.lua @@ -1,8 +1,8 @@ ---@diagnostic disable: duplicate-set-field Marker = {} local Created = setmetatable({}, { __mode = "k" }) --what is mode? -local id = Ids or Require("lib/utility/shared/ids.lua") -local point = Require("lib/points/client/points.lua") +local Ids = Ids or Require("lib/utility/shared/ids.lua") +local point = Point or Require("lib/points/client/points.lua") local loopRunning = false local Drawing = {} @@ -29,7 +29,7 @@ end --- @param data table{position: vector3, offset: vector3, rotation: vector3, size: vector3, color: vector3, alpha: number, bobUpAndDown: boolean, marker: number, interaction: function} --- @return string|nil function Marker.Create(data) - local _id = data.id or id.Random() + local _id = data.id or Ids.CreateUniqueId(Created) if not validateMarkerData(data) then return end local basePosition = data.position or vector3(0.0, 0.0, 0.0) local baseOffset = data.offset or vector3(0.0, 0.0, 0.0) @@ -61,7 +61,7 @@ function Marker.Create(data) end, function(markerData) Drawing[_id] = nil - end + end, nil ) return _id end @@ -117,14 +117,27 @@ function Marker.Run(data) end RegisterNetEvent("community_bridge:Client:Marker", function(data) - print("community_bridge:Client:Marker") Marker.Create(data) end) +RegisterNetEvent("community_bridge:Client:MarkerBulk", function(datas) + if not datas then return end + for _, data in pairs(datas) do + Marker.Create(data) + end +end) + RegisterNetEvent("community_bridge:Client:MarkerRemove", function(id) Marker.Remove(id) end) +RegisterNetEvent("community_bridge:Client:MarkerRemoveBulk", function(ids) + if not ids then return end + for _, id in pairs(ids) do + Marker.Remove(id) + end +end) + -- local loopRunning = false -- function Marker.Draw() -- if loopRunning then return end diff --git a/lib/markers/server/server.lua b/lib/markers/server/server.lua index c281d61..c3b8717 100644 --- a/lib/markers/server/server.lua +++ b/lib/markers/server/server.lua @@ -3,7 +3,7 @@ local id = Ids or Require("lib/utility/shared/ids.lua") Marker = {} local Created = {} -function Marker.Create(data) +function Marker.New(data) if not data.position or not data.position.x or not data.position.y or not data.position.z then print("Invalid marker position. Must be a vector3 with x, y, and z coordinates.") return @@ -40,19 +40,49 @@ function Marker.Create(data) drawOnEnts = data.drawOnEnts, } Created[_id] = data - TriggerClientEvent("community_bridge:Client:Marker", -1, data) + return _id +end +function Marker.Destroy(id) + if not id or not Created[id] then return end + Created[id] = nil + return true +end + +function Marker.Create(data) + local _id = Marker.New(data) + if not _id then return end + TriggerClientEvent("community_bridge:Client:Marker", -1, Created[_id]) return _id end function Marker.Remove(id) - if not Created[id] then return end + if not Marker.Destroy(id) then return end TriggerClientEvent("community_bridge:Client:MarkerRemove", -1, id) - Created[id] = nil end -RegisterNetEvent("community_bridge:Server:MarkerRemove", function(id) - Marker.Remove(id) -end) +function Marker.CreateBulk(datas) + if not datas then return end + local toClient = {} + for k, v in pairs(datas) do + table.insert(toClient, Marker.Create(v)) + end + TriggerClientEvent("community_bridge:Client:MarkerBulk", -1, toClient) + return toClient +end + +function Marker.RemoveBulk(ids) + if not ids then return end + local toClient = {} + for k, v in pairs(ids) do + local id = v + if type(v) == "table" then + id = v.id + end + Marker.Destroy(id) + table.insert(toClient, id) + end + TriggerClientEvent("community_bridge:Client:MarkerRemoveBulk", -1, toClient) +end exports("Marker", Marker) return Marker diff --git a/lib/particles/client/particles.lua b/lib/particles/client/particles.lua index 28da84b..41c5533 100644 --- a/lib/particles/client/particles.lua +++ b/lib/particles/client/particles.lua @@ -1,4 +1,8 @@ +Particles = {} Particle = {} +---@diagnostic disable: duplicate-set-field +local Ids = Ids or Require("lib/utility/shared/ids.lua") +local point = Require("lib/points/client/points.lua") ---Loads a ptfx asset into memory. ---@param dict string @@ -14,7 +18,6 @@ function LoadPtfxAsset(dict) return HasNamedPtfxAssetLoaded(dict) end - --- Create a particle effect at the specified position and rotation. --- @param dict string --- @param ptfx string @@ -25,7 +28,7 @@ end --- @param looped boolean --- @param loopLength number|nil --- @return number|nil ptfxHandle -- The handle of the particle effect, or nil if it failed to create. -function Particle.Create(dict, ptfx, pos, rot, scale, color, looped, loopLength) +function Particle.Play(dict, ptfx, pos, rot, scale, color, looped, loopLength) LoadPtfxAsset(dict) UseParticleFxAssetNextCall(dict) SetParticleFxNonLoopedColour(color.x, color.y, color.z) @@ -45,14 +48,107 @@ function Particle.Create(dict, ptfx, pos, rot, scale, color, looped, loopLength) return particle end -function Particle.Remove(particle) +function Particle.Stop(particle) if not particle then return end StopParticleFxLooped(particle, false) RemoveParticleFx(particle, false) RemoveNamedPtfxAsset(particle) - end +function Particle.Create(data) + assert(data, "Particle data is nil") + assert(data.dict, "Invalid particle data. Must contain string dict.") + assert(data.ptfx, "Invalid particle data. Must contain string ptfx.") + + local _id = data.id or Ids.CreateUniqueId(Particles) + print("Creating particle", _id) + -- data for particles above + data = { + id = _id, + dict = data.dict, + ptfx = data.ptfx, + position = data.position or vector3(0.0, 0.0, 0.0), + rotation = data.rotation or vector3(0, 0, 0), + size = data.size or 1.0, + color = data.color or vector3(255, 255, 255), + looped = data.looped or false, + loopLength = data.loopLength or nil, + spawned = false, + } + Particles[_id] = data + + point.Register( -- checking if players in range + _id, + data.position, + data.drawDistance or 50.0, + data, + function(_) + if not Particles[_id] then return point.Remove(_id) end + local particleData = Particles[_id] + if particleData.spawned then return end + particleData.spawned = Particle.Play( + particleData.dict, + particleData.ptfx, + particleData.position, + particleData.rotation, + particleData.size, + particleData.color, + particleData.looped, + particleData.loopLength + ) + end, + function(markerData) + if not Particles[_id] then return end + local particleData = Particles[_id] + if not particleData.spawned then return end + Particle.Stop(particleData.spawned) + particleData.spawned = nil + end + ) + return _id +end + +function Particle.Remove(id) + if not id then return end + print("Removing particle1", id) + local particle = Particles[id] + print("Removing particle2", id) + if not particle then return end + print("Removing particle3", id) + Particle.Stop(particle.spawned) + Particles[id] = nil + point.Remove(id) +end + + + +RegisterNetEvent("community_bridge:Client:Particle", function(data) + if not data then return end + Particle.Create(data) +end) + +RegisterNetEvent("community_bridge:Client:ParticleBulk", function(datas) + if not datas then return end + for _, data in pairs(datas) do + Particle.Create(data) + end +end) + +RegisterNetEvent("community_bridge:Client:ParticleRemove", function(id) + local particle = Particles[id] + if not particle then return end + Particle.Remove(Drawing[id]) +end) + +RegisterNetEvent("community_bridge:Client:ParticleRemoveBulk", function(ids) + print("community_bridge:Client:ParticleRemoveBulk", ids) + for _, id in pairs(ids) do + Particle.Remove(id) + end +end) + + + function Particle.CreateOnEntity(dict, ptfx, entity, offset, rot, scale, color, looped, loopLength) LoadPtfxAsset(dict) UseParticleFxAssetNextCall(dict) diff --git a/lib/particles/server/particles.lua b/lib/particles/server/particles.lua new file mode 100644 index 0000000..f71ab68 --- /dev/null +++ b/lib/particles/server/particles.lua @@ -0,0 +1,72 @@ +---@diagnostic disable: duplicate-set-field + +Particles = {} +Particle = Particles or {} + +function Particle.New(data) + assert(data, "Particle data is nil") + assert(data.dict, "Invalid particle data. Must contain string dict.") + assert(data.ptfx, "Invalid particle data. Must contain string ptfx.") + + local _id = data.id or id.CreateUniqueId(Particles) + data = { + id = _id, + dict = data.dict, + ptfx = data.ptfx, + position = data.position or vector3(0.0, 0.0, 0.0), + rotation = data.rotation or vector3(0, 0, 0), + size = data.size or 1.0, + color = data.color or vector3(255, 255, 255), + looped = data.looped or false, + loopLength = data.loopLength or nil, + } + Particles[_id] = data + return data +end + +function Particle.Destroy(id) + if not id or not Particles[id] then return end + Particles[id] = nil + return true +end + +function Particle.Create(data) + local particleData = Particle.New(data) + if not particleData then return end + TriggerClientEvent("community_bridge:Client:Particle", -1, particleData) + return +end + + +function Particle.Remove(id) + if not Particle.Destroy(id) then return end + TriggerClientEvent("community_bridge:Client:ParticleRemove", -1, id) +end + +function Particle.CreateBulk(datas) + if not datas then return end + local toClient = {} + for k, v in pairs(datas) do + local data = Particle.New(v) + table.insert(toClient, data) + end + TriggerClientEvent("community_bridge:Client:ParticleBulk", -1, toClient) + return toClient +end + +function Particle.RemoveBulk(ids) + if not ids then return end + local toClient = {} + for k, v in pairs(ids) do + local id = v + if type(v) == "table" then + id = v.id + end + Particle.Destroy(id) + table.insert(toClient, id) + end + TriggerClientEvent("community_bridge:Client:ParticleRemoveBulk", -1, toClient) + return ids +end + +return Particle \ No newline at end of file From 340b57d301aa34f2def69f9c0f8aa9ae85984faf Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Mon, 12 May 2025 02:44:27 -0500 Subject: [PATCH 27/38] marker fix wasnt drawing at the correct location just the first location. cleaned up prints in particles --- lib/markers/client/markers.lua | 67 ++++++------------------------ lib/markers/server/server.lua | 13 ------ lib/particles/client/particles.lua | 6 --- 3 files changed, 13 insertions(+), 73 deletions(-) diff --git a/lib/markers/client/markers.lua b/lib/markers/client/markers.lua index 30de853..a747e20 100644 --- a/lib/markers/client/markers.lua +++ b/lib/markers/client/markers.lua @@ -37,7 +37,6 @@ function Marker.Create(data) local data = { id = _id, position = vector3(basePosition.x + baseOffset.x, basePosition.y + baseOffset.y, basePosition.z + baseOffset.z), - offset = baseOffset, marker = data.marker or 1, rotation = data.rotation or vector3(0, 0, 0), size = data.size or vector3(1.0, 1.0, 1.0), @@ -57,7 +56,7 @@ function Marker.Create(data) function(_) if not Created[_id] then return point.Remove(_id) end Drawing[_id] = Created[_id] - Marker.Run(Drawing[_id]) + Marker.Run() end, function(markerData) Drawing[_id] = nil @@ -89,25 +88,29 @@ end -- This will loop through all marker(points) in range and draw them. -- @param data table{marker: number, position: vector3, rotation: vector3, size: vector3, color: vector3, alpha: number, bobUpAndDown: boolean, faceCamera: boolean, rotate: boolean, textureDict: string, textureName: string, drawOnEnts: boolean} -- @return nil -function Marker.Run(data) +function Marker.Run() if loopRunning then return end loopRunning = true CreateThread(function() while loopRunning do + if not next(Created) then + loopRunning = false + return + end for drawingId, drawingData in pairs(Drawing) do if not Created[drawingId] then Drawing[drawingId] = nil goto continue end DrawMarker( - data.marker, - data.position.x, data.position.y, data.position.z, + drawingData.marker, + drawingData.position.x, drawingData.position.y, drawingData.position.z, 0.0, 0.0, 0.0, - data.rotation.x, data.rotation.y, data.rotation.z, - data.size.x, data.size.y, data.size.z, - data.color.x, data.color.y, data.color.z, data.alpha, - data.bobUpAndDown, data.faceCamera, false, - data.rotate, data.textureDict, data.textureName, data.drawOnEnts + drawingData.rotation.x, drawingData.rotation.y, drawingData.rotation.z, + drawingData.size.x, drawingData.size.y, drawingData.size.z, + drawingData.color.x, drawingData.color.y, drawingData.color.z, drawingData.alpha, + drawingData.bobUpAndDown, drawingData.faceCamera, false, + drawingData.rotate, drawingData.textureDict, drawingData.textureName, drawingData.drawOnEnts ) ::continue:: end @@ -138,50 +141,6 @@ RegisterNetEvent("community_bridge:Client:MarkerRemoveBulk", function(ids) end end) --- local loopRunning = false --- function Marker.Draw() --- if loopRunning then return end --- loopRunning = true --- while loopRunning do --- Wait(0) --- if not next(Created) then --- Wait(1000) -- Reduce CPU usage when no markers are present --- goto continue --- end - --- for id, _ in pairs(Created) do --- if Created[id] then --- local data = Created[id] --- if #(data.position - GetEntityCoords(PlayerPedId())) > 100.0 then --- goto continue --- else --- DrawMarker( --- data.marker, --- data.position.x, data.position.y, data.position.z, --- 0.0, 0.0, 0.0, --- data.rotation.x, data.rotation.y, data.rotation.z, --- data.size.x, data.size.y, data.size.z, --- data.color.x, data.color.y, data.color.z, data.alpha, --- data.bobUpAndDown, data.faceCamera, false, --- data.rotate, data.textureDict, data.textureName, data.drawOnEnts --- ) --- -- if data.interaction then --- -- local playerCoords = GetEntityCoords(PlayerPedId()) --- -- local distance = #(data.position - playerCoords) --- -- if distance < 2.0 then --- -- if IsControlJustReleased(0, 38) then -- E key --- -- data.interaction(data.id) --- -- end --- -- end --- -- end --- end --- end --- end --- ::continue:: --- end --- end - --- Marker.Draw() -- Start the marker drawing loop exports("Marker", Marker) diff --git a/lib/markers/server/server.lua b/lib/markers/server/server.lua index c3b8717..62719dc 100644 --- a/lib/markers/server/server.lua +++ b/lib/markers/server/server.lua @@ -8,19 +8,6 @@ function Marker.New(data) print("Invalid marker position. Must be a vector3 with x, y, and z coordinates.") return end - if data.offset and (not data.offset.x or not data.offset.y or not data.offset.z) then - print("Invalid marker offset. Must be a vector3 with x, y, and z coordinates.") - return - end - if data.rotation and (not data.rotation.x or not data.rotation.y or not data.rotation.z) then - print("Invalid marker rotation. Must be a vector3 with x, y, and z coordinates.") - return - end - - if not data.size or not data.size.x or not data.size.y or not data.size.z then - print("Invalid marker size. Must be a vector3 with x, y, and z dimensions.") - return - end local _id = data.id or id.CreateUniqueId(Created) local data = { diff --git a/lib/particles/client/particles.lua b/lib/particles/client/particles.lua index 41c5533..d425163 100644 --- a/lib/particles/client/particles.lua +++ b/lib/particles/client/particles.lua @@ -61,8 +61,6 @@ function Particle.Create(data) assert(data.ptfx, "Invalid particle data. Must contain string ptfx.") local _id = data.id or Ids.CreateUniqueId(Particles) - print("Creating particle", _id) - -- data for particles above data = { id = _id, dict = data.dict, @@ -110,11 +108,8 @@ end function Particle.Remove(id) if not id then return end - print("Removing particle1", id) local particle = Particles[id] - print("Removing particle2", id) if not particle then return end - print("Removing particle3", id) Particle.Stop(particle.spawned) Particles[id] = nil point.Remove(id) @@ -141,7 +136,6 @@ RegisterNetEvent("community_bridge:Client:ParticleRemove", function(id) end) RegisterNetEvent("community_bridge:Client:ParticleRemoveBulk", function(ids) - print("community_bridge:Client:ParticleRemoveBulk", ids) for _, id in pairs(ids) do Particle.Remove(id) end From 7927927394d4be5e810eedd20f1c9221e8a8f1b8 Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Mon, 12 May 2025 02:48:11 -0500 Subject: [PATCH 28/38] lil more cleanup i love prints! --- lib/entities/client/client_entity.lua | 2 - .../client/client_entity_actions_ext.lua | 43 +++++++++---------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/lib/entities/client/client_entity.lua b/lib/entities/client/client_entity.lua index 7835763..d3764ff 100644 --- a/lib/entities/client/client_entity.lua +++ b/lib/entities/client/client_entity.lua @@ -159,12 +159,10 @@ end -- Network Event Handlers RegisterNetEvent("community_bridge:client:CreateEntity", function(entityData) - print(string.format("[ClientEntity] Received entity %s", entityData.id)) ClientEntity.Register(entityData) end) RegisterNetEvent("community_bridge:client:DeleteEntity", function(id) - print(string.format("[ClientEntity] Deleting entity %s", id)) ClientEntity.Unregister(id) end) diff --git a/lib/entities/client/client_entity_actions_ext.lua b/lib/entities/client/client_entity_actions_ext.lua index 8c03bad..4033e29 100644 --- a/lib/entities/client/client_entity_actions_ext.lua +++ b/lib/entities/client/client_entity_actions_ext.lua @@ -34,14 +34,14 @@ function DefaultActions.WalkTo(entityData, coords, speed, timeout) ClientEntityActions.ActionThreads[entityId] = thread end --- Internal implementation for playing an animation. Registered via RegisterAction. --- @param entityData table --- @param animDict string --- @param animName string --- @param blendIn number (Optional, default 8.0) --- @param blendOut number (Optional, default -8.0) --- @param duration number (Optional, default -1 for loop/until stopped) --- @param flag number (Optional, default 0) --- @param playbackRate number (Optional, default 0.0) +--- @param entityData table +--- @param animDict string +--- @param animName string +--- @param blendIn number (Optional, default 8.0) +--- @param blendOut number (Optional, default -8.0) +--- @param duration number (Optional, default -1 for loop/until stopped) +--- @param flag number (Optional, default 0) +--- @param playbackRate number (Optional, default 0.0) function DefaultActions.PlayAnim(entityData, animDict, animName, blendIn, blendOut, duration, flag, playbackRate) local entity = entityData.spawned local entityId = entityData.id @@ -156,17 +156,17 @@ function DefaultActions.LerpTo(entityData, targetCoords, duration, easingType, e ClientEntityActions.ActionThreads[entityId] = thread end --- Internal implementation for attaching a prop. Registered via RegisterAction. --- This action completes immediately after attaching. Use DetachProp to remove. --- @param entityData table --- @param propModel string|number --- @param boneIndex number (Optional, default -1 for root) --- @param offsetPos vector3 (Optional, default vector3(0,0,0)) --- @param offsetRot vector3 (Optional, default vector3(0,0,0)) --- @param useSoftPinning boolean (Optional, default false) --- @param collision boolean (Optional, default false) --- @param isPed boolean (Optional, default false) - Seems unused in native? --- @param vertexIndex number (Optional, default 2) - Seems unused in native? --- @param fixedRot boolean (Optional, default true) +--- This action completes immediately after attaching. Use DetachProp to remove. +--- @param entityData table +--- @param propModel string|number +--- @param boneIndex number (Optional, default -1 for root) +--- @param offsetPos vector3 (Optional, default vector3(0,0,0)) +--- @param offsetRot vector3 (Optional, default vector3(0,0,0)) +--- @param useSoftPinning boolean (Optional, default false) +--- @param collision boolean (Optional, default false) +--- @param isPed boolean (Optional, default false) - Seems unused in native? +--- @param vertexIndex number (Optional, default 2) - Seems unused in native? +--- @param fixedRot boolean (Optional, default true) function DefaultActions.AttachProp(entityData, propModel, boneName, offsetPos, offsetRot, useSoftPinning, collision, isPed, vertexIndex, fixedRot) local entity = entityData.spawned local entityId = entityData.id @@ -205,8 +205,8 @@ function DefaultActions.AttachProp(entityData, propModel, boneName, offsetPos, o ClientEntityActions.ProcessNextAction(entityId) end --- Internal implementation for detaching a prop. Registered via RegisterAction. --- @param entityData table --- @param propModel string|number The model name/hash of the prop to detach. +--- @param entityData table +--- @param propModel string|number The model name/hash of the prop to detach. function DefaultActions.DetachProp(entityData, propModel) local entityId = entityData.id @@ -264,7 +264,6 @@ function DefaultActions.GetInCar(entityData, vehicleData, seatIndex, timeout) end function DefaultActions.Freeze(entityData, freeze) - print("[ClientEntityActions] Freeze action called", freeze) local entity = entityData.spawned local entityId = entityData.id From 42fe204615a70e560dc6d6586853bd30d2ad1a0e Mon Sep 17 00:00:00 2001 From: JericoFX Date: Mon, 12 May 2025 11:46:47 -0300 Subject: [PATCH 29/38] Refactor cLib initialization and modularize server/client libraries --- init.lua | 33 +++++++++++------ lib/init.lua | 100 ++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 109 insertions(+), 24 deletions(-) diff --git a/init.lua b/init.lua index 8db2673..d9818c8 100644 --- a/init.lua +++ b/init.lua @@ -22,7 +22,7 @@ function Bridge.RegisterModule(moduleName, moduleTable) end Bridge[moduleName] = wrappedModule _ENV[moduleName] = wrappedModule -- Add to the ENV table the modules so is more easy and safe to call from inside - _ENV.Bridge = Bridge -- Add the bridge too to the _ENV + _ENV.Bridge = Bridge -- Add the bridge too to the _ENV exports(moduleName, function() return wrappedModule @@ -31,19 +31,26 @@ function Bridge.RegisterModule(moduleName, moduleTable) --trigger update object event TriggerEvent("Bridge:Refresh", moduleName, wrappedModule) end +CreateThread(function() -- lets try to load the lib first to use it on the rest of the modules + for k, v in pairs(cLib) do + if v then + Bridge.RegisterModule(k, v) + end + end +end) exports("RegisterModule", Bridge.RegisterModule) --TODO: Create a way to overide functions or create a new functions for module function Bridge.RegisterModuleFunction(moduleName, functionName, func) - assert(moduleName and functionName and func, string.format("Bridge.RegisterModuleFunction(%s, %s, %s) - Invalid arguments", moduleName, functionName, func)) + assert(moduleName and functionName and func, + string.format("Bridge.RegisterModuleFunction(%s, %s, %s) - Invalid arguments", moduleName, functionName, func)) Bridge[moduleName] = Bridge[moduleName] or {} Bridge[moduleName][functionName] = func --trigger update object event TriggerEvent("Bridge:Refresh", moduleName, Bridge[moduleName]) end - --Bridge Bridge.RegisterModule("Framework", Framework) Bridge.RegisterModule("Inventory", Inventory) @@ -75,23 +82,27 @@ Bridge.RegisterModule("Require", Require) -- Bridge.RegisterModule("Skills", Skills) -for k, v in pairs(cLib) do - if v then - Bridge.RegisterModule(k, v) + + +--[[ CreateThread(function() -- using metatables + for k, v in pairs(cLib.loaded) do + if v then + Bridge.RegisterModule(k, v) + end end -end +end) ]] exports('Bridge', function() return Bridge end) --- ▄▀▀ ██▀ █▀▄ █ █ ██▀ █▀▄ --- ▄█▀ █▄▄ █▀▄ ▀▄▀ █▄▄ █▀▄ +-- ▄▀▀ ██▀ █▀▄ █ █ ██▀ █▀▄ +-- ▄█▀ █▄▄ █▀▄ ▀▄▀ █▄▄ █▀▄ if not IsDuplicityVersion() then goto client end Bridge.RegisterModule('Version', Version) --- ▄▀▀ █ █ ██▀ █▄ █ ▀█▀ --- ▀▄▄ █▄▄ █ █▄▄ █ ▀█ █ +-- ▄▀▀ █ █ ██▀ █▄ █ ▀█▀ +-- ▀▄▄ █▄▄ █ █▄▄ █ ▀█ █ if IsDuplicityVersion() then return end ::client:: diff --git a/lib/init.lua b/lib/init.lua index 7aa6a34..9db3466 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -1,4 +1,5 @@ loadedModules = {} +local cLib = {} function Require(modulePath, resourceName) if resourceName and type(resourceName) ~= "string" then @@ -35,23 +36,95 @@ function Require(modulePath, resourceName) return result end +local function getServerLib() + return { + SQL = SQL or Require("lib/sql/server/sqlHandler.lua"), + Logs = Logs or Require("lib/logs/server/logs.lua"), + ItemsBuilder = ItemsBuilder or Require("lib/generators/server/ItemsBuilder.lua"), + LootTables = LootTables or Require("lib/generators/server/lootTables.lua"), + Cache = Cache or Require("lib/cache/shared/cache.lua"), + ServerEntity = ServerEntity or Require("lib/entities/server/server_entity.lua"), + Marker = Marker or Require("lib/markers/server/server.lua"), + Particle = Particle or Require("lib/particles/server/particles.lua"), + } +end +local function getClientLib() + return { + Require = Require, + Gizmo = Gizmo or Require("lib/placers/client/gizmo.lua"), + Scaleform = Scaleform or Require("lib/scaleform/client/scaleform.lua"), + Placeable = Placeable or Require("lib/placers/client/object_placer.lua"), + Utility = Utility or Require("lib/utility/client/utility.lua"), + PlaceableObject = PlaceableObject or Require("lib/placers/client/placeable_object.lua"), + Raycast = Raycast or Require("lib/raycast/client/raycast.lua"), + Point = Point or Require("lib/points/client/points.lua"), + Particle = Particle or Require("lib/particles/client/particles.lua"), + Cache = Cache or Require("lib/cache/client/cache.lua"), + ClientEntity = ClientEntity or Require("lib/entities/client/client_entity.lua"), + ClientEntityActions = ClientEntityActions or Require("lib/entities/client/client_entity_actions.lua"), + ClientStateBag = ClientStateBag or Require("lib/statebags/client/client.lua"), + Marker = Marker or Require("lib/markers/client/markers.lua"), + Anim = Anim or Require("lib/anim/client/client.lua"), + Cutscene = Cutscene or Require("lib/cutscenes/client/cutscene.lua"), + DUI = DUI or Require("lib/dui/client/dui.lua"), + } +end -cLib = { - Require = Require, - Callback = Callback or Require("lib/utility/shared/callbacks.lua"), - Ids = Ids or Require("lib/utility/shared/ids.lua"), - ReboundEntities = ReboundEntities or Require("lib/utility/shared/rebound_entities.lua"), - Tables = Tables or Require("lib/utility/shared/tables.lua"), - Prints = Prints or Require("lib/utility/shared/prints.lua"), - Math = Math or Require("lib/utility/shared/math.lua"), - LA = LA or Require("lib/utility/shared/la.lua"), - Perlin = Perlin or Require("lib/utility/shared/perlin.lua"), - -- Action = Action or Require("lib/entities/shared/actions.lua"), -} +local function getSharedLib() + return { + Require = Require, + Callback = Callback or Require("lib/utility/shared/callbacks.lua"), + Ids = Ids or Require("lib/utility/shared/ids.lua"), + ReboundEntities = ReboundEntities or Require("lib/utility/shared/rebound_entities.lua"), + Tables = Tables or Require("lib/utility/shared/tables.lua"), + Prints = Prints or Require("lib/utility/shared/prints.lua"), + Math = Math or Require("lib/utility/shared/math.lua"), + LA = LA or Require("lib/utility/shared/la.lua"), + Perlin = Perlin or Require("lib/utility/shared/perlin.lua"), + -- Action = Action or Require("lib/entities/shared/actions.lua"), + } +end -exports('cLib', cLib) +cLib = setmetatable(getSharedLib(), { __index = IsDuplicityVersion() and getServerLib() or getClientLib() }) +_ENV.cLib = cLib +_ENV.Require = Require +exports('cLib', function() + return cLib +end) +--[[ _ENV.cLib = setmetatable({ + context = not IsDuplicityVersion() and "client" or "server", + resource = GetCurrentResourceName(), + loaded = {} +}, { + __newindex = function(self, key, value) + return error("Attempt to modify read-only table: " .. key) + end, + __index = function(self, key) -- modify the index function to load the library modules + if self.context == "server" then + return rawget(self.loaded, key) + else + return rawget(self.loaded, key) + end + end, + __call = function(self) -- modify the call function to load the library modules + if self.context == "server" then + if not next(self.loaded) then + self.loaded = getServerLib() + return true + end + else + if not next(self.loaded) then + self.loaded = getClientLib() + return true + end + end + end, +}) +cLib() -- load the library modules ]] + +--[[ if not IsDuplicityVersion() then goto client end cLib.SQL = SQL or Require("lib/sql/server/sqlHandler.lua") @@ -84,3 +157,4 @@ cLib.DUI = DUI or Require("lib/dui/client/dui.lua") cLib.Particle = Particle or Require("lib/particles/client/particles.lua") return cLib + ]] From 68aa645494d27f9dde8522a58b01afea687d9d26 Mon Sep 17 00:00:00 2001 From: JericoFX Date: Mon, 12 May 2025 12:13:16 -0300 Subject: [PATCH 30/38] Refactor global environment setup by removing redundant assignments to _ENV --- init.lua | 14 +++++++++++++- lib/init.lua | 2 -- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index d9818c8..6a1c9cc 100644 --- a/init.lua +++ b/init.lua @@ -22,7 +22,7 @@ function Bridge.RegisterModule(moduleName, moduleTable) end Bridge[moduleName] = wrappedModule _ENV[moduleName] = wrappedModule -- Add to the ENV table the modules so is more easy and safe to call from inside - _ENV.Bridge = Bridge -- Add the bridge too to the _ENV + exports(moduleName, function() return wrappedModule @@ -31,6 +31,7 @@ function Bridge.RegisterModule(moduleName, moduleTable) --trigger update object event TriggerEvent("Bridge:Refresh", moduleName, wrappedModule) end + CreateThread(function() -- lets try to load the lib first to use it on the rest of the modules for k, v in pairs(cLib) do if v then @@ -38,6 +39,17 @@ CreateThread(function() -- lets try to load the lib first to use it on the rest end end end) + +--- @module GlobalEnvironment +--- @field cLib table # Core library utilities, available globally after initialization. +--- @field Require fun(module: string): any # Function to require/load modules by name. + +--- Global environment setup. +-- The following assignments expose core utilities globally, +-- making them accessible in all subsequently loaded modules. + +_ENV.cLib = cLib ~= nil and cLib or export.community_lib.cLib() ---@type table +_ENV.Require = Require ---@type fun(module: string): any exports("RegisterModule", Bridge.RegisterModule) --TODO: Create a way to overide functions or create a new functions for module diff --git a/lib/init.lua b/lib/init.lua index 9db3466..4003b66 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -87,8 +87,6 @@ local function getSharedLib() end cLib = setmetatable(getSharedLib(), { __index = IsDuplicityVersion() and getServerLib() or getClientLib() }) -_ENV.cLib = cLib -_ENV.Require = Require exports('cLib', function() return cLib end) From 3ea66043ea71b862d6c17fc2da8936bce8f398ff Mon Sep 17 00:00:00 2001 From: JericoFX Date: Mon, 12 May 2025 14:24:32 -0300 Subject: [PATCH 31/38] Enhance cache module with improved type annotations and error handling; allow nil wait times for dynamic caching --- lib/cache/client/cache.lua | 10 +-- lib/cache/shared/cache.lua | 121 ++++++++++++++++++++++++++----------- 2 files changed, 92 insertions(+), 39 deletions(-) diff --git a/lib/cache/client/cache.lua b/lib/cache/client/cache.lua index df493c8..b9aefdc 100644 --- a/lib/cache/client/cache.lua +++ b/lib/cache/client/cache.lua @@ -54,10 +54,10 @@ local function GetWeapon() return GetSelectedPedWeapon(ped) end -Cache.Create("Ped", GetPed, 1000) -- Check ped every second (adjust as needed) -Cache.Create("Vehicle", GetVehicle, 500) -- Check vehicle every 500ms -Cache.Create("Seat", GetVehicleSeat, 500) -- Check if in vehicle every 500ms -Cache.Create("Weapon", GetWeapon, 250) -- Check weapon every 250ms -Cache.Create("ServerId", GetServerId, 1000) -- Check server ID every second +Cache.Create("Ped", GetPed, nil) -- Check ped every second (adjust as needed) +Cache.Create("Vehicle", GetVehicle, 500) -- Check vehicle every 500ms +Cache.Create("Seat", GetVehicleSeat, 500) -- Check if in vehicle every 500ms +Cache.Create("Weapon", GetWeapon, 250) -- Check weapon every 250ms +Cache.Create("ServerId", GetServerId, nil) -- Check server ID every second return Cache diff --git a/lib/cache/shared/cache.lua b/lib/cache/shared/cache.lua index ed42a50..c6fe0b1 100644 --- a/lib/cache/shared/cache.lua +++ b/lib/cache/shared/cache.lua @@ -1,29 +1,54 @@ -local Cache = {} +---@class CacheEntry +---@field Name string +---@field Compare fun(): any +---@field WaitTime integer +---@field LastChecked integer|nil +---@field OnChange fun(new:any, old:any)[] +---@field Value any + +---@class CacheModule +---@field Caches table +---@field LoopRunning boolean +---@field Create fun(name:string, compare:fun():any, waitTime?:integer): CacheEntry +---@field Get fun(name:string): any +---@field OnChange fun(name:string, onChange:fun(new:any, old:any)) +---@field Remove fun(name:string) +local Cache = {} ---@type CacheModule + local Config = Require("settings/sharedConfig.lua") local max = 5000 local CreateThread = CreateThread local Wait = Wait local GetGameTimer = GetGameTimer - Cache.Caches = Cache.Caches or {} Cache.LoopRunning = Cache.LoopRunning or false -local function print(...) +---@param ... any +local function debugPrint(...) if Config.DebugLevel == 0 then return end print("^2[Cache]^0", ...) end +local function HasActiveCaches() + for _, cache in pairs(Cache.Caches) do + if cache.WaitTime ~= nil then + return true + end + end + return false +end + local function StartLoop() if Cache.LoopRunning then return end + if not HasActiveCaches() then return end Cache.LoopRunning = true CreateThread(function() while Cache.LoopRunning do local now = GetGameTimer() local minWait = nil - local caches = Cache.Caches - for name, cache in pairs(caches) do - if cache.Compare then + for name, cache in pairs(Cache.Caches) do + if cache.Compare and cache.WaitTime ~= nil then cache.LastChecked = cache.LastChecked or now cache.WaitTime = cache.WaitTime or max local elapsed = now - cache.LastChecked @@ -32,8 +57,8 @@ local function StartLoop() local oldValue = cache.Value cache.Value = cache.Compare() if cache.Value ~= oldValue and cache.OnChange then - for _, onChange in pairs(cache.OnChange) do - onChange(cache.Value, oldValue) + for i = 1, #cache.OnChange do + cache.OnChange[i](cache.Value, oldValue) end end cache.LastChecked = now @@ -50,44 +75,53 @@ local function StartLoop() else Wait(max) end + -- if there is no cache valid, stop the loop + if not HasActiveCaches() then + Cache.LoopRunning = false + end end end) end +---@param name string +---@param compare fun():any +---@param waitTime? integer +---@return CacheEntry function Cache.Create(name, compare, waitTime) assert(name, "Cache name is required.") assert(compare, "Comparison function is required.") assert(type(compare) == "function", "Comparison function must be a function.") - local _name = tostring(name) -- Ensure name is a string + local _name = tostring(name) local cache = Cache.Caches[_name] if cache and cache.Compare == compare then - print(name .. " already exists with the same comparison function.") + debugPrint(_name .. " already exists with the same comparison function.") return cache end - cache = nil -- clean variable, so we can use the same name for the new cache - local s, r = pcall(function() -- Try to create the cache and catch any errors - local _cache = { - Name = _name, - Compare = compare, - WaitTime = waitTime or max, - LastChecked = nil, - OnChange = {}, - Value = compare() - } - Cache.Caches[_name] = _cache - print(_name .. " created with initial value: " .. tostring(Cache.Caches[_name].Value)) - for _, onChange in pairs(_cache.OnChange) do - onChange(_cache.Value, nil) - end - end) - if not s then - print("Error creating cache '" .. _name .. "': " .. tostring(r)) + local ok, result = pcall(compare) + if not ok then + debugPrint("Error creating cache '" .. _name .. "': " .. tostring(result)) return nil end - - return StartLoop() + ---@type CacheEntry + local newCache = { + Name = _name, + Compare = compare, + WaitTime = waitTime, -- can be nil + LastChecked = nil, + OnChange = {}, + Value = result + } + Cache.Caches[_name] = newCache + debugPrint(_name .. " created with initial value: " .. tostring(result)) + for i = 1, #newCache.OnChange do + newCache.OnChange[i](newCache.Value, nil) + end + StartLoop() + return newCache end +---@param name string +---@return any function Cache.Get(name) assert(name, "Cache name is required.") local _name = tostring(name) @@ -95,25 +129,44 @@ function Cache.Get(name) return cache and cache.Value or nil end +---@param name string +---@param onChange fun(new:any, old:any) function Cache.OnChange(name, onChange) assert(name, "Cache name is required.") - local _name = tostring(name) -- Ensure name is a string + local _name = tostring(name) local cache = Cache.Caches[_name] assert(cache, "Cache with name '" .. _name .. "' does not exist.") cache.OnChange[#cache.OnChange + 1] = onChange end +---@param name string function Cache.Remove(name) assert(name, "Cache name is required.") - local _name = tostring(name) -- Ensure name is a string + local _name = tostring(name) local cache = Cache.Caches[_name] if cache then Cache.Caches[_name] = nil - print(_name .. " removed from cache.") + debugPrint(_name .. " removed from cache.") if next(Cache.Caches) == nil then - Cache.LoopRunning = false -- Stop the loop if no caches are left + Cache.LoopRunning = false end end end +setmetatable(Cache, { + __index = function(self, key) + local cache = self.Caches[key] + if cache then + return cache.Value + else + return rawget(self, key) + end + end, + __call = function(self, key) + return self.Get(self, key) + end, +}) + +-- with this change now we can use Cache("name") to get the value or simple Cache.name (Cache.Get("name")) + return Cache From c1c5626df365d99d278b82d2ef0523622f90e6af Mon Sep 17 00:00:00 2001 From: JericoFX Date: Mon, 12 May 2025 14:31:33 -0300 Subject: [PATCH 32/38] add update function to cache --- lib/cache/shared/cache.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/cache/shared/cache.lua b/lib/cache/shared/cache.lua index c6fe0b1..05b5359 100644 --- a/lib/cache/shared/cache.lua +++ b/lib/cache/shared/cache.lua @@ -139,6 +139,22 @@ function Cache.OnChange(name, onChange) cache.OnChange[#cache.OnChange + 1] = onChange end +---@param name string +---@param newValue any +function Cache.Update(name, newValue) + assert(name, "Cache name is required.") + local _name = tostring(name) + local cache = Cache.Caches[_name] + assert(cache, "Cache with name '" .. _name .. "' does not exist.") + local oldValue = cache.Value + if oldValue ~= newValue then + cache.Value = newValue + for i = 1, #cache.OnChange do + cache.OnChange[i](newValue, oldValue) + end + end +end + ---@param name string function Cache.Remove(name) assert(name, "Cache name is required.") From 0dc3d51319271f4aa5ba7fd44a373577b70174b4 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Mon, 12 May 2025 23:13:08 -0400 Subject: [PATCH 33/38] psuh for crowley --- init.lua | 20 +------------------- modules/framework/es_extended/client.lua | 12 +++--------- modules/framework/qb-core/client.lua | 10 ++-------- modules/framework/qbx_core/client.lua | 10 ++-------- 4 files changed, 8 insertions(+), 44 deletions(-) diff --git a/init.lua b/init.lua index 6a1c9cc..bde914e 100644 --- a/init.lua +++ b/init.lua @@ -48,7 +48,7 @@ end) -- The following assignments expose core utilities globally, -- making them accessible in all subsequently loaded modules. -_ENV.cLib = cLib ~= nil and cLib or export.community_lib.cLib() ---@type table +_ENV.cLib = cLib ~= nil and cLib or exports.community_bridge:cLib() ---@type table _ENV.Require = Require ---@type fun(module: string): any exports("RegisterModule", Bridge.RegisterModule) @@ -129,21 +129,3 @@ Bridge.RegisterModule("Target", Target) Bridge.RegisterModule("Menu", Menu) Bridge.RegisterModule("Dialogue", Dialogue) Bridge.RegisterModule("Accessibility", Accessibility) -- new - --- Fill the bridge tables with player data. -function FillBridgeTables() - PlayerLoaded = true - PlayerIdentifier = Framework.GetPlayerIdentifier() - PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel = Framework.GetPlayerJob() -end - --- Clean the bridge tables. -function ClearClientSideVariables() - PlayerLoaded = false - PlayerIdentifier = nil - PlayerJobName = nil - PlayerJobLabel = nil - PlayerJobGradeName = nil - PlayerJobGradeLevel = nil - StoredOldClothing = {} -end diff --git a/modules/framework/es_extended/client.lua b/modules/framework/es_extended/client.lua index b0e3fca..9b4f0a2 100644 --- a/modules/framework/es_extended/client.lua +++ b/modules/framework/es_extended/client.lua @@ -119,21 +119,15 @@ end RegisterNetEvent('esx:playerLoaded', function(xPlayer) Wait(1500) - FillBridgeTables() - TriggerEvent('community_bridge:Client:OnPlayerLoaded') + TriggerEvent('community_bridge:Client:OnPlayerLoaded') end) RegisterNetEvent('esx:onPlayerLogout', function() - ClearClientSideVariables() - TriggerEvent('community_bridge:Client:OnPlayerUnload') + TriggerEvent('community_bridge:Client:OnPlayerUnload') end) RegisterNetEvent('esx:setJob', function(data) - PlayerJobName = data.name - PlayerJobLabel = data.label - PlayerJobGradeName = data.grade_label - PlayerJobGradeLevel = data.grade - TriggerEvent('community_bridge:Client:OnPlayerJobUpdate',PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel) + TriggerEvent('community_bridge:Client:OnPlayerJobUpdate', data.name, data.label, data.grade_label, data.grade) end) return Framework \ No newline at end of file diff --git a/modules/framework/qb-core/client.lua b/modules/framework/qb-core/client.lua index 71639aa..180adf1 100644 --- a/modules/framework/qb-core/client.lua +++ b/modules/framework/qb-core/client.lua @@ -148,21 +148,15 @@ Framework.Shared = QBCore.Shared RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() Wait(1500) - FillBridgeTables() TriggerEvent('community_bridge:Client:OnPlayerLoaded') end) RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() - ClearClientSideVariables() - TriggerEvent('community_bridge:Client:OnPlayerUnload') + TriggerEvent('community_bridge:Client:OnPlayerUnload') end) RegisterNetEvent('QBCore:Client:OnJobUpdate', function(data) - PlayerJobName = data.name - PlayerJobLabel = data.label - PlayerJobGradeName = data.grade.name - PlayerJobGradeLevel = data.grade.level - TriggerEvent('community_bridge:Client:OnPlayerJobUpdate', PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel) + TriggerEvent('community_bridge:Client:OnPlayerJobUpdate', data.name, data.label, data.grade.name, data.grade.level) end) RegisterNetEvent('QBCore:Client:OnGangUpdate', function(data) diff --git a/modules/framework/qbx_core/client.lua b/modules/framework/qbx_core/client.lua index 2fee358..20e6805 100644 --- a/modules/framework/qbx_core/client.lua +++ b/modules/framework/qbx_core/client.lua @@ -74,21 +74,15 @@ end RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() Wait(1500) - FillBridgeTables() TriggerEvent('community_bridge:Client:OnPlayerLoaded') end) RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() - ClearClientSideVariables() - TriggerEvent('community_bridge:Client:OnPlayerUnload') + TriggerEvent('community_bridge:Client:OnPlayerUnload') end) RegisterNetEvent('QBCore:Client:OnJobUpdate', function(data) - PlayerJobName = data.name - PlayerJobLabel = data.label - PlayerJobGradeName = data.grade.name - PlayerJobGradeLevel = data.grade.level - TriggerEvent('community_bridge:Client:OnPlayerJobUpdate',PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel) + TriggerEvent('community_bridge:Client:OnPlayerJobUpdate', data.name, data.label, data.grade.name, data.grade.level) end) return Framework \ No newline at end of file From 2a5fa897a90e4f8fb9d407135f113f3bd6b6f28e Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Tue, 13 May 2025 00:22:49 -0400 Subject: [PATCH 34/38] Revert "psuh for crowley" This reverts commit 0dc3d51319271f4aa5ba7fd44a373577b70174b4. --- init.lua | 20 +++++++++++++++++++- modules/framework/es_extended/client.lua | 12 +++++++++--- modules/framework/qb-core/client.lua | 10 ++++++++-- modules/framework/qbx_core/client.lua | 10 ++++++++-- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/init.lua b/init.lua index bde914e..6a1c9cc 100644 --- a/init.lua +++ b/init.lua @@ -48,7 +48,7 @@ end) -- The following assignments expose core utilities globally, -- making them accessible in all subsequently loaded modules. -_ENV.cLib = cLib ~= nil and cLib or exports.community_bridge:cLib() ---@type table +_ENV.cLib = cLib ~= nil and cLib or export.community_lib.cLib() ---@type table _ENV.Require = Require ---@type fun(module: string): any exports("RegisterModule", Bridge.RegisterModule) @@ -129,3 +129,21 @@ Bridge.RegisterModule("Target", Target) Bridge.RegisterModule("Menu", Menu) Bridge.RegisterModule("Dialogue", Dialogue) Bridge.RegisterModule("Accessibility", Accessibility) -- new + +-- Fill the bridge tables with player data. +function FillBridgeTables() + PlayerLoaded = true + PlayerIdentifier = Framework.GetPlayerIdentifier() + PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel = Framework.GetPlayerJob() +end + +-- Clean the bridge tables. +function ClearClientSideVariables() + PlayerLoaded = false + PlayerIdentifier = nil + PlayerJobName = nil + PlayerJobLabel = nil + PlayerJobGradeName = nil + PlayerJobGradeLevel = nil + StoredOldClothing = {} +end diff --git a/modules/framework/es_extended/client.lua b/modules/framework/es_extended/client.lua index 9b4f0a2..b0e3fca 100644 --- a/modules/framework/es_extended/client.lua +++ b/modules/framework/es_extended/client.lua @@ -119,15 +119,21 @@ end RegisterNetEvent('esx:playerLoaded', function(xPlayer) Wait(1500) - TriggerEvent('community_bridge:Client:OnPlayerLoaded') + FillBridgeTables() + TriggerEvent('community_bridge:Client:OnPlayerLoaded') end) RegisterNetEvent('esx:onPlayerLogout', function() - TriggerEvent('community_bridge:Client:OnPlayerUnload') + ClearClientSideVariables() + TriggerEvent('community_bridge:Client:OnPlayerUnload') end) RegisterNetEvent('esx:setJob', function(data) - TriggerEvent('community_bridge:Client:OnPlayerJobUpdate', data.name, data.label, data.grade_label, data.grade) + PlayerJobName = data.name + PlayerJobLabel = data.label + PlayerJobGradeName = data.grade_label + PlayerJobGradeLevel = data.grade + TriggerEvent('community_bridge:Client:OnPlayerJobUpdate',PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel) end) return Framework \ No newline at end of file diff --git a/modules/framework/qb-core/client.lua b/modules/framework/qb-core/client.lua index 180adf1..71639aa 100644 --- a/modules/framework/qb-core/client.lua +++ b/modules/framework/qb-core/client.lua @@ -148,15 +148,21 @@ Framework.Shared = QBCore.Shared RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() Wait(1500) + FillBridgeTables() TriggerEvent('community_bridge:Client:OnPlayerLoaded') end) RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() - TriggerEvent('community_bridge:Client:OnPlayerUnload') + ClearClientSideVariables() + TriggerEvent('community_bridge:Client:OnPlayerUnload') end) RegisterNetEvent('QBCore:Client:OnJobUpdate', function(data) - TriggerEvent('community_bridge:Client:OnPlayerJobUpdate', data.name, data.label, data.grade.name, data.grade.level) + PlayerJobName = data.name + PlayerJobLabel = data.label + PlayerJobGradeName = data.grade.name + PlayerJobGradeLevel = data.grade.level + TriggerEvent('community_bridge:Client:OnPlayerJobUpdate', PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel) end) RegisterNetEvent('QBCore:Client:OnGangUpdate', function(data) diff --git a/modules/framework/qbx_core/client.lua b/modules/framework/qbx_core/client.lua index 20e6805..2fee358 100644 --- a/modules/framework/qbx_core/client.lua +++ b/modules/framework/qbx_core/client.lua @@ -74,15 +74,21 @@ end RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() Wait(1500) + FillBridgeTables() TriggerEvent('community_bridge:Client:OnPlayerLoaded') end) RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() - TriggerEvent('community_bridge:Client:OnPlayerUnload') + ClearClientSideVariables() + TriggerEvent('community_bridge:Client:OnPlayerUnload') end) RegisterNetEvent('QBCore:Client:OnJobUpdate', function(data) - TriggerEvent('community_bridge:Client:OnPlayerJobUpdate', data.name, data.label, data.grade.name, data.grade.level) + PlayerJobName = data.name + PlayerJobLabel = data.label + PlayerJobGradeName = data.grade.name + PlayerJobGradeLevel = data.grade.level + TriggerEvent('community_bridge:Client:OnPlayerJobUpdate',PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel) end) return Framework \ No newline at end of file From 1d0255185dbb221c6e144a5553a5ae1da2d60979 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Tue, 13 May 2025 00:23:01 -0400 Subject: [PATCH 35/38] Revert "Merge pull request #92 from JericoFX/dev" This reverts commit d69731714227d9147907752f0ef367725eb26461, reversing changes made to 7927927394d4be5e810eedd20f1c9221e8a8f1b8. --- init.lua | 45 +++--------- lib/cache/client/cache.lua | 10 +-- lib/cache/shared/cache.lua | 137 +++++++++---------------------------- lib/init.lua | 98 ++++---------------------- 4 files changed, 63 insertions(+), 227 deletions(-) diff --git a/init.lua b/init.lua index 6a1c9cc..8db2673 100644 --- a/init.lua +++ b/init.lua @@ -22,7 +22,7 @@ function Bridge.RegisterModule(moduleName, moduleTable) end Bridge[moduleName] = wrappedModule _ENV[moduleName] = wrappedModule -- Add to the ENV table the modules so is more easy and safe to call from inside - + _ENV.Bridge = Bridge -- Add the bridge too to the _ENV exports(moduleName, function() return wrappedModule @@ -31,38 +31,19 @@ function Bridge.RegisterModule(moduleName, moduleTable) --trigger update object event TriggerEvent("Bridge:Refresh", moduleName, wrappedModule) end - -CreateThread(function() -- lets try to load the lib first to use it on the rest of the modules - for k, v in pairs(cLib) do - if v then - Bridge.RegisterModule(k, v) - end - end -end) - ---- @module GlobalEnvironment ---- @field cLib table # Core library utilities, available globally after initialization. ---- @field Require fun(module: string): any # Function to require/load modules by name. - ---- Global environment setup. --- The following assignments expose core utilities globally, --- making them accessible in all subsequently loaded modules. - -_ENV.cLib = cLib ~= nil and cLib or export.community_lib.cLib() ---@type table -_ENV.Require = Require ---@type fun(module: string): any exports("RegisterModule", Bridge.RegisterModule) --TODO: Create a way to overide functions or create a new functions for module function Bridge.RegisterModuleFunction(moduleName, functionName, func) - assert(moduleName and functionName and func, - string.format("Bridge.RegisterModuleFunction(%s, %s, %s) - Invalid arguments", moduleName, functionName, func)) + assert(moduleName and functionName and func, string.format("Bridge.RegisterModuleFunction(%s, %s, %s) - Invalid arguments", moduleName, functionName, func)) Bridge[moduleName] = Bridge[moduleName] or {} Bridge[moduleName][functionName] = func --trigger update object event TriggerEvent("Bridge:Refresh", moduleName, Bridge[moduleName]) end + --Bridge Bridge.RegisterModule("Framework", Framework) Bridge.RegisterModule("Inventory", Inventory) @@ -94,27 +75,23 @@ Bridge.RegisterModule("Require", Require) -- Bridge.RegisterModule("Skills", Skills) - - ---[[ CreateThread(function() -- using metatables - for k, v in pairs(cLib.loaded) do - if v then - Bridge.RegisterModule(k, v) - end +for k, v in pairs(cLib) do + if v then + Bridge.RegisterModule(k, v) end -end) ]] +end exports('Bridge', function() return Bridge end) --- ▄▀▀ ██▀ █▀▄ █ █ ██▀ █▀▄ --- ▄█▀ █▄▄ █▀▄ ▀▄▀ █▄▄ █▀▄ +-- ▄▀▀ ██▀ █▀▄ █ █ ██▀ █▀▄ +-- ▄█▀ █▄▄ █▀▄ ▀▄▀ █▄▄ █▀▄ if not IsDuplicityVersion() then goto client end Bridge.RegisterModule('Version', Version) --- ▄▀▀ █ █ ██▀ █▄ █ ▀█▀ --- ▀▄▄ █▄▄ █ █▄▄ █ ▀█ █ +-- ▄▀▀ █ █ ██▀ █▄ █ ▀█▀ +-- ▀▄▄ █▄▄ █ █▄▄ █ ▀█ █ if IsDuplicityVersion() then return end ::client:: diff --git a/lib/cache/client/cache.lua b/lib/cache/client/cache.lua index b9aefdc..df493c8 100644 --- a/lib/cache/client/cache.lua +++ b/lib/cache/client/cache.lua @@ -54,10 +54,10 @@ local function GetWeapon() return GetSelectedPedWeapon(ped) end -Cache.Create("Ped", GetPed, nil) -- Check ped every second (adjust as needed) -Cache.Create("Vehicle", GetVehicle, 500) -- Check vehicle every 500ms -Cache.Create("Seat", GetVehicleSeat, 500) -- Check if in vehicle every 500ms -Cache.Create("Weapon", GetWeapon, 250) -- Check weapon every 250ms -Cache.Create("ServerId", GetServerId, nil) -- Check server ID every second +Cache.Create("Ped", GetPed, 1000) -- Check ped every second (adjust as needed) +Cache.Create("Vehicle", GetVehicle, 500) -- Check vehicle every 500ms +Cache.Create("Seat", GetVehicleSeat, 500) -- Check if in vehicle every 500ms +Cache.Create("Weapon", GetWeapon, 250) -- Check weapon every 250ms +Cache.Create("ServerId", GetServerId, 1000) -- Check server ID every second return Cache diff --git a/lib/cache/shared/cache.lua b/lib/cache/shared/cache.lua index 05b5359..ed42a50 100644 --- a/lib/cache/shared/cache.lua +++ b/lib/cache/shared/cache.lua @@ -1,54 +1,29 @@ ----@class CacheEntry ----@field Name string ----@field Compare fun(): any ----@field WaitTime integer ----@field LastChecked integer|nil ----@field OnChange fun(new:any, old:any)[] ----@field Value any - ----@class CacheModule ----@field Caches table ----@field LoopRunning boolean ----@field Create fun(name:string, compare:fun():any, waitTime?:integer): CacheEntry ----@field Get fun(name:string): any ----@field OnChange fun(name:string, onChange:fun(new:any, old:any)) ----@field Remove fun(name:string) -local Cache = {} ---@type CacheModule - +local Cache = {} local Config = Require("settings/sharedConfig.lua") local max = 5000 local CreateThread = CreateThread local Wait = Wait local GetGameTimer = GetGameTimer + Cache.Caches = Cache.Caches or {} Cache.LoopRunning = Cache.LoopRunning or false ----@param ... any -local function debugPrint(...) +local function print(...) if Config.DebugLevel == 0 then return end print("^2[Cache]^0", ...) end -local function HasActiveCaches() - for _, cache in pairs(Cache.Caches) do - if cache.WaitTime ~= nil then - return true - end - end - return false -end - local function StartLoop() if Cache.LoopRunning then return end - if not HasActiveCaches() then return end Cache.LoopRunning = true CreateThread(function() while Cache.LoopRunning do local now = GetGameTimer() local minWait = nil - for name, cache in pairs(Cache.Caches) do - if cache.Compare and cache.WaitTime ~= nil then + local caches = Cache.Caches + for name, cache in pairs(caches) do + if cache.Compare then cache.LastChecked = cache.LastChecked or now cache.WaitTime = cache.WaitTime or max local elapsed = now - cache.LastChecked @@ -57,8 +32,8 @@ local function StartLoop() local oldValue = cache.Value cache.Value = cache.Compare() if cache.Value ~= oldValue and cache.OnChange then - for i = 1, #cache.OnChange do - cache.OnChange[i](cache.Value, oldValue) + for _, onChange in pairs(cache.OnChange) do + onChange(cache.Value, oldValue) end end cache.LastChecked = now @@ -75,53 +50,44 @@ local function StartLoop() else Wait(max) end - -- if there is no cache valid, stop the loop - if not HasActiveCaches() then - Cache.LoopRunning = false - end end end) end ----@param name string ----@param compare fun():any ----@param waitTime? integer ----@return CacheEntry function Cache.Create(name, compare, waitTime) assert(name, "Cache name is required.") assert(compare, "Comparison function is required.") assert(type(compare) == "function", "Comparison function must be a function.") - local _name = tostring(name) + local _name = tostring(name) -- Ensure name is a string local cache = Cache.Caches[_name] if cache and cache.Compare == compare then - debugPrint(_name .. " already exists with the same comparison function.") + print(name .. " already exists with the same comparison function.") return cache end - local ok, result = pcall(compare) - if not ok then - debugPrint("Error creating cache '" .. _name .. "': " .. tostring(result)) + cache = nil -- clean variable, so we can use the same name for the new cache + local s, r = pcall(function() -- Try to create the cache and catch any errors + local _cache = { + Name = _name, + Compare = compare, + WaitTime = waitTime or max, + LastChecked = nil, + OnChange = {}, + Value = compare() + } + Cache.Caches[_name] = _cache + print(_name .. " created with initial value: " .. tostring(Cache.Caches[_name].Value)) + for _, onChange in pairs(_cache.OnChange) do + onChange(_cache.Value, nil) + end + end) + if not s then + print("Error creating cache '" .. _name .. "': " .. tostring(r)) return nil end - ---@type CacheEntry - local newCache = { - Name = _name, - Compare = compare, - WaitTime = waitTime, -- can be nil - LastChecked = nil, - OnChange = {}, - Value = result - } - Cache.Caches[_name] = newCache - debugPrint(_name .. " created with initial value: " .. tostring(result)) - for i = 1, #newCache.OnChange do - newCache.OnChange[i](newCache.Value, nil) - end - StartLoop() - return newCache + + return StartLoop() end ----@param name string ----@return any function Cache.Get(name) assert(name, "Cache name is required.") local _name = tostring(name) @@ -129,60 +95,25 @@ function Cache.Get(name) return cache and cache.Value or nil end ----@param name string ----@param onChange fun(new:any, old:any) function Cache.OnChange(name, onChange) assert(name, "Cache name is required.") - local _name = tostring(name) + local _name = tostring(name) -- Ensure name is a string local cache = Cache.Caches[_name] assert(cache, "Cache with name '" .. _name .. "' does not exist.") cache.OnChange[#cache.OnChange + 1] = onChange end ----@param name string ----@param newValue any -function Cache.Update(name, newValue) - assert(name, "Cache name is required.") - local _name = tostring(name) - local cache = Cache.Caches[_name] - assert(cache, "Cache with name '" .. _name .. "' does not exist.") - local oldValue = cache.Value - if oldValue ~= newValue then - cache.Value = newValue - for i = 1, #cache.OnChange do - cache.OnChange[i](newValue, oldValue) - end - end -end - ----@param name string function Cache.Remove(name) assert(name, "Cache name is required.") - local _name = tostring(name) + local _name = tostring(name) -- Ensure name is a string local cache = Cache.Caches[_name] if cache then Cache.Caches[_name] = nil - debugPrint(_name .. " removed from cache.") + print(_name .. " removed from cache.") if next(Cache.Caches) == nil then - Cache.LoopRunning = false + Cache.LoopRunning = false -- Stop the loop if no caches are left end end end -setmetatable(Cache, { - __index = function(self, key) - local cache = self.Caches[key] - if cache then - return cache.Value - else - return rawget(self, key) - end - end, - __call = function(self, key) - return self.Get(self, key) - end, -}) - --- with this change now we can use Cache("name") to get the value or simple Cache.name (Cache.Get("name")) - return Cache diff --git a/lib/init.lua b/lib/init.lua index 4003b66..7aa6a34 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -1,5 +1,4 @@ loadedModules = {} -local cLib = {} function Require(modulePath, resourceName) if resourceName and type(resourceName) ~= "string" then @@ -36,93 +35,23 @@ function Require(modulePath, resourceName) return result end -local function getServerLib() - return { - SQL = SQL or Require("lib/sql/server/sqlHandler.lua"), - Logs = Logs or Require("lib/logs/server/logs.lua"), - ItemsBuilder = ItemsBuilder or Require("lib/generators/server/ItemsBuilder.lua"), - LootTables = LootTables or Require("lib/generators/server/lootTables.lua"), - Cache = Cache or Require("lib/cache/shared/cache.lua"), - ServerEntity = ServerEntity or Require("lib/entities/server/server_entity.lua"), - Marker = Marker or Require("lib/markers/server/server.lua"), - Particle = Particle or Require("lib/particles/server/particles.lua"), - } -end -local function getClientLib() - return { - Require = Require, - Gizmo = Gizmo or Require("lib/placers/client/gizmo.lua"), - Scaleform = Scaleform or Require("lib/scaleform/client/scaleform.lua"), - Placeable = Placeable or Require("lib/placers/client/object_placer.lua"), - Utility = Utility or Require("lib/utility/client/utility.lua"), - PlaceableObject = PlaceableObject or Require("lib/placers/client/placeable_object.lua"), - Raycast = Raycast or Require("lib/raycast/client/raycast.lua"), - Point = Point or Require("lib/points/client/points.lua"), - Particle = Particle or Require("lib/particles/client/particles.lua"), - Cache = Cache or Require("lib/cache/client/cache.lua"), - ClientEntity = ClientEntity or Require("lib/entities/client/client_entity.lua"), - ClientEntityActions = ClientEntityActions or Require("lib/entities/client/client_entity_actions.lua"), - ClientStateBag = ClientStateBag or Require("lib/statebags/client/client.lua"), - Marker = Marker or Require("lib/markers/client/markers.lua"), - Anim = Anim or Require("lib/anim/client/client.lua"), - Cutscene = Cutscene or Require("lib/cutscenes/client/cutscene.lua"), - DUI = DUI or Require("lib/dui/client/dui.lua"), - } -end -local function getSharedLib() - return { - Require = Require, - Callback = Callback or Require("lib/utility/shared/callbacks.lua"), - Ids = Ids or Require("lib/utility/shared/ids.lua"), - ReboundEntities = ReboundEntities or Require("lib/utility/shared/rebound_entities.lua"), - Tables = Tables or Require("lib/utility/shared/tables.lua"), - Prints = Prints or Require("lib/utility/shared/prints.lua"), - Math = Math or Require("lib/utility/shared/math.lua"), - LA = LA or Require("lib/utility/shared/la.lua"), - Perlin = Perlin or Require("lib/utility/shared/perlin.lua"), - -- Action = Action or Require("lib/entities/shared/actions.lua"), - } -end +cLib = { + Require = Require, + Callback = Callback or Require("lib/utility/shared/callbacks.lua"), + Ids = Ids or Require("lib/utility/shared/ids.lua"), + ReboundEntities = ReboundEntities or Require("lib/utility/shared/rebound_entities.lua"), + Tables = Tables or Require("lib/utility/shared/tables.lua"), + Prints = Prints or Require("lib/utility/shared/prints.lua"), + Math = Math or Require("lib/utility/shared/math.lua"), + LA = LA or Require("lib/utility/shared/la.lua"), + Perlin = Perlin or Require("lib/utility/shared/perlin.lua"), + -- Action = Action or Require("lib/entities/shared/actions.lua"), +} -cLib = setmetatable(getSharedLib(), { __index = IsDuplicityVersion() and getServerLib() or getClientLib() }) -exports('cLib', function() - return cLib -end) +exports('cLib', cLib) ---[[ _ENV.cLib = setmetatable({ - context = not IsDuplicityVersion() and "client" or "server", - resource = GetCurrentResourceName(), - loaded = {} -}, { - __newindex = function(self, key, value) - return error("Attempt to modify read-only table: " .. key) - end, - __index = function(self, key) -- modify the index function to load the library modules - if self.context == "server" then - return rawget(self.loaded, key) - else - return rawget(self.loaded, key) - end - end, - __call = function(self) -- modify the call function to load the library modules - if self.context == "server" then - if not next(self.loaded) then - self.loaded = getServerLib() - return true - end - else - if not next(self.loaded) then - self.loaded = getClientLib() - return true - end - end - end, -}) -cLib() -- load the library modules ]] - ---[[ if not IsDuplicityVersion() then goto client end cLib.SQL = SQL or Require("lib/sql/server/sqlHandler.lua") @@ -155,4 +84,3 @@ cLib.DUI = DUI or Require("lib/dui/client/dui.lua") cLib.Particle = Particle or Require("lib/particles/client/particles.lua") return cLib - ]] From 99f82095d7ac3ff899b07be3d2f6f6a1fc9011bf Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Tue, 13 May 2025 01:06:52 -0400 Subject: [PATCH 36/38] fuck --- init.lua | 20 +------- modules/framework/es_extended/client.lua | 26 ++++------- modules/framework/es_extended/server.lua | 44 +++++++++--------- modules/framework/qb-core/client.lua | 26 ++++------- modules/framework/qb-core/server.lua | 58 ++++++++++++------------ modules/framework/qbx_core/client.lua | 24 ++++------ modules/framework/qbx_core/server.lua | 54 +++++++++++----------- 7 files changed, 109 insertions(+), 143 deletions(-) diff --git a/init.lua b/init.lua index 8db2673..2fc7e21 100644 --- a/init.lua +++ b/init.lua @@ -105,22 +105,4 @@ Bridge.RegisterModule("Weather", Weather) Bridge.RegisterModule("Target", Target) Bridge.RegisterModule("Menu", Menu) Bridge.RegisterModule("Dialogue", Dialogue) -Bridge.RegisterModule("Accessibility", Accessibility) -- new - --- Fill the bridge tables with player data. -function FillBridgeTables() - PlayerLoaded = true - PlayerIdentifier = Framework.GetPlayerIdentifier() - PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel = Framework.GetPlayerJob() -end - --- Clean the bridge tables. -function ClearClientSideVariables() - PlayerLoaded = false - PlayerIdentifier = nil - PlayerJobName = nil - PlayerJobLabel = nil - PlayerJobGradeName = nil - PlayerJobGradeLevel = nil - StoredOldClothing = {} -end +Bridge.RegisterModule("Accessibility", Accessibility) -- new \ No newline at end of file diff --git a/modules/framework/es_extended/client.lua b/modules/framework/es_extended/client.lua index b0e3fca..0704ac1 100644 --- a/modules/framework/es_extended/client.lua +++ b/modules/framework/es_extended/client.lua @@ -26,7 +26,7 @@ end ---This will return the players birth date ---@return string Framework.GetPlayerDob = function() - local playerData = ESX.GetPlayerData() + local playerData = Framework.GetPlayerData() local dob = playerData.dateofbirth return dob end @@ -35,7 +35,7 @@ end ---@param metadata string ---@return table | nil Framework.GetPlayerMetaData = function(metadata) - return ESX.GetPlayerData().metadata[metadata] + return Framework.GetPlayerData().metadata[metadata] end ---This will prompt the user with a notification message @@ -64,7 +64,7 @@ end ---This will return the players identifier ---@return string Framework.GetPlayerIdentifier = function() - local playerData = ESX.GetPlayerData() + local playerData = Framework.GetPlayerData() return playerData.identifier end @@ -72,7 +72,7 @@ end ---@return string ---@return string Framework.GetPlayerName = function() - local playerData = ESX.GetPlayerData() + local playerData = Framework.GetPlayerData() return playerData.firstName, playerData.lastName end @@ -82,7 +82,7 @@ end ---@return string ---@return string Framework.GetPlayerJob = function() - local playerData = ESX.GetPlayerData() + local playerData = Framework.GetPlayerData() return playerData.job.name, playerData.job.label, playerData.job.grade_label, playerData.job.grade end @@ -97,7 +97,7 @@ end ---This will return a table of the players inventory ---@return table Framework.GetPlayerInventory = function() - local playerData = ESX.GetPlayerData() + local playerData = Framework.GetPlayerData() return playerData.inventory end @@ -113,27 +113,21 @@ end ---This will return a boolean if the player is dead ---@return boolean Framework.GetIsPlayerDead = function() - local playerData = ESX.GetPlayerData() + local playerData = Framework.GetPlayerData() return playerData.dead end RegisterNetEvent('esx:playerLoaded', function(xPlayer) Wait(1500) - FillBridgeTables() - TriggerEvent('community_bridge:Client:OnPlayerLoaded') + TriggerEvent('community_bridge:Client:OnPlayerLoaded') end) RegisterNetEvent('esx:onPlayerLogout', function() - ClearClientSideVariables() - TriggerEvent('community_bridge:Client:OnPlayerUnload') + TriggerEvent('community_bridge:Client:OnPlayerUnload') end) RegisterNetEvent('esx:setJob', function(data) - PlayerJobName = data.name - PlayerJobLabel = data.label - PlayerJobGradeName = data.grade_label - PlayerJobGradeLevel = data.grade - TriggerEvent('community_bridge:Client:OnPlayerJobUpdate',PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel) + TriggerEvent('community_bridge:Client:OnPlayerJobUpdate', data.name, data.label, data.grade_label, data.grade) end) return Framework \ No newline at end of file diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index 5e125d9..83fee38 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -11,13 +11,15 @@ Framework.GetFrameworkName = function() end Framework.GetPlayerDob = function(src) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end local dob = xPlayer.get("dateofbirth") return dob end --- This will return a table of the players data +--- +--- This table is in the framework format and not converted to any standard. ---@param src any ---@return table | nil Framework.GetPlayer = function(src) @@ -29,7 +31,7 @@ end -- Framework.GetPlayerIdentifier(src) -- Returns the citizen ID of the player. Framework.GetPlayerIdentifier = function(src) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end return xPlayer.getIdentifier() end @@ -41,7 +43,7 @@ end -- Framework.GetPlayerName(src) -- Returns the first and last name of the player. Framework.GetPlayerName = function(src) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end return xPlayer.variables.firstName, xPlayer.variables.lastName end @@ -61,7 +63,7 @@ end -- Returns a table of items matching the specified name and if passed metadata from the player's inventory. -- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot} Framework.GetItem = function(src, item, _) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end local playerItems = xPlayer.getInventory() local repackedTable = {} @@ -81,7 +83,7 @@ end -- Framework.GetItemCount(src, item, _) -- Returns the count of items matching the specified name and if passed metadata from the player's inventory. Framework.GetItemCount = function(src, item, _) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end return xPlayer.getInventoryItem(item).count end @@ -99,7 +101,7 @@ end -- Returns the entire inventory of the player as a table. -- returns {name = v.name, count = v.amount, _, _} Framework.GetPlayerInventory = function(src) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end local playerItems = xPlayer.getInventory() local repackedTable = {} @@ -119,7 +121,7 @@ end -- Framework.SetMetadata(src, metadata, value) -- Adds the specified metadata key and number value to the player's data. Framework.SetPlayerMetadata = function(src, metadata, value) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end xPlayer.setMeta(metadata, value, nil) return true @@ -128,7 +130,7 @@ end -- Framework.GetMetadata(src, metadata) -- Gets the specified metadata key and value to the player's data. Framework.GetPlayerMetadata = function(src, metadata) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end return xPlayer.getMeta(metadata) or false end @@ -139,13 +141,13 @@ end -- skin, status, is_dead, id, disabled, last_property, created_at, last_seen, -- phone_number, pincode Framework.GetStatus = function(src, column) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end return xPlayer.get(column) or nil end Framework.GetIsPlayerDead = function(src) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end return xPlayer.get("is_dead") or false end @@ -190,7 +192,7 @@ end -- Framework.GetPlayerPhone(src) -- Returns the phone number of the player. Framework.GetPlayerPhone = function(src) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end return xPlayer.get("phone_number") end @@ -203,7 +205,7 @@ end ---@return string | nil ---@return string | nil Framework.GetPlayerJob = function(src) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end local job = xPlayer.getJob() return job.name, job.label, job.grade_label, job.grade @@ -213,7 +215,7 @@ end ---@param src number ---@return boolean Framework.GetPlayerDuty = function(src) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return false end local job = xPlayer.getJob() if not job.onDuty then return false end @@ -225,7 +227,7 @@ end ---@param dutystatus boolean ---@return boolean Framework.SetPlayerDuty = function(src, dutystatus) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return false end local job = xPlayer.getJob() if not job.onDuty then return false end @@ -238,7 +240,7 @@ Framework.GetPlayersByJob = function(job) local players = GetPlayers() local playerList = {} for _, src in pairs(players) do - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if xPlayer.getJob().name == job then table.insert(playerList, src) end @@ -249,7 +251,7 @@ end -- Framework.SetPlayerJob(src, name, grade) -- Sets the player's job to the specified name and grade. Framework.SetPlayerJob = function(src, name, grade) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end if not ESX.DoesJobExist(name, grade) then Prints.Error("Job Does Not Exsist In Framework :NAME " .. name .. " Grade:" .. grade) @@ -261,7 +263,7 @@ end -- Framework.AddAccountBalance(src, _type, amount) -- Adds the specified amount to the player's account balance of the specified type. Framework.AddAccountBalance = function(src, _type, amount) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end if _type == 'cash' then _type = 'money' end return xPlayer.addAccountMoney(_type, amount) @@ -270,7 +272,7 @@ end -- Framework.RemoveAccountBalance(src, _type, amount) -- Removes the specified amount from the player's account balance of the specified type. Framework.RemoveAccountBalance = function(src, _type, amount) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end if _type == 'cash' then _type = 'money' end xPlayer.removeAccountMoney(_type, amount) @@ -280,7 +282,7 @@ end -- Framework.GetAccountBalance(src, _type) -- Returns the player's account balance of the specified type. Framework.GetAccountBalance = function(src, _type) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end if _type == 'cash' then _type = 'money' end return xPlayer.getAccount(_type).money @@ -289,7 +291,7 @@ end -- Framework.AddItem(src, item, amount, _, _) -- Adds the specified item to the player's inventory. Framework.AddItem = function(src, item, amount, slot, metadata) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end return xPlayer.addInventoryItem(item, amount) end @@ -297,7 +299,7 @@ end -- Framework.RemoveItem(src, item, amount, _, _) -- Removes the specified item from the player's inventory. Framework.RemoveItem = function(src, item, amount, slot, metadata) - local xPlayer = ESX.GetPlayerFromId(src) + local xPlayer = Framework.GetPlayer(src) if not xPlayer then return end return xPlayer.removeInventoryItem(item, amount) end diff --git a/modules/framework/qb-core/client.lua b/modules/framework/qb-core/client.lua index 71639aa..1daa075 100644 --- a/modules/framework/qb-core/client.lua +++ b/modules/framework/qb-core/client.lua @@ -33,7 +33,7 @@ end ---This will get the players birth date ---@return string Framework.GetPlayerDob = function() - local player = QBCore.Functions.GetPlayerData() + local player = Framework.GetPlayerData() local playerData = player.PlayerData return playerData.charinfo.birthdate end @@ -42,7 +42,7 @@ end ---@param metadata table | string ---@return table | string | number | boolean Framework.GetPlayerMetaData = function(metadata) - return QBCore.Functions.GetPlayerData().metadata[metadata] + return Framework.GetPlayerData().metadata[metadata] end Framework.Notify = function(message, type, time) @@ -80,14 +80,14 @@ end ---This will get the players identifier (citizenid) etc. ---@return string Framework.GetPlayerIdentifier = function() - return QBCore.Functions.GetPlayerData().citizenid + return Framework.GetPlayerData().citizenid end ---This will get the players name (first and last). ---@return string ---@return string Framework.GetPlayerName = function() - local playerData = QBCore.Functions.GetPlayerData() + local playerData = Framework.GetPlayerData() return playerData.charinfo.firstname, playerData.charinfo.lastname end @@ -97,7 +97,7 @@ end ---@return string ---@return string Framework.GetPlayerJob = function() - local playerData = QBCore.Functions.GetPlayerData() + local playerData = Framework.GetPlayerData() return playerData.job.name, playerData.job.label, playerData.job.grade.name, playerData.job.grade.level end @@ -109,7 +109,7 @@ end ---@param item string ---@return number Framework.GetItemCount = function(item) - local frameworkInv = QBCore.Functions.GetPlayerData().items + local frameworkInv = Framework.GetPlayerData().items local count = 0 for _, v in pairs(frameworkInv) do if v.name == item then @@ -121,7 +121,7 @@ end Framework.GetPlayerInventory = function() local items = {} - local frameworkInv = QBCore.Functions.GetPlayerData().items + local frameworkInv = Framework.GetPlayerData().items for _, v in pairs(frameworkInv) do table.insert(items, { name = v.name, @@ -140,7 +140,7 @@ end ---This will get a players dead status. ---@return boolean Framework.GetIsPlayerDead = function() - local playerData = QBCore.Functions.GetPlayerData() + local playerData = Framework.GetPlayerData() return playerData.metadata["isdead"] or playerData.metadata["inlaststand"] end @@ -148,21 +148,15 @@ Framework.Shared = QBCore.Shared RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() Wait(1500) - FillBridgeTables() TriggerEvent('community_bridge:Client:OnPlayerLoaded') end) RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() - ClearClientSideVariables() - TriggerEvent('community_bridge:Client:OnPlayerUnload') + TriggerEvent('community_bridge:Client:OnPlayerUnload') end) RegisterNetEvent('QBCore:Client:OnJobUpdate', function(data) - PlayerJobName = data.name - PlayerJobLabel = data.label - PlayerJobGradeName = data.grade.name - PlayerJobGradeLevel = data.grade.level - TriggerEvent('community_bridge:Client:OnPlayerJobUpdate', PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel) + TriggerEvent('community_bridge:Client:OnPlayerJobUpdate', data.name, data.label, data.grade_label, data.grade) end) RegisterNetEvent('QBCore:Client:OnGangUpdate', function(data) diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index c94145f..1a302da 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -13,7 +13,7 @@ end -- Framework.GetPlayerIdentifier(src) -- Returns the citizen ID of the player. Framework.GetPlayerIdentifier = function(src) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData return playerData.citizenid @@ -44,7 +44,7 @@ end -- Returns the first and last name of the player. ---@return string, string Framework.GetPlayerName = function(src) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData return playerData.charinfo.firstname, playerData.charinfo.lastname @@ -53,7 +53,7 @@ end ---This will get the players birth date ---@return string Framework.GetPlayerDob = function(src) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData return playerData.charinfo.birthdate @@ -63,7 +63,7 @@ end -- Returns a table of items matching the specified name and if passed metadata from the player's inventory. -- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot} Framework.GetItem = function(src, item, metadata) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local playerInventory = playerData.items @@ -106,7 +106,7 @@ end ---@param metadata table ---@return number Framework.GetItemCount = function(src, item, metadata) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local playerInventory = playerData.items @@ -132,7 +132,7 @@ end -- Returns the entire inventory of the player as a table. -- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot} Framework.GetPlayerInventory = function(src) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local playerInventory = playerData.items @@ -160,7 +160,7 @@ Framework.GetPlayers = function() end Framework.GetItemBySlot = function(src, slot) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local playerInventory = playerData.items @@ -186,7 +186,7 @@ end -- Adds the specified metadata key and number value to the player's data. ---@return boolean | nil Framework.SetPlayerMetadata = function(src, metadata, value) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end player.Functions.SetMetaData(metadata, value) return true @@ -195,7 +195,7 @@ end -- Framework.GetMetadata(src, metadata) -- Gets the specified metadata key to the player's data. Framework.GetPlayerMetadata = function(src, metadata) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData return playerData.metadata[metadata] or false @@ -205,7 +205,7 @@ end -- Adds the specified value to the player's stress level and updates the client HUD. ---@return number | nil Framework.AddStress = function(src, value) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local newStress = playerData.metadata.stress + value @@ -218,7 +218,7 @@ end -- Removes the specified value from the player's stress level and updates the client HUD. ---@return number | nil Framework.RemoveStress = function(src, value) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local newStress = (playerData.metadata.stress or 0) - value @@ -231,7 +231,7 @@ end -- Adds the specified value from the player's hunger level. ---@return number | nil Framework.AddHunger = function(src, value) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local newHunger = (playerData.metadata.hunger or 0) + value @@ -246,7 +246,7 @@ end -- Adds the specified value from the player's thirst level. ---@return number | nil Framework.AddThirst = function(src, value) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local newThirst = (playerData.metadata.thirst or 0) + value @@ -260,7 +260,7 @@ end ---@param src any ---@return number | nil Framework.GetHunger = function(src) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local newHunger = (playerData.metadata.hunger or 0) @@ -268,7 +268,7 @@ Framework.GetHunger = function(src) end Framework.GetIsPlayerDead = function(src) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData return playerData.metadata.isdead or playerData.metadata.inlaststand or false @@ -286,7 +286,7 @@ end ---@param src any ---@return number | nil Framework.GetThirst = function(src) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local newThirst = (playerData.metadata.thirst or 0) @@ -296,7 +296,7 @@ end -- Framework.GetPlayerPhone(src) -- Returns the phone number of the player. Framework.GetPlayerPhone = function(src) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData return playerData.charinfo.phone @@ -305,7 +305,7 @@ end -- Framework.GetPlayerGang(src) -- Returns the gang name of the player. Framework.GetPlayerGang = function(src) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData return playerData.gang.name @@ -318,7 +318,7 @@ Framework.GetPlayersByJob = function(job) local playerList = {} local players = QBCore.Functions.GetPlayers() for _, src in pairs(players) do - local player = QBCore.Functions.GetPlayer(src).PlayerData + local player = Framework.GetPlayer(src).PlayerData if player.job.name == job then table.insert(playerList, src) end @@ -333,7 +333,7 @@ end ---@return string ---@return string Framework.GetPlayerJob = function(src) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData return playerData.job.name, playerData.job.label, playerData.job.grade.name, playerData.job.grade.level @@ -343,7 +343,7 @@ end ---@param src number ---@return boolean | nil Framework.GetPlayerDuty = function(src) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData if not playerData.job.onduty then return false end @@ -355,7 +355,7 @@ end ---@param status boolean ---@return nil Framework.SetPlayerDuty = function(src, status) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end player.Functions.SetJobDuty(status) TriggerEvent('QBCore:Server:SetDuty', src, player.PlayerData.job.onduty) @@ -367,7 +367,7 @@ end ---@param grade string ---@return nil Framework.SetPlayerJob = function(src, name, grade) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end return player.Functions.SetJob(name, grade) end @@ -378,7 +378,7 @@ end ---@param amount number ---@return boolean | nil Framework.AddAccountBalance = function(src, _type, amount) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end if _type == 'money' then _type = 'cash' end return player.Functions.AddMoney(_type, amount) @@ -390,7 +390,7 @@ end ---@param amount number ---@return boolean | nil Framework.RemoveAccountBalance = function(src, _type, amount) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end if _type == 'money' then _type = 'cash' end return player.Functions.RemoveMoney(_type, amount) @@ -401,7 +401,7 @@ end ---@param _type string ---@return string | nil Framework.GetAccountBalance = function(src, _type) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData if _type == 'money' then _type = 'cash' end @@ -411,7 +411,7 @@ end -- Framework.AddItem(src, item, amount, slot, metadata) -- Adds the specified item to the player's inventory. Framework.AddItem = function(src, item, amount, slot, metadata) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, { action = "add", item = item, count = amount, slot = slot, metadata = metadata }) @@ -421,7 +421,7 @@ end -- Framework.RemoveItem(src, item, amount, slot, metadata) -- Removes the specified item from the player's inventory. Framework.RemoveItem = function(src, item, amount, slot, metadata) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, { action = "remove", item = item, count = amount, slot = slot, metadata = metadata }) @@ -432,7 +432,7 @@ end -- Sets the metadata for the specified item in the player's inventory. -- Notes, this is kinda a jank workaround. with the framework aside from updating the entire table theres not really a better way Framework.SetMetadata = function(src, item, slot, metadata) - local player = QBCore.Functions.GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local slotFinder = Framework.GetPlayerInventory(src) local freeSlot = Table.FindFirstUnoccupiedSlot(slotFinder) diff --git a/modules/framework/qbx_core/client.lua b/modules/framework/qbx_core/client.lua index 2fee358..bf1e9af 100644 --- a/modules/framework/qbx_core/client.lua +++ b/modules/framework/qbx_core/client.lua @@ -18,7 +18,7 @@ Framework.GetFrameworkJobs = function() end Framework.GetPlayerDob = function() - local playerData = QBox.GetPlayerData() + local playerData = Framework.GetPlayerData() return playerData.charinfo.birthdate end @@ -37,26 +37,26 @@ Framework.HideHelpText = function() end Framework.GetPlayerMetaData = function(metadata) - local playerData = QBox.GetPlayerData() + local playerData = Framework.GetPlayerData() return playerData.metadata[metadata] end Framework.GetPlayerIdentifier = function() - return QBox.GetPlayerData().citizenid + return Framework.GetPlayerData().citizenid end Framework.GetPlayerName = function() - local playerData = QBox.GetPlayerData() + local playerData = Framework.GetPlayerData() return playerData.charinfo.firstname, playerData.charinfo.lastname end Framework.GetPlayerJob = function() - local playerData = QBox.GetPlayerData() + local playerData = Framework.GetPlayerData() return playerData.job.name, playerData.job.label, playerData.job.grade.name, playerData.job.grade.level end Framework.GetPlayerInventory = function() - return QBox.GetPlayerData().items + return Framework.GetPlayerData().items end ---comment @@ -68,27 +68,21 @@ Framework.GetItemCount = function(item) end Framework.GetIsPlayerDead = function() - local platerData = QBox.GetPlayerData() + local platerData = Framework.GetPlayerData() return platerData.metadata["isdead"] or platerData.metadata["inlaststand"] end RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() Wait(1500) - FillBridgeTables() TriggerEvent('community_bridge:Client:OnPlayerLoaded') end) RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() - ClearClientSideVariables() - TriggerEvent('community_bridge:Client:OnPlayerUnload') + TriggerEvent('community_bridge:Client:OnPlayerUnload') end) RegisterNetEvent('QBCore:Client:OnJobUpdate', function(data) - PlayerJobName = data.name - PlayerJobLabel = data.label - PlayerJobGradeName = data.grade.name - PlayerJobGradeLevel = data.grade.level - TriggerEvent('community_bridge:Client:OnPlayerJobUpdate',PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel) + TriggerEvent('community_bridge:Client:OnPlayerJobUpdate', data.name, data.label, data.grade.name, data.grade.level) end) return Framework \ No newline at end of file diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index ddc1017..ef6cbcb 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -15,7 +15,7 @@ end ---@param src number ---@return string Framework.GetPlayerDob = function(src) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData return playerData.charinfo.birthdate @@ -40,7 +40,7 @@ end ---@param src number ---@return string | boolean Framework.GetPlayerIdentifier = function(src) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData if not playerData then return false end @@ -62,7 +62,7 @@ end ---@param src number ---@return string | nil Framework.GetPlayerName = function(src) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData return playerData.charinfo.firstname, playerData.charinfo.lastname @@ -74,7 +74,7 @@ end ---@param metadata table ---@return table Framework.GetItem = function(src, item, metadata) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerInventory = player.PlayerData.items local repackedTable = {} @@ -97,7 +97,7 @@ end ---@param metadata table ---@return number Framework.GetItemCount = function(src, item, metadata) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerInventory = player.PlayerData.items local count = 0 @@ -122,7 +122,7 @@ end ---@param src number ---@return table Framework.GetPlayerInventory = function(src) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerItems = player.PlayerData.items local repackedTable = {} @@ -143,7 +143,7 @@ end ---@param value string ---@return boolean Framework.SetPlayerMetadata = function(src, metadata, value) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end player.Functions.SetMetaData(metadata, value) return true @@ -154,7 +154,7 @@ end ---@param metadata string ---@return string | boolean | nil Framework.GetPlayerMetadata = function(src, metadata) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData return playerData.metadata[metadata] or false @@ -165,7 +165,7 @@ end ---@param value number ---@return number | nil Framework.AddStress = function(src, value) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local newStress = playerData.metadata.stress + value @@ -179,7 +179,7 @@ end ---@param value number ---@return number | nil Framework.RemoveStress = function(src, value) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local newStress = (playerData.metadata.stress or 0) - value @@ -193,7 +193,7 @@ end ---@param value number ---@return number | nil Framework.AddHunger = function(src, value) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local newHunger = (playerData.metadata.hunger or 0) + value @@ -207,7 +207,7 @@ end ---@param value number ---@return number | nil Framework.AddThirst = function(src, value) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local newThirst = (playerData.metadata.thirst or 0) + value @@ -220,7 +220,7 @@ end ---@param src number ---@return number | nil Framework.GetHunger = function(src) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local newHunger = (playerData.metadata.hunger or 0) @@ -228,7 +228,7 @@ Framework.GetHunger = function(src) end Framework.GetIsPlayerDead = function(src) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData return playerData.metadata.isdead or false @@ -245,7 +245,7 @@ end ---@param src number ---@return number Framework.GetThirst = function(src) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData local newThirst = (playerData.metadata.thirst or 0) @@ -256,7 +256,7 @@ end ---@param src number ---@return string | nil Framework.GetPlayerPhone = function(src) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData return playerData.charinfo.phone @@ -266,7 +266,7 @@ end ---@param src number ---@return string | nil Framework.GetPlayerGang = function(src) - local player = QBox:GetPlayer(src).PlayerData + local player = Framework.GetPlayer(src).PlayerData return player.gang.name end @@ -291,7 +291,7 @@ end ---@return string | string | string | number | nil ---@return string | string | string | number | nil Framework.GetPlayerJob = function(src) - local player = QBox:GetPlayer(src).PlayerData + local player = Framework.GetPlayer(src).PlayerData if not player then return end return player.job.name, player.job.label, player.job.grade.name, player.job.grade.level end @@ -302,7 +302,7 @@ end ---@param grade string ---@return boolean | nil Framework.SetPlayerJob = function(src, name, grade) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end return player.Functions.SetJob(name, grade) end @@ -311,7 +311,7 @@ end ---@param src number ---@param status boolean Framework.SetPlayerDuty = function(src, status) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData QBox:SetJobDuty(playerData.citizenid, status) @@ -322,7 +322,7 @@ end ---@param src number ---@return boolean | nil Framework.GetPlayerDuty = function(src) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData if not playerData.job.onduty then return false end @@ -335,7 +335,7 @@ end ---@param amount number ---@return boolean | nil Framework.AddAccountBalance = function(src, _type, amount) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end if _type == 'money' then _type = 'cash' end return player.Functions.AddMoney(_type, amount) @@ -347,7 +347,7 @@ end ---@param amount number ---@return boolean | nil Framework.RemoveAccountBalance = function(src, _type, amount) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end if _type == 'money' then _type = 'cash' end return player.Functions.RemoveMoney(_type, amount) @@ -358,7 +358,7 @@ end ---@param _type string ---@return number | nil Framework.GetAccountBalance = function(src, _type) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData if _type == 'money' then _type = 'cash' end @@ -373,7 +373,7 @@ end ---@param metadata table ---@return boolean | nil Framework.AddItem = function(src, item, amount, slot, metadata) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, { action = "add", item = item, count = amount, slot = slot, metadata = metadata }) @@ -388,7 +388,7 @@ end ---@param metadata table ---@return boolean | nil Framework.RemoveItem = function(src, item, amount, slot, metadata) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, { action = "remove", item = item, count = amount, slot = slot, metadata = metadata }) @@ -402,7 +402,7 @@ end ---@param metadata table ---@return boolean | nil Framework.SetMetadata = function(src, item, slot, metadata) - local player = QBox:GetPlayer(src) + local player = Framework.GetPlayer(src) if not player then return end player.Functions.RemoveItem(item, 1, slot) return player.Functions.AddItem(item, 1, slot, metadata) From 5629bab494d034b5b5f83d0bdcc1eda8229b92a5 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Tue, 13 May 2025 01:25:47 -0400 Subject: [PATCH 37/38] Update server.lua --- modules/framework/qbx_core/server.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index ef6cbcb..b981b50 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -38,7 +38,7 @@ end ---Returns the citizen ID of the player. ---@param src number ----@return string | boolean +---@return string | boolean | nil Framework.GetPlayerIdentifier = function(src) local player = Framework.GetPlayer(src) if not player then return end @@ -61,6 +61,7 @@ end ---Returns the first and last name of the player. ---@param src number ---@return string | nil +---@return string | nil Framework.GetPlayerName = function(src) local player = Framework.GetPlayer(src) if not player then return end @@ -95,7 +96,7 @@ end ---@param src number ---@param item string ---@param metadata table ----@return number +---@return number | nil Framework.GetItemCount = function(src, item, metadata) local player = Framework.GetPlayer(src) if not player then return end @@ -120,7 +121,7 @@ end ---Returns the entire inventory of the player as a table. ---@param src number ----@return table +---@return table | nil Framework.GetPlayerInventory = function(src) local player = Framework.GetPlayer(src) if not player then return end @@ -141,7 +142,7 @@ end ---@param src number ---@param metadata string ---@param value string ----@return boolean +---@return boolean | nil Framework.SetPlayerMetadata = function(src, metadata, value) local player = Framework.GetPlayer(src) if not player then return end From df95934c1c71b0bdf61d019bea52a931f7394683 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Tue, 13 May 2025 01:51:34 -0400 Subject: [PATCH 38/38] 0.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🚀 Version Bump Update Hello everyone! As we push this latest version, I wanted to take a moment to highlight what's new. This update includes **44 commits** and introduces **GitHub Actions** to the repository—so if all goes well, this notice should also make its way into Discord! ### 📜 Organizational Updates * We've added a **Code of Conduct** for the organization—please take a moment to review it. * We're excited to officially welcome **@JericoFX** to the team! His contributions in this update have been massive. ### 🔧 Highlights of This Update * **Core Inventory Compatibility** (ESX + QB): Now fully (and hopefully seamlessly) integrated – thanks to @MrNewb. * **Version Checker**: Minor improvements by @MrNewb. * **Bridge Table Formatting**: Now matches `ox` formatting more closely – thanks to @MrNewb. * **Documentation Efforts**: We've made major strides in improving notation and preparing for better documentation across the board. * **Library & Load Structure**: Significant internal refactoring by @JericoFX and @gononono64. * **Revive Player**: Functionality added to the bridge by @gononono64. * **Switch/Match Functions**: Introduced by @JericoFX. * **Player Data Functions**: Framework Native return data functions added by @JericoFX. * **Marker System Fixes**: Marker and particle fixes, now with server-side support – thanks to @gononono64. * **Cutscene System**: Added by @gononono64 with enhancements from @JericoFX. * **DUI Manager**: Now includes mouse support and instance management – built by @JericoFX. * **General Cleanup & Optimization**: Massive improvements to bridge stability and structure – thanks to @JericoFX & @gononono64. * **Misc Fixes**: Includes `qs-inventory` fixes and `isPlayerDead` resolution – by @gononono64. Thanks to everyone contributing, testing, and providing feedback. We're continuing to push toward better structure, documentation, and usability across all systems. Stay tuned—and as always, report any issues you encounter! --- fxmanifest.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index 556bcf1..9aaa255 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -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.7.0' +version '0.8.0' shared_scripts { '@ox_lib/init.lua',