From 1d9acd407cc10cf8e22312ea5ce4c069fa3a534e Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Tue, 8 Apr 2025 16:47:27 -0500 Subject: [PATCH 01/22] perticles --- lib/init.lua | 1 + lib/particles/client/particles.lua | 90 ++++++++++++++---------------- unit_tests/particle_test.lua | 7 +++ 3 files changed, 49 insertions(+), 49 deletions(-) create mode 100644 unit_tests/particle_test.lua diff --git a/lib/init.lua b/lib/init.lua index 32df25c..408f616 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -67,6 +67,7 @@ cLib.Utility = Utility or Require("lib/utility/client/utility.lua") cLib.PlaceableObject = PlaceableObject or Require("lib/placers/client/placeable_object.lua") cLib.Raycast = Raycast or Require("lib/raycast/client/raycast.lua") cLib.Point = Point or Require("lib/points/client/points.lua") +cLib.Particle = Particle or Require("lib/particles/client/particles.lua") cLib.Object = Object or Require("lib/entities/client/entity_object.lua") return cLib \ No newline at end of file diff --git a/lib/particles/client/particles.lua b/lib/particles/client/particles.lua index d920080..89ed5f2 100644 --- a/lib/particles/client/particles.lua +++ b/lib/particles/client/particles.lua @@ -1,61 +1,53 @@ -function CreateParticleFX(dict, ptfx, pos, rot, scale, color, looped, loopLength) - CreateThread(function() - local failed = 5 - while not HasNamedPtfxAssetLoaded(dict) and failed >= 0 do - RequestNamedPtfxAsset(ptfx) - failed = failed - 1 - Wait(0) - end +Particle = {} +Particles = {} - UseParticleFxAssetNextCall(dict) - SetParticleFxNonLoopedColour(color.x, color.y, color.z) - if looped then - StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false) - Wait(loopLength) - RemoveParticleFxInRange(pos.x, pos.y, pos.z, 0.01) - else - StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false) - end - RemoveNamedPtfxAsset(ptfx) - end) + +--- Load a particle dictionary. This function will block until the dictionary is loaded. +--- @param dict string -- The name of the particle dictionary to load. +--- @return boolean -- Returns true if the dictionary was loaded successfully, false otherwise. +--- @throws string -- Throws an error if the dictionary fails to load after 100 attempts. +function Particle.LoadDict(dict) + RequestNamedPtfxAsset(dict) + local failed = 100 + while not HasNamedPtfxAssetLoaded(dict) and failed >= 0 do + failed = failed - 1 + Wait(50) + end + assert(failed >= 0, "Failed to load particle dictionary: " .. dict) + return true end -function CreateParticleFXOnEntityBone(dict, ptfx, entity, bone, offset, rot, scale, color, looped, loopLength) - local failed = 5 - while not HasNamedPtfxAssetLoaded(dict) and failed >= 0 do - RequestNamedPtfxAsset(ptfx) - failed = failed - 1 - Wait(0) - end - +--- Create a particle effect at the specified position and rotation. +--- @param dict string +--- @param ptfx string +--- @param pos vector3 +--- @param rot vector3 +--- @param scale number +--- @param color vector3 +--- @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) + if not Particle.LoadDict(dict) then return end UseParticleFxAssetNextCall(dict) - SetParticleFxNonLoopedColour(color.x, color.y, color.z) - local bleh = nil + local handle = nil if looped then - bleh = StartNetworkedParticleFxLoopedOnEntityBone(ptfx, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, bone, scale, false, false, false) + handle = StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false) + SetParticleFxLoopedColour(handle, color.x, color.y, color.z, false) if loopLength then Wait(loopLength) - RemoveParticleFxFromEntity(entity) + StopParticleFxLooped(handle, 0) + RemoveParticleFx(handle, false) end else - bleh = StartNetworkedParticleFxNonLoopedOnEntityBone(ptfx, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, bone, scale, false, false, false) + SetParticleFxNonLoopedColour(color.x, color.y, color.z) + handle = StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false) + RemoveParticleFx(handle, false) end - RemoveNamedPtfxAsset(ptfx) - return bleh + return handle end -function PlayParticleFX(dict, name, looped, x, y, z, rotX, rotY, rotZ, scale) - RequestNamedPtfxAsset(dict) - while not HasNamedPtfxAssetLoaded(dict) do - Wait(0) - end - SetPtfxAssetNextCall(dict) - UseParticleFxAssetNextCall(dict) - local particle = nil - if looped then - particle = StartParticleFxLoopedAtCoord(name, x, y, z , rotX, rotY, rotZ, scale) - else - particle = StartParticleFxNonLoopedAtCoord(name, x, y, z, rotX, rotY, rotZ, scale, false, false, false) - end - return particle -end \ No newline at end of file +-- need to add looping effects (regarless of if its a looped particle or not) + + +return Particle \ No newline at end of file diff --git a/unit_tests/particle_test.lua b/unit_tests/particle_test.lua new file mode 100644 index 0000000..5e14be1 --- /dev/null +++ b/unit_tests/particle_test.lua @@ -0,0 +1,7 @@ + +RegisterCommand("test_particle", function(source, args, rawCommand) + local playerPed = PlayerPedId() + local coords = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, 1.0, 0.0) + local heading = GetEntityHeading(playerPed) + Particle.Create("core", "ent_dst_concrete_large", coords, vector3(0.0, 0.0, heading), 1.0, vector3(1.0, 1.0, 1.0), false) +end) \ No newline at end of file From 64d302d0daea43acded130f3084a9bdfcd5cf102 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Thu, 10 Apr 2025 07:03:32 -0400 Subject: [PATCH 02/22] itembox patch --- modules/inventory/ps-inventory/server.lua | 6 ++---- modules/inventory/qb-inventory/server.lua | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/inventory/ps-inventory/server.lua b/modules/inventory/ps-inventory/server.lua index 2967b58..3854241 100644 --- a/modules/inventory/ps-inventory/server.lua +++ b/modules/inventory/ps-inventory/server.lua @@ -67,12 +67,11 @@ end ---@param metadata table ---@return boolean Inventory.AddItem = function(src, item, amount, slot, metadata) - TriggerClientEvent('ps-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add') + 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') end - ---comment ---@param src number ---@param item string @@ -81,12 +80,11 @@ end ---@param metadata table ---@return boolean Inventory.RemoveItem = function(src, item, amount, slot, metadata) - TriggerClientEvent('ps-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'remove') + 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 ---@param oldplate string ---@param newplate string diff --git a/modules/inventory/qb-inventory/server.lua b/modules/inventory/qb-inventory/server.lua index 3e83d72..86ea1d4 100644 --- a/modules/inventory/qb-inventory/server.lua +++ b/modules/inventory/qb-inventory/server.lua @@ -109,13 +109,13 @@ Inventory.UpdatePlate = function(oldplate, newplate) end Inventory.AddItem = function(src, item, amount, slot, metadata) - TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add') + 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') + 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 From 6ddbb47e97f2bf0966560c13db4da9a769428ec5 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Thu, 10 Apr 2025 07:04:15 -0400 Subject: [PATCH 03/22] GetItemInfo fix on ps/qb inventory --- modules/inventory/ps-inventory/client.lua | 14 ++++++++++++++ modules/inventory/qb-inventory/client.lua | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/modules/inventory/ps-inventory/client.lua b/modules/inventory/ps-inventory/client.lua index 6ffcd0a..7e459e2 100644 --- a/modules/inventory/ps-inventory/client.lua +++ b/modules/inventory/ps-inventory/client.lua @@ -26,3 +26,17 @@ Inventory.GetImagePath = function(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 + +Inventory.GetItemInfo = function(item) + local itemData = Framework.Shared.Items[item] + if not itemData then return {} end + local repackedTable = { + name = itemData.name, + label = itemData.label, + stack = itemData.unique, + weight = itemData.weight, + description = itemData.description, + image = Inventory.GetImagePath(itemData.name) + } + return repackedTable +end \ No newline at end of file diff --git a/modules/inventory/qb-inventory/client.lua b/modules/inventory/qb-inventory/client.lua index c699953..2507543 100644 --- a/modules/inventory/qb-inventory/client.lua +++ b/modules/inventory/qb-inventory/client.lua @@ -25,3 +25,18 @@ Inventory.GetImagePath = function(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 + +Inventory.GetItemInfo = function(item) + local itemData = Framework.Shared.Items[item] + if not itemData then return {} end + local repackedTable = { + name = itemData.name, + label = itemData.label, + stack = itemData.unique, + weight = itemData.weight, + description = itemData.description, + image = Inventory.GetImagePath(itemData.name) + } + return repackedTable +end + From d52574a3ce0d0f4d71f9ded37e36f7c56e64c0a9 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Thu, 10 Apr 2025 07:04:46 -0400 Subject: [PATCH 04/22] jpr seems to be qb only so updating this for image pathing --- modules/inventory/jpr-inventory/client.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/inventory/jpr-inventory/client.lua b/modules/inventory/jpr-inventory/client.lua index 42f6c98..7f1afdd 100644 --- a/modules/inventory/jpr-inventory/client.lua +++ b/modules/inventory/jpr-inventory/client.lua @@ -24,3 +24,17 @@ Inventory.GetImagePath = function(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 + +Inventory.GetItemInfo = function(item) + local itemData = Framework.Shared.Items[item] + if not itemData then return {} end + local repackedTable = { + name = itemData.name, + label = itemData.label, + stack = itemData.unique, + weight = itemData.weight, + description = itemData.description, + image = Inventory.GetImagePath(itemData.name) + } + return repackedTable +end \ No newline at end of file From 1a0707efac85b0a864fa02896a11dde912800784 Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Thu, 10 Apr 2025 17:07:13 -0500 Subject: [PATCH 05/22] select fix issues with input select for qb. Try dat --- modules/input/_qb-input.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/input/_qb-input.lua b/modules/input/_qb-input.lua index a72dc2e..ae0da6a 100644 --- a/modules/input/_qb-input.lua +++ b/modules/input/_qb-input.lua @@ -39,14 +39,16 @@ function OxToQBInput(data) } if v.type == "select" then input.text = "" - input.options = { - {value = v.value, text = v.label} - } + input.options = {} + for k, j in pairs(v.options) do + table.insert(input.options, {value = j.value, text = j.label}) + end elseif v.type == "checkbox" then input.text = "" - input.options = { - {value = v.value, text = v.label} - } + input.options = {} + for k, j in pairs(v.options) do + table.insert(input.options, {value = j.value, text = j.label}) + end end table.insert(returnData, input) end From c15b4dd29264af4fd306b2290d906d4d237f8f3c Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Thu, 10 Apr 2025 22:21:38 -0400 Subject: [PATCH 06/22] configValue --- modules/input/_oxlib.lua | 4 +++- modules/input/_qb-input.lua | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/input/_oxlib.lua b/modules/input/_oxlib.lua index c376a23..6baa54c 100644 --- a/modules/input/_oxlib.lua +++ b/modules/input/_oxlib.lua @@ -1,4 +1,6 @@ -if GetResourceState('ox_lib') ~= 'started' or (BridgeClientConfig.InputSystem ~= "ox" and BridgeClientConfig.InputSystem ~= "auto") then return end +local resourceName = "ox_lib" +local configValue = BridgeClientConfig.InputSystem +if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end function QBTypeToOxType(_type) if _type == "text" then diff --git a/modules/input/_qb-input.lua b/modules/input/_qb-input.lua index ae0da6a..4371b81 100644 --- a/modules/input/_qb-input.lua +++ b/modules/input/_qb-input.lua @@ -1,5 +1,6 @@ - -if GetResourceState('qb-input') ~= 'started' or (BridgeClientConfig.InputSystem ~= "qb" and BridgeClientConfig.InputSystem ~= "auto") then return end +local resourceName = "qb-input" +local configValue = BridgeClientConfig.InputSystem +if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end function OxTypeToQBType(_type) if _type == "input" then @@ -69,7 +70,7 @@ function OpenInput(title, data, isQBFormat, submitText) if returnData[1] then return returnData end --converting to standard format (ox) local convertedData = {} - if isQBFormat then + if isQBFormat then for i, v in pairs(input) do for k, j in pairs(returnData) do if k == v.text then From 801db83402638de2f10b2902d0270c44fa718b4a Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Sat, 12 Apr 2025 02:30:38 -0400 Subject: [PATCH 07/22] GetItemInfo fixes, oops Ive also adjusted comments in here because it bugged me. --- modules/framework/qb-core/server.lua | 19 +++++++++++++- modules/inventory/_default/server.lua | 30 +++++++++++------------ modules/inventory/qb-inventory/server.lua | 1 - 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index d72ce64..5a48503 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -71,6 +71,23 @@ 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. +---@param item string +---@return table +Framework.GetItemInfo = function(item) + local itemData = QBCore.Shared.Items[item] + if not itemData then return {} end + local repackedTable = { + name = itemData.name, + label = itemData.label, + stack = itemData.unique, + weight = itemData.weight, + description = itemData.description, + image = itemData.image + } + 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. Framework.GetItemCount = function(src, item, metadata) @@ -255,8 +272,8 @@ end ---@param job any ---@return table Framework.GetPlayersByJob = function(job) - local players = QBCore.Functions.GetPlayers() local playerList = {} + local players = QBCore.Functions.GetPlayers() for _, src in pairs(players) do local player = QBCore.Functions.GetPlayer(src).PlayerData if player.job.name == job then diff --git a/modules/inventory/_default/server.lua b/modules/inventory/_default/server.lua index d179eaf..87eb68c 100644 --- a/modules/inventory/_default/server.lua +++ b/modules/inventory/_default/server.lua @@ -1,36 +1,36 @@ Inventory = Inventory or {} ----comment +---This will fallback to framework add item functions when an inventory does not have the specifiec function. ---@param src number ---@param item string ---@param count number ---@param slot number ---@param metadata table ----@return boolean +---@return boolean|nil Inventory.AddItem = function(src, item, count, slot, metadata) return Framework.AddItem(src, item, count, slot, metadata) end ----comment +---This will fallback to framework add item functions when an inventory does not have the specifiec function. ---@param src number ---@param item string ---@param count number ---@param slot number ---@param metadata table ----@return boolean +---@return boolean|nil Inventory.RemoveItem = function(src, item, count, slot, metadata) item = type(item) == "table" and item.name or item return Framework.RemoveItem(src, item, count, slot, metadata) end ----comment +---This will fallback to framework add item functions when an inventory does not have the specifiec function. ---@param item string ----@return boolean +---@return table Inventory.GetItemInfo = function(item) - return false, print("This Inventory Has Not Been Bridged For An Item Info Feature.") + return Framework.GetItemInfo(item) end ----comment +---This will fallback to framework add item functions when an inventory does not have the specifiec function. ---@param src number ---@param item string ---@param metadata table @@ -39,14 +39,14 @@ Inventory.GetItemCount = function(src, item, metadata) return Framework.GetItemCount(src, item, metadata) end ----comment +---This will fallback to framework add item functions when an inventory does not have the specifiec function. ---@param src number ---@return table Inventory.GetPlayerInventory = function(src) return Framework.GetPlayerInventory(src) end ----comment +---This will fallback to framework add item functions when an inventory does not have the specifiec function. ---@param src number ---@param slot number ---@return table @@ -54,7 +54,7 @@ Inventory.GetItemBySlot = function(src, slot) return Framework.GetItemBySlot(src, slot) end ----comment +---This will fallback to framework add item functions when an inventory does not have the specifiec function. ---@param src number ---@param item string ---@param slot number @@ -64,7 +64,7 @@ Inventory.SetMetadata = function(src, item, slot, metadata) return Framework.SetMetadata(src, item, slot, metadata) end ----comment +---This will fallback to framework add item functions when an inventory does not have the specifiec function. ---@param src number ---@param id string||number ---@param label string @@ -75,12 +75,12 @@ end ---@param coords table ---@return boolean Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) - return false, print("This Inventory Has Not Been Bridged For A Stash Feature.") + return false, Prints.Error("This Inventory Has Not Been Bridged For A Stash Feature.") end ----comment +---This will provide a image of the community bridge logo if the inventory isnt bridged for the specific path. ---@param item string ---@return string Inventory.GetImagePath = function(item) return "https://avatars.githubusercontent.com/u/47620135" -end +end \ No newline at end of file diff --git a/modules/inventory/qb-inventory/server.lua b/modules/inventory/qb-inventory/server.lua index 86ea1d4..03b43ff 100644 --- a/modules/inventory/qb-inventory/server.lua +++ b/modules/inventory/qb-inventory/server.lua @@ -76,7 +76,6 @@ Inventory.GetItemBySlot = function(src, slot) } end - ---comment ---@param oldplate string ---@param newplate string From d1da9710dab0b536d92e900d3e0922dad99d5bfd Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Sat, 12 Apr 2025 02:30:59 -0400 Subject: [PATCH 08/22] cleanup (use unit tests) --- lib/entities/server/entity_relay.lua | 21 +-------------------- lib/points/client/points.lua | 21 --------------------- 2 files changed, 1 insertion(+), 41 deletions(-) diff --git a/lib/entities/server/entity_relay.lua b/lib/entities/server/entity_relay.lua index 5c2f2d0..5c75eb4 100644 --- a/lib/entities/server/entity_relay.lua +++ b/lib/entities/server/entity_relay.lua @@ -1,8 +1,6 @@ - -- Objects Ids = Ids or Require("lib/utility/shared/ids.lua") - local Entities = {} EntityRelay = {} @@ -45,21 +43,4 @@ function EntityRelay.LoadModel(model) return Utility.LoadModel(model) end -return EntityRelay - - - -- RegisterCommand("entityobj", function() - -- local entity = Bridge.Object.Create({ - -- id = "something", -- optional - -- model = "prop_beach_fire", - -- coords = GetEntityCoords(PlayerPedId()), - -- rotation = vector3(0.0, 0.0, 0.0), - -- }) - -- Bridge.Object.SetOnSpawn("something", function(self, coords, rotation) - -- print("Entity spawned") - -- end) - - -- Bridge.Object.SetOnRemove("something", function(self, entity) - -- print("Entity removed") - -- end) - -- end) \ No newline at end of file +return EntityRelay \ No newline at end of file diff --git a/lib/points/client/points.lua b/lib/points/client/points.lua index e5e23b5..9acf9d5 100644 --- a/lib/points/client/points.lua +++ b/lib/points/client/points.lua @@ -242,25 +242,4 @@ function Point.GetAll() return ActivePoints end --- Usage example for checking nearby points --- -- --- ▀█▀ █▄█ █ ▄▀▀ █ ▄▀▀ █▀ █ █ ▄▀▀ █▄▀ █ █▄ █ ▄▀ █▄█ ▄▀▄ ▀█▀ █▀▄ ▄▀▄ █ █▄ █ ▀█▀ ▄▀▀ █▀ ▄▀▄ █▀▄ ▄▀▀ █▀▄ ▄▀▄ █ █ █ ██▀ ▀▄▀ --- █ █ █ █ ▄█▀ █ ▄█▀ █▀ ▀▄█ ▀▄▄ █ █ █ █ ▀█ ▀▄█ █ █ ▀▄▀ █ ██ █▀ ▀▄▀ █ █ ▀█ █ ▄█▀ █▀ ▀▄▀ █▀▄ ▀▄▄ █▀▄ ▀▄▀ ▀▄▀▄▀ █▄▄ █▄▄ █ ---[[ -Point.Register("point1", vector3(100, 100, 30), 5.0, - function(point) - print("Entered point1") - end, - function(point) - print("Exited point1") - end, - function(nearbyPoints) - print("Point1 has nearby points:") - for id, point in pairs(nearbyPoints) do - print("- " .. id .. " at distance: " .. #(point.coords - ActivePoints["point1"].coords)) - end - end -) ---]] - return Point \ No newline at end of file From e6ffe48d826dce4fb79d0ef312ba115ba880bd99 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Sat, 12 Apr 2025 02:31:47 -0400 Subject: [PATCH 09/22] prints moved to prefexied prints + comments --- modules/inventory/_default/client.lua | 11 +++++++---- modules/shops/_default/client.lua | 2 +- modules/shops/_default/server.lua | 2 +- modules/vehicleKey/_default/client/client.lua | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/inventory/_default/client.lua b/modules/inventory/_default/client.lua index dc645f3..afd63b6 100644 --- a/modules/inventory/_default/client.lua +++ b/modules/inventory/_default/client.lua @@ -1,26 +1,29 @@ Inventory = Inventory or {} ----comment +---This will fallback to framework add item functions when an inventory does not have the specifiec function. ---@param item string ---@return table Inventory.GetItemInfo = function(item) return Framework.GetItemInfo(item) end ----comment +---This will fallback to framework add item functions when an inventory does not have the specifiec function. ---@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. +---@param item string +---@return number Inventory.GetItemCount = function(item) return Framework.GetItemCount(item) end ----comment +---This will provide a image of the community bridge logo if the inventory isnt bridged for the specific path. ---@param item string ---@return string Inventory.GetImagePath = function(item) return "https://avatars.githubusercontent.com/u/47620135" -end +end \ No newline at end of file diff --git a/modules/shops/_default/client.lua b/modules/shops/_default/client.lua index cc7e377..254b302 100644 --- a/modules/shops/_default/client.lua +++ b/modules/shops/_default/client.lua @@ -59,7 +59,7 @@ end ---@param shopData any ---@return nil Shops.OpenShop = function(title, shopData) - if not title and not shopData and not title then return print("No Title Passed") end + if not title and not shopData and not title then return Prints.Error("No Title Passed") end local generatedID = Ids.CreateUniqueId() local buildMenu = {} for _, v in pairs(shopData) do diff --git a/modules/shops/_default/server.lua b/modules/shops/_default/server.lua index 708c6fd..09a84fa 100644 --- a/modules/shops/_default/server.lua +++ b/modules/shops/_default/server.lua @@ -44,7 +44,7 @@ Shops.CompleteCheckout = function(src, shopName, item, amount, paymentType) break end end - if not itemData then return print("Player ID "..src.." Is Possibly A Cheater And Has Attempted To Purchase A "..item) end + if not itemData then return Prints.Error("Player ID "..src.." Is Possibly A Cheater And Has Attempted To Purchase A "..item) end if not itemData.price then return end local balance = Framework.GetAccountBalance(src, paymentType) local mathStuff = tonumber(itemData.price) * tonumber(amount) diff --git a/modules/vehicleKey/_default/client/client.lua b/modules/vehicleKey/_default/client/client.lua index 5472dc7..df07dc4 100644 --- a/modules/vehicleKey/_default/client/client.lua +++ b/modules/vehicleKey/_default/client/client.lua @@ -4,7 +4,7 @@ VehicleKey = VehicleKey or {} ---@param vehicle number The vehicle entity ID. ---@param plate string The plate of the vehicle. VehicleKey.GiveKeys = function(vehicle, plate) - return true, print("There Is No Vehicle Key System Installed") + return true, Prints.Error("There Is No Vehicle Key System Installed") end ---This will remove keys from the specifed vehicle/plate. @@ -12,5 +12,5 @@ end ---@param plate string The plate of the vehicle. ---@return boolean | nil VehicleKey.RemoveKeys = function(vehicle, plate) - return true, print("There Is No Vehicle Key System Installed") + return true, Prints.Error("There Is No Vehicle Key System Installed") end \ No newline at end of file From a5bc7dcbcc8a2549ffe95f93a596c4ef07a0d6aa Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Sat, 12 Apr 2025 02:32:55 -0400 Subject: [PATCH 10/22] Prevent confusion on github api downtime I have been getting tickets/dms when the api is down, to prevent this I have just disabled the failure portion. This isnt ideal but I dont see alerting a server owner the api is down as a solution either. --- modules/version/server/VersionChecker.lua | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/modules/version/server/VersionChecker.lua b/modules/version/server/VersionChecker.lua index dde4d03..acf583c 100644 --- a/modules/version/server/VersionChecker.lua +++ b/modules/version/server/VersionChecker.lua @@ -1,11 +1,7 @@ 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") ---@param repoPath string ---@param tebex boolean | nil @@ -23,22 +19,20 @@ function Version.VersionChecker(repoPath, tebex) local username, reponame = repoPath:match("([^/]+)/([^/]+)") if not username or not reponame then return Prints.Error('^1Invalid repository format. Expected format: "username/reponame"^0') end PerformHttpRequest(('https://api.github.com/repos/%s/%s/releases/latest'):format(username, reponame), function(status, response) - local failure = ('^1Unable locate github repo for resource %s ^0'):format(resource) - if status ~= 200 then return Prints.Error(failure) end + if status ~= 200 then return end response = json.decode(response) - if response.prerelease then return Prints.Error(failure) end - local latest = response.tag_name:match('%d+%.%d+%.%d+') - if not latest then return Prints.Error(failure) end + if not latest then return end - --if latest == version then return print(('^2 %s is on the latest version.^0'):format(resource)) 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 + 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 end, 'GET') From 04abdb44e295f4c942062f33c077df7c00adfe6b Mon Sep 17 00:00:00 2001 From: Sky <108126483+cityparadise@users.noreply.github.com> Date: Sun, 13 Apr 2025 10:46:06 +0100 Subject: [PATCH 11/22] Update shops icon in client.lua - Found missing icon when using shop module to buy stuff - Fixed typo --- modules/shops/_default/client.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/shops/_default/client.lua b/modules/shops/_default/client.lua index 254b302..02e774d 100644 --- a/modules/shops/_default/client.lua +++ b/modules/shops/_default/client.lua @@ -24,7 +24,7 @@ Shops.FinalizeCheckOut = function(shopName, item, itemLabel, price, amount) { title = locale('Shops.PayByCard').." "..tostring(mathStuff), description = locale('Shops.AreYouSure') .. itemLabel, - icon = "fa-solid fa-building-column", + icon = "fa-solid fa-building-columns", onSelect = function(_, __, ___) TriggerServerEvent('community_bridge:completeCheckout', shopName, item, amount, "bank") end @@ -75,4 +75,4 @@ Shops.OpenShop = function(title, shopData) }) end Menu.Open({ id = generatedID, title = title, options = buildMenu }, false) -end \ No newline at end of file +end From f74552db7e5d1d8b998dee9a5408f4f5d67fdeb2 Mon Sep 17 00:00:00 2001 From: Sky <108126483+cityparadise@users.noreply.github.com> Date: Sun, 13 Apr 2025 12:49:35 +0100 Subject: [PATCH 12/22] Update animation flag - Stopped animation continually running by adding flag var in animation table. --- modules/progressbar/qb-progressbar/client.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/progressbar/qb-progressbar/client.lua b/modules/progressbar/qb-progressbar/client.lua index 2fb16bc..a98cf58 100644 --- a/modules/progressbar/qb-progressbar/client.lua +++ b/modules/progressbar/qb-progressbar/client.lua @@ -22,7 +22,8 @@ local function convertFromOx(options) }, animation = { animDict = options.anim?.dict, - anim = options.anim?.clip + anim = options.anim?.clip, + flags = 49 }, prop = { model = prop1.model, @@ -78,4 +79,4 @@ RegisterCommand("progressbar", function() print(cancelled and "Cancelled" or "Complete") end) end) ---]] \ No newline at end of file +--]] From 663e3bc9c1c3f6eee03b79ac40f893f69bdcdfe3 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Sun, 13 Apr 2025 19:58:51 -0400 Subject: [PATCH 13/22] NEEDS TESTED -- Core Inventory --- modules/inventory/core_inventory/client.lua | 16 ++++++++++++++++ modules/inventory/core_inventory/server.lua | 7 ++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/inventory/core_inventory/client.lua b/modules/inventory/core_inventory/client.lua index 27eb884..21d4fac 100644 --- a/modules/inventory/core_inventory/client.lua +++ b/modules/inventory/core_inventory/client.lua @@ -13,4 +13,20 @@ Inventory.GetImagePath = function(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 + +Inventory.GetItemInfo = function(item) + local frameworkName = Framework.GetFrameworkName() + if not frameworkName then return {} end + local dataRepack = {} + if frameworkName == 'es_extended' then + 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] + if not dataRepack then return {} end + elseif frameworkName == 'qb-core' then + dataRepack = Framework.Shared.Items[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 \ No newline at end of file diff --git a/modules/inventory/core_inventory/server.lua b/modules/inventory/core_inventory/server.lua index 7acfbe8..1fbfaca 100644 --- a/modules/inventory/core_inventory/server.lua +++ b/modules/inventory/core_inventory/server.lua @@ -34,4 +34,9 @@ Inventory.UpdatePlate = function(oldplate, newplate) if GetResourceState('jg-mechanic') ~= 'started' then return true end exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) return true -end \ No newline at end of file +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 From 870f440a1bb75e41c2876d42366ab3238e4b1f82 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Mon, 14 Apr 2025 01:16:06 -0400 Subject: [PATCH 14/22] GetPlayers added while theres a native to do this, the purpose of this is using the framework methods, this will only return logged in players ie wont include people who are in multichar and still not logged in --- modules/framework/es_extended/server.lua | 11 +++++++++++ modules/framework/qb-core/server.lua | 11 +++++++++++ modules/framework/qbx_core/server.lua | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index b5c8359..f717a22 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -35,6 +35,17 @@ Framework.GetPlayerName = function(src) return xPlayer.variables.firstName, xPlayer.variables.lastName end +---This will return a table of all logged in players +---@return table +Framework.GetPlayers = function() + local players = ESX.GetExtendedPlayers() + local playerList = {} + for _, xPlayer in pairs(players) do + table.insert(playerList, xPlayer.source) + end + return playerList +end + -- Framework.GetItem(src, item, metadata) -- 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} diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index 5a48503..631532a 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -133,6 +133,17 @@ Framework.GetPlayerInventory = function(src) return repackedTable end +---This will return a table of all logged in players +---@return table +Framework.GetPlayers = function() + local players = QBCore.Functions.GetPlayers() + local playerList = {} + for _, src in pairs(players) do + table.insert(playerList, src) + end + return playerList +end + Framework.GetItemBySlot = function(src, slot) local player = QBCore.Functions.GetPlayer(src) if not player then return end diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index 4e3540d..d9e48d0 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -29,6 +29,17 @@ Framework.GetPlayerIdentifier = function(src) return playerData.citizenid end +---This will return a table of all logged in players +---@return table +Framework.GetPlayers = function() + local players = QBox:GetQBPlayers() + local playerList = {} + for src, _ in pairs(players) do + table.insert(playerList, src) + end + return playerList +end + -- Framework.GetPlayerName(src) -- Returns the first and last name of the player. Framework.GetPlayerName = function(src) From 2700c9baa9ff7204062d62bb13f004ed830eb835 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Mon, 14 Apr 2025 02:45:12 -0400 Subject: [PATCH 15/22] small patch --- lib/logs/server/logs.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/logs/server/logs.lua b/lib/logs/server/logs.lua index fa353f6..29706e3 100644 --- a/lib/logs/server/logs.lua +++ b/lib/logs/server/logs.lua @@ -49,7 +49,7 @@ Logs.Send = function(src, message) elseif BridgeServerConfig.LogSystem == "qb" then return TriggerEvent('qb-log:server:CreateLog', GetCurrentResourceName(), GetCurrentResourceName(), 'green', message) elseif BridgeServerConfig.LogSystem == "ox" then - return exports.ox_lib:logger(src, GetCurrentResourceName(), message) + return lib.logger(src, GetCurrentResourceName(), message) end end From 01f7b385c195773c63568286f846b3dbec8dd29b Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Tue, 15 Apr 2025 03:00:44 -0400 Subject: [PATCH 16/22] comments + disable dup warning --- modules/framework/es_extended/client.lua | 1 + modules/framework/es_extended/server.lua | 1 + modules/framework/qb-core/client.lua | 1 + modules/framework/qb-core/server.lua | 1 + modules/framework/qbx_core/client.lua | 1 + modules/framework/qbx_core/server.lua | 188 ++++++++++++++++------- 6 files changed, 137 insertions(+), 56 deletions(-) diff --git a/modules/framework/es_extended/client.lua b/modules/framework/es_extended/client.lua index 31bdd58..9f0145c 100644 --- a/modules/framework/es_extended/client.lua +++ b/modules/framework/es_extended/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('es_extended') ~= 'started' then return end ESX = exports["es_extended"]:getSharedObject() diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index f717a22..3e02dbf 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('es_extended') ~= 'started' then return end ESX = exports["es_extended"]:getSharedObject() diff --git a/modules/framework/qb-core/client.lua b/modules/framework/qb-core/client.lua index e9e9a04..a3ed050 100644 --- a/modules/framework/qb-core/client.lua +++ b/modules/framework/qb-core/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qb-core') ~= 'started' then return end if GetResourceState('qbx_core') == 'started' then return end diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index 631532a..7c9dd36 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qb-core') ~= 'started' then return end if GetResourceState('qbx_core') == 'started' then return end diff --git a/modules/framework/qbx_core/client.lua b/modules/framework/qbx_core/client.lua index 9e7564a..a0da4bb 100644 --- a/modules/framework/qbx_core/client.lua +++ b/modules/framework/qbx_core/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qbx_core') ~= 'started' then return end QBox = exports.qbx_core diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index d9e48d0..1a8f366 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -1,13 +1,19 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qbx_core') ~= 'started' then return end local QBox = exports.qbx_core Framework = {} +---Returns the name of the framework being used (if a supported framework). +---@return string Framework.GetFrameworkName = function() return 'qbx_core' end +---Returns the player date of birth. +---@param src number +---@return string Framework.GetPlayerDob = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -15,12 +21,15 @@ Framework.GetPlayerDob = function(src) return playerData.charinfo.birthdate end +---Returns a table of the jobs in the framework. +---@return table Framework.GetFrameworkJobs = function() return QBox.GetJobs() end --- Framework.GetPlayerIdentifier(src) --- Returns the citizen ID of the player. +---Returns the citizen ID of the player. +---@param src number +---@return string | boolean Framework.GetPlayerIdentifier = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -40,8 +49,9 @@ Framework.GetPlayers = function() return playerList end --- Framework.GetPlayerName(src) --- Returns the first and last name of the player. +---Returns the first and last name of the player. +---@param src number +---@return string | nil Framework.GetPlayerName = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -49,9 +59,11 @@ Framework.GetPlayerName = function(src) return playerData.charinfo.firstname, playerData.charinfo.lastname end --- Framework.GetItem(src, item, metadata) -- 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} +---@param src number +---@param item string +---@param metadata table +---@return table Framework.GetItem = function(src, item, metadata) local player = QBox:GetPlayer(src) if not player then return end @@ -70,8 +82,11 @@ Framework.GetItem = function(src, item, metadata) 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. +---Returns the count of items matching the specified name and if passed metadata from the player's inventory. +---@param src number +---@param item string +---@param metadata table +---@return number Framework.GetItemCount = function(src, item, metadata) local player = QBox:GetPlayer(src) if not player then return end @@ -85,7 +100,7 @@ Framework.GetItemCount = function(src, item, metadata) return count end ----comment +---Returns boolean if the player has the specified item in their inventory. ---@param src number ---@param item string ---@return boolean @@ -94,9 +109,9 @@ Framework.HasItem = function(src, item) return getCount > 0 end --- Framework.GetPlayerInventory(src) --- Returns the entire inventory of the player as a table. --- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot} +---Returns the entire inventory of the player as a table. +---@param src number +---@return table Framework.GetPlayerInventory = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -113,8 +128,11 @@ Framework.GetPlayerInventory = function(src) return repackedTable end --- Framework.SetMetadata(src, metadata, value) --- Adds the specified metadata key and number value to the player's data. +---Adds the specified metadata key and number value to the player's data. +---@param src number +---@param metadata string +---@param value string +---@return boolean Framework.SetPlayerMetadata = function(src, metadata, value) local player = QBox:GetPlayer(src) if not player then return end @@ -122,8 +140,10 @@ Framework.SetPlayerMetadata = function(src, metadata, value) return true end --- Framework.GetMetadata(src, metadata) --- Gets the specified metadata key to the player's data. +---Gets the specified metadata key to the player's data. +---@param src number +---@param metadata string +---@return string | boolean | nil Framework.GetPlayerMetadata = function(src, metadata) local player = QBox:GetPlayer(src) if not player then return end @@ -131,8 +151,10 @@ Framework.GetPlayerMetadata = function(src, metadata) return playerData.metadata[metadata] or false end --- Framework.AddStress(src, value) --- Adds the specified value to the player's stress level and updates the client HUD. +---Adds the specified value to the player's stress level and updates the client HUD. +---@param src number +---@param value number +---@return number | nil Framework.AddStress = function(src, value) local player = QBox:GetPlayer(src) if not player then return end @@ -143,8 +165,10 @@ Framework.AddStress = function(src, value) return newStress end --- Framework.RemoveStress(src, value) --- Removes the specified value from the player's stress level and updates the client HUD. +---Removes the specified value from the player's stress level and updates the client HUD. +---@param src number +---@param value number +---@return number | nil Framework.RemoveStress = function(src, value) local player = QBox:GetPlayer(src) if not player then return end @@ -155,8 +179,10 @@ Framework.RemoveStress = function(src, value) return newStress end --- Framework.AddHunger(src, value) --- Adds the specified value from the player's hunger level. +---Adds the specified value from the player's hunger level. +---@param src number +---@param value number +---@return number | nil Framework.AddHunger = function(src, value) local player = QBox:GetPlayer(src) if not player then return end @@ -167,8 +193,10 @@ Framework.AddHunger = function(src, value) return newHunger end --- Framework.AddThirst(src, value) -- Adds the specified value from the player's thirst level. +---@param src number +---@param value number +---@return number | nil Framework.AddThirst = function(src, value) local player = QBox:GetPlayer(src) if not player then return end @@ -179,6 +207,9 @@ Framework.AddThirst = function(src, value) return newThirst end +---This will return the players hunger level. +---@param src number +---@return number | nil Framework.GetHunger = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -187,6 +218,9 @@ Framework.GetHunger = function(src) return newHunger end +---This will return the players thirst level. +---@param src number +---@return number Framework.GetThirst = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -195,8 +229,9 @@ Framework.GetThirst = function(src) return newThirst end --- Framework.GetPlayerPhone(src) --- Returns the phone number of the player. +---Returns the phone number of the player. +---@param src number +---@return string | nil Framework.GetPlayerPhone = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -204,13 +239,17 @@ Framework.GetPlayerPhone = function(src) return playerData.charinfo.phone end --- Framework.GetPlayerGang(src) --- Returns the gang name of the player. +---Returns the gang name of the player. +---@param src number +---@return string | nil Framework.GetPlayerGang = function(src) local player = QBox:GetPlayer(src).PlayerData return player.gang.name end +---This will return a table of all players with the specified job. +---@param job string +---@return table Framework.GetPlayersByJob = function(job) local playerList = {} local players = QBox:GetQBPlayers() @@ -222,21 +261,32 @@ Framework.GetPlayersByJob = function(job) return playerList end --- Framework.GetPlayerJob(src) --- Returns the job name, label, grade name, and grade level of the player. +---Returns the job name, label, grade name, and grade level of the player. +---@param src number +---@return string | string | string | number | nil +---@return string | string | string | number | nil +---@return string | string | string | number | nil +---@return string | string | string | number | nil Framework.GetPlayerJob = function(src) local player = QBox: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 --- Framework.SetPlayerJob(src, name, grade) --- Sets the player's job to the specified name and grade. +---Sets the player's job to the specified name and grade. +---@param src number +---@param name string +---@param grade string +---@return boolean | nil Framework.SetPlayerJob = function(src, name, grade) local player = QBox:GetPlayer(src) if not player then return end return player.Functions.SetJob(name, grade) end +---This will toggle the duty status of the player. +---@param src number +---@param status boolean Framework.ToggleDuty = function(src, status) local player = QBox:GetPlayer(src) if not player then return end @@ -244,8 +294,11 @@ Framework.ToggleDuty = function(src, status) QBox:SetJobDuty(playerData.citizenid, status) end --- Framework.AddAccountBalance(src, _type, amount) --- Adds the specified amount to the player's account balance of the specified type. +---Adds the specified amount to the player's account balance of the specified type. +---@param src number +---@param _type string +---@param amount number +---@return boolean | nil Framework.AddAccountBalance = function(src, _type, amount) local player = QBox:GetPlayer(src) if not player then return end @@ -253,8 +306,11 @@ Framework.AddAccountBalance = function(src, _type, amount) return player.Functions.AddMoney(_type, amount) end --- Framework.RemoveAccountBalance(src, _type, amount) --- Removes the specified amount from the player's account balance of the specified type. +---Removes the specified amount from the player's account balance of the specified type. +---@param src number +---@param _type string +---@param amount number +---@return boolean | nil Framework.RemoveAccountBalance = function(src, _type, amount) local player = QBox:GetPlayer(src) if not player then return end @@ -262,8 +318,10 @@ Framework.RemoveAccountBalance = function(src, _type, amount) return player.Functions.RemoveMoney(_type, amount) end --- Framework.GetAccountBalance(src, _type) --- Returns the player's account balance of the specified type. +---Returns the player's account balance of the specified type. +---@param src number +---@param _type string +---@return number | nil Framework.GetAccountBalance = function(src, _type) local player = QBox:GetPlayer(src) if not player then return end @@ -272,8 +330,13 @@ Framework.GetAccountBalance = function(src, _type) return playerData.money[_type] end --- Framework.AddItem(src, item, amount, slot, metadata) --- Adds the specified item to the player's inventory. +---Adds the specified item to the player's inventory. +---@param src number +---@param item string +---@param amount number +---@param slot number +---@param metadata table +---@return boolean | nil Framework.AddItem = function(src, item, amount, slot, metadata) local player = QBox:GetPlayer(src) if not player then return end @@ -281,8 +344,13 @@ Framework.AddItem = function(src, item, amount, slot, metadata) return player.Functions.AddItem(item, amount, slot, metadata) end --- Framework.RemoveItem(src, item, amount, slot, metadata) --- Removes the specified item from the player's inventory. +---Removes the specified item from the player's inventory. +---@param src number +---@param item string +---@param amount number +---@param slot number +---@param metadata table +---@return boolean | nil Framework.RemoveItem = function(src, item, amount, slot, metadata) local player = QBox:GetPlayer(src) if not player then return end @@ -290,9 +358,12 @@ Framework.RemoveItem = function(src, item, amount, slot, metadata) return player.Functions.RemoveItem(item, amount, slot) end --- Framework.SetMetadata(src, item, slot, metadata) --- 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 +---Sets the metadata for the specified item in the player's inventory. +-----@param src number +---@param item string +---@param slot number +---@param metadata table +---@return boolean | nil Framework.SetMetadata = function(src, item, slot, metadata) local player = QBox:GetPlayer(src) if not player then return end @@ -300,6 +371,9 @@ Framework.SetMetadata = function(src, item, slot, metadata) return player.Functions.AddItem(item, 1, slot, metadata) end +---Returns a table of owned vehicles for the player. format is {vehicle = vehicle, plate = plate} +---@param src number +---@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 .. "'") @@ -312,6 +386,19 @@ Framework.GetOwnedVehicles = function(src) return vehicles end +---Registers a usable item with a callback function. +---@param itemName string +---@param cb function +---@return function +Framework.RegisterUsableItem = function(itemName, cb) + local func = function(src, item, itemData) + itemData = itemData or item + itemData.metadata = itemData.metadata or itemData.info or {} + cb(src, itemData) + end + return QBox:CreateUseableItem(itemName, func) +end + RegisterNetEvent("QBCore:Server:OnPlayerLoaded", function() local src = source TriggerEvent("community_bridge:Server:OnPlayerLoaded", src) @@ -325,15 +412,4 @@ end) AddEventHandler("playerDropped", function() local src = source TriggerEvent("community_bridge:Server:OnPlayerUnload", src) -end) - --- Framework.RegisterUsableItem(item, cb) --- Registers a usable item with a callback function. -Framework.RegisterUsableItem = function(itemName, cb) - local func = function(src, item, itemData) - itemData = itemData or item - itemData.metadata = itemData.metadata or itemData.info or {} - cb(src, itemData) - end - return QBox:CreateUseableItem(itemName, func) -end \ No newline at end of file +end) \ No newline at end of file From 329d3328d8ccc6f79ebfe4b46ec65b67b1d798b0 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Tue, 15 Apr 2025 07:06:57 -0400 Subject: [PATCH 17/22] experimental housing module - wip --- fxmanifest.lua | 2 ++ init.lua | 1 + modules/housing/_defualts/client.lua | 1 + modules/housing/_defualts/server.lua | 12 ++++++++++++ modules/housing/bcs-housing/client.lua | 11 +++++++++++ modules/housing/bcs-housing/server.lua | 3 +++ modules/housing/esx_property/client.lua | 3 +++ modules/housing/esx_property/server.lua | 13 +++++++++++++ modules/housing/ps-housing/client.lua | 3 +++ modules/housing/ps-housing/server.lua | 13 +++++++++++++ modules/housing/qb-appartments/client.lua | 3 +++ modules/housing/qb-appartments/server.lua | 9 +++++++++ modules/housing/qb-houses/client.lua | 3 +++ modules/housing/qb-houses/server.lua | 9 +++++++++ 14 files changed, 86 insertions(+) create mode 100644 modules/housing/_defualts/client.lua create mode 100644 modules/housing/_defualts/server.lua create mode 100644 modules/housing/bcs-housing/client.lua create mode 100644 modules/housing/bcs-housing/server.lua create mode 100644 modules/housing/esx_property/client.lua create mode 100644 modules/housing/esx_property/server.lua create mode 100644 modules/housing/ps-housing/client.lua create mode 100644 modules/housing/ps-housing/server.lua create mode 100644 modules/housing/qb-appartments/client.lua create mode 100644 modules/housing/qb-appartments/server.lua create mode 100644 modules/housing/qb-houses/client.lua create mode 100644 modules/housing/qb-houses/server.lua diff --git a/fxmanifest.lua b/fxmanifest.lua index 4acca46..7c10082 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -28,6 +28,7 @@ server_scripts { 'modules/clothing/**/server.lua', 'modules/shops/**/server.lua', 'modules/notify/**/server.lua', + 'modules/housing/**/server.lua', 'init.lua', } @@ -50,6 +51,7 @@ client_scripts { 'modules/notify/**/client.lua', 'modules/dialogue/**/client/*.lua', 'modules/shops/**/client.lua', + 'modules/housing/**/client.lua', 'modules/accessibility/client.lua', 'init.lua', } diff --git a/init.lua b/init.lua index 3c6340b..646a1f0 100644 --- a/init.lua +++ b/init.lua @@ -53,6 +53,7 @@ Bridge.RegisterModule("Doorlock", Doorlock) Bridge.RegisterModule("Phone", Phone) Bridge.RegisterModule("Dispatch", Dispatch) Bridge.RegisterModule("Shops", Shops) +Bridge.RegisterModule("Housing", Housing) --lib Bridge.RegisterModule("Tables", cLib.Tables) diff --git a/modules/housing/_defualts/client.lua b/modules/housing/_defualts/client.lua new file mode 100644 index 0000000..4e660db --- /dev/null +++ b/modules/housing/_defualts/client.lua @@ -0,0 +1 @@ +Housing = Housing or {} \ No newline at end of file diff --git a/modules/housing/_defualts/server.lua b/modules/housing/_defualts/server.lua new file mode 100644 index 0000000..dcfb42b --- /dev/null +++ b/modules/housing/_defualts/server.lua @@ -0,0 +1,12 @@ +Housing = Housing or {} + +---This is an internal event, listen for 'community_bridge:Client:OnPlayerInside' instead. +---This event is triggered when a player enters or leaves a property. +---@param src number +---@param insideId string +RegisterNetEvent('community_bridge:Server:_OnPlayerInside', function(src, insideId) + local currentBucket = GetPlayerRoutingBucket(src) + local playerEntity = GetPlayerPed(src) + local playerCoords = GetEntityCoords(playerEntity) + TriggerEvent('community_bridge:Client:OnPlayerInside', src, insideId, currentBucket, playerCoords) +end) \ No newline at end of file diff --git a/modules/housing/bcs-housing/client.lua b/modules/housing/bcs-housing/client.lua new file mode 100644 index 0000000..d5d2396 --- /dev/null +++ b/modules/housing/bcs-housing/client.lua @@ -0,0 +1,11 @@ +if GetResourceState('bcs-housing') ~= 'started' then return end + +Housing = Housing or {} + +RegisterNetEvent('Housing:client:EnterHome', function(insideId) + TriggerServerEvent('community_bridge:Server:_OnPlayerInside', insideId) +end) + +RegisterNetEvent("Housing:client:DeleteFurnitures", function() + TriggerServerEvent('community_bridge:Server:_OnPlayerInside', false) +end) \ No newline at end of file diff --git a/modules/housing/bcs-housing/server.lua b/modules/housing/bcs-housing/server.lua new file mode 100644 index 0000000..f4263c0 --- /dev/null +++ b/modules/housing/bcs-housing/server.lua @@ -0,0 +1,3 @@ +if GetResourceState('bcs-housing') ~= 'started' then return end + +Housing = Housing or {} \ No newline at end of file diff --git a/modules/housing/esx_property/client.lua b/modules/housing/esx_property/client.lua new file mode 100644 index 0000000..3d3238f --- /dev/null +++ b/modules/housing/esx_property/client.lua @@ -0,0 +1,3 @@ +if GetResourceState('esx_property') ~= 'started' then return end + +Housing = Housing or {} \ No newline at end of file diff --git a/modules/housing/esx_property/server.lua b/modules/housing/esx_property/server.lua new file mode 100644 index 0000000..5243ae7 --- /dev/null +++ b/modules/housing/esx_property/server.lua @@ -0,0 +1,13 @@ +if GetResourceState('esx_property') ~= 'started' then return end + +Housing = Housing or {} + +RegisterNetEvent('esx_property:enter', function(insideId) + local src = source + TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) +end) + +RegisterNetEvent('esx_property:leave', function(insideId) + local src = source + TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) +end) \ No newline at end of file diff --git a/modules/housing/ps-housing/client.lua b/modules/housing/ps-housing/client.lua new file mode 100644 index 0000000..a40ae1c --- /dev/null +++ b/modules/housing/ps-housing/client.lua @@ -0,0 +1,3 @@ +if GetResourceState('ps-housing') ~= 'started' then return end + +Housing = Housing or {} \ No newline at end of file diff --git a/modules/housing/ps-housing/server.lua b/modules/housing/ps-housing/server.lua new file mode 100644 index 0000000..d364c2e --- /dev/null +++ b/modules/housing/ps-housing/server.lua @@ -0,0 +1,13 @@ +if GetResourceState('ps-housing') ~= 'started' then return end + +Housing = Housing or {} + +RegisterNetEvent('ps-housing:server:enterProperty', function(insideId) + local src = source + TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) +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 diff --git a/modules/housing/qb-appartments/client.lua b/modules/housing/qb-appartments/client.lua new file mode 100644 index 0000000..5d6b7f8 --- /dev/null +++ b/modules/housing/qb-appartments/client.lua @@ -0,0 +1,3 @@ +if GetResourceState('qb-appartments') ~= 'started' then return end + +Housing = Housing or {} \ No newline at end of file diff --git a/modules/housing/qb-appartments/server.lua b/modules/housing/qb-appartments/server.lua new file mode 100644 index 0000000..6c5f6c5 --- /dev/null +++ b/modules/housing/qb-appartments/server.lua @@ -0,0 +1,9 @@ +if GetResourceState('qb-appartments') ~= 'started' then return end + +Housing = Housing or {} + +RegisterNetEvent('qb-apartments:server:SetInsideMeta', function(house, insideId, bool, isVisiting) + local src = source + insideId = bool and house .. '-' .. insideId or nil + TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) +end) \ No newline at end of file diff --git a/modules/housing/qb-houses/client.lua b/modules/housing/qb-houses/client.lua new file mode 100644 index 0000000..e1e61cf --- /dev/null +++ b/modules/housing/qb-houses/client.lua @@ -0,0 +1,3 @@ +if GetResourceState('qb-houses') ~= 'started' then return end + +Housing = Housing or {} \ No newline at end of file diff --git a/modules/housing/qb-houses/server.lua b/modules/housing/qb-houses/server.lua new file mode 100644 index 0000000..7fac010 --- /dev/null +++ b/modules/housing/qb-houses/server.lua @@ -0,0 +1,9 @@ +if GetResourceState('qb-houses') ~= 'started' then return end + +Housing = Housing or {} + +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 From 5d3a9d1950b7a18122ecd1295de0fbe7813da817 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Tue, 15 Apr 2025 08:04:43 -0400 Subject: [PATCH 18/22] Get/SetPlayerDuty --- modules/framework/es_extended/server.lua | 43 ++++++++++++++++++------ modules/framework/qb-core/server.lua | 34 ++++++++++++------- modules/framework/qbx_core/server.lua | 14 +++++++- 3 files changed, 67 insertions(+), 24 deletions(-) diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index 3e02dbf..fabaf0e 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -172,12 +172,41 @@ Framework.GetPlayerPhone = function(src) return xPlayer.get("phone_number") end --- Framework.GetPlayerJob(src) --- Returns the job name, label, grade name, and grade level of the player. + +---Returns the job name, label, grade name, and grade level of the player. +---@param src number +---@return string | nil +---@return string | nil +---@return string | nil +---@return string | nil Framework.GetPlayerJob = function(src) local xPlayer = ESX.GetPlayerFromId(src) if not xPlayer then return end - return xPlayer.getJob().name, xPlayer.getJob().label, xPlayer.getJob().grade_label, xPlayer.getJob().grade + local job = xPlayer.getJob() + return job.name, job.label, job.grade_label, job.grade +end + +---Returns the players duty status. +---@param src number +---@return boolean +Framework.GetPlayerDuty = function(src) + local xPlayer = ESX.GetPlayerFromId(src) + if not xPlayer then return false end + local job = xPlayer.getJob() + if not job.onDuty then return false end + return true +end + +---Sets the players duty status. +---@param src number +---@param dutystatus boolean +---@return boolean +Framework.SetPlayerDuty = function(src, dutystatus) + local xPlayer = ESX.GetPlayerFromId(src) + if not xPlayer then return false end + local job = xPlayer.getJob() + if not job.onDuty then return false end + return xPlayer.setJob(job.name, job.grade, dutystatus) end -- Framework.GetPlayersByJob(jobname) @@ -203,14 +232,6 @@ Framework.SetPlayerJob = function(src, name, grade) return xPlayer.setJob(name, grade, true) end -Framework.ToggleDuty = function(src, status) - local xPlayer = ESX.GetPlayerFromId(src) - if not xPlayer then return end - local name = xPlayer.getJob().name - local grade = xPlayer.getJob().grade - xPlayer.setJob(name, grade, status) -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) diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index 7c9dd36..ff641b1 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -308,6 +308,28 @@ Framework.GetPlayerJob = function(src) return playerData.job.name, playerData.job.label, playerData.job.grade.name, playerData.job.grade.level end +---Returns the players duty status. +---@param src number +---@return boolean | nil +Framework.GetPlayerDuty = function(src) + local player = QBCore.Functions.GetPlayer(src) + if not player then return end + local playerData = player.PlayerData + if not playerData.job.onduty then return false end + return true +end + +---This will toggle a players duty status +---@param src number +---@param status boolean +---@return nil +Framework.SetPlayerDuty = function(src, status) + local player = QBCore.Functions.GetPlayer(src) + if not player then return end + player.Functions.SetJobDuty(status) + TriggerEvent('QBCore:Server:SetDuty', src, player.PlayerData.job.onduty) +end + -- Sets the player's job to the specified name and grade. ---@param src number ---@param name string @@ -319,18 +341,6 @@ Framework.SetPlayerJob = function(src, name, grade) return player.Functions.SetJob(name, grade) end ----This will toggle a players duty status ----@param src number ----@param status boolean ----@return nil -Framework.ToggleDuty = function(src, status) - local player = QBCore.Functions.GetPlayer(src) - if not player then return end - player.Functions.SetJobDuty(status) - TriggerEvent('QBCore:Server:SetDuty', src, player.PlayerData.job.onduty) -end - - ---This will add money based on the type of account (money/bank) ---@param src number ---@param _type string diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index 1a8f366..94e30c4 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -287,11 +287,23 @@ end ---This will toggle the duty status of the player. ---@param src number ---@param status boolean -Framework.ToggleDuty = function(src, status) +Framework.SetPlayerDuty = function(src, status) local player = QBox:GetPlayer(src) if not player then return end local playerData = player.PlayerData QBox:SetJobDuty(playerData.citizenid, status) + TriggerEvent('QBCore:Server:SetDuty', src, player.PlayerData.job.onduty) +end + +---Returns the players duty status. +---@param src number +---@return boolean | nil +Framework.GetPlayerDuty = function(src) + local player = QBox:GetPlayer(src) + if not player then return end + local playerData = player.PlayerData + if not playerData.job.onduty then return false end + return true end ---Adds the specified amount to the player's account balance of the specified type. From bd0074a156486e2037c889f7effd3854c628fb39 Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Wed, 16 Apr 2025 05:24:03 -0500 Subject: [PATCH 19/22] Inventory Update Added serverside iteminfo and consolidated image path. Now returns full nui path in .image --- modules/framework/qb-core/server.lua | 12 ++++++++---- modules/inventory/_default/client.lua | 7 +++++++ modules/inventory/_default/server.lua | 7 +++++++ modules/inventory/codem-inventory/client.lua | 4 +++- modules/inventory/codem-inventory/server.lua | 1 + modules/inventory/core_inventory/client.lua | 1 + modules/inventory/core_inventory/server.lua | 1 + modules/inventory/jpr-inventory/client.lua | 1 + modules/inventory/jpr-inventory/server.lua | 1 + modules/inventory/origen_inventory/client.lua | 1 + modules/inventory/origen_inventory/server.lua | 1 + modules/inventory/ox_inventory/client.lua | 1 + modules/inventory/ox_inventory/server.lua | 19 +++++++++++++++++++ modules/inventory/ps-inventory/client.lua | 1 + modules/inventory/ps-inventory/server.lua | 1 + modules/inventory/qb-inventory/client.lua | 3 ++- modules/inventory/qb-inventory/server.lua | 16 ++++++++++++++++ modules/inventory/qs-inventory/client.lua | 1 + modules/inventory/qs-inventory/server.lua | 1 + modules/inventory/tgiann-inventory/client.lua | 1 + modules/inventory/tgiann-inventory/server.lua | 1 + modules/progressbar/qb-progressbar/client.lua | 10 +++++++--- 22 files changed, 83 insertions(+), 9 deletions(-) diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index ff641b1..8df05f2 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -5,7 +5,7 @@ if GetResourceState('qbx_core') == 'started' then return end QBCore = exports['qb-core']:GetCoreObject() Framework = {} - +Framework.Shared = QBCore.Shared Framework.GetFrameworkName = function() return 'qb-core' end @@ -222,7 +222,9 @@ Framework.AddHunger = function(src, value) local playerData = player.PlayerData local newHunger = (playerData.metadata.hunger or 0) + 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 @@ -235,6 +237,7 @@ Framework.AddThirst = function(src, value) local playerData = player.PlayerData local newThirst = (playerData.metadata.thirst or 0) + value player.Functions.SetMetaData('thirst', Math.Clamp(newThirst, 0, 100)) + TriggerClientEvent('hud:client:UpdateNeeds', src, playerData.metadata.hunger, newThirst) --TriggerClientEvent('hud:client:UpdateStress', src, newStress) return newThirst end @@ -412,8 +415,8 @@ Framework.SetMetadata = function(src, item, slot, metadata) end end end - player.Functions.RemoveItem(item, 1, itemSlot) - return player.Functions.AddItem(item, 1, freeSlot, metadata) + if not player.Functions.RemoveItem(item, 1, itemSlot) then return false end + return player.Functions.AddItem(item, 1, slot, metadata) end ---This will get all owned vehicles for the player @@ -460,4 +463,5 @@ end) Framework.Commands = {} Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...) QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...) -end \ No newline at end of file +end + diff --git a/modules/inventory/_default/client.lua b/modules/inventory/_default/client.lua index afd63b6..21991ad 100644 --- a/modules/inventory/_default/client.lua +++ b/modules/inventory/_default/client.lua @@ -26,4 +26,11 @@ end ---@return string Inventory.GetImagePath = function(item) return "https://avatars.githubusercontent.com/u/47620135" +end + +Inventory.StripPNG = function(item) + if string.find(item, ".png") then + item = string.gsub(item, ".png", "") + end + return item end \ No newline at end of file diff --git a/modules/inventory/_default/server.lua b/modules/inventory/_default/server.lua index 87eb68c..2d42c54 100644 --- a/modules/inventory/_default/server.lua +++ b/modules/inventory/_default/server.lua @@ -83,4 +83,11 @@ end ---@return string Inventory.GetImagePath = function(item) return "https://avatars.githubusercontent.com/u/47620135" +end + +Inventory.StripPNG = function(item) + if string.find(item, ".png") then + item = string.gsub(item, ".png", "") + end + return item end \ No newline at end of file diff --git a/modules/inventory/codem-inventory/client.lua b/modules/inventory/codem-inventory/client.lua index fc616b5..11be4c5 100644 --- a/modules/inventory/codem-inventory/client.lua +++ b/modules/inventory/codem-inventory/client.lua @@ -8,13 +8,14 @@ local codem = exports['codem-inventory'] ---@return table Inventory.GetItemInfo = function(item) local itemData = codem:GetItemList(item) + local image = itemData.image and Inventory.GetImagePath(itemData.image) or Inventory.GetImagePath(item) local repackedTable = { 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), + image = image, } return repackedTable or {} end @@ -43,6 +44,7 @@ end ---@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" diff --git a/modules/inventory/codem-inventory/server.lua b/modules/inventory/codem-inventory/server.lua index 55d0b3b..cbf6847 100644 --- a/modules/inventory/codem-inventory/server.lua +++ b/modules/inventory/codem-inventory/server.lua @@ -86,6 +86,7 @@ Inventory.GetItemBySlot = function(src, slot) end 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" diff --git a/modules/inventory/core_inventory/client.lua b/modules/inventory/core_inventory/client.lua index 21d4fac..2e9cce0 100644 --- a/modules/inventory/core_inventory/client.lua +++ b/modules/inventory/core_inventory/client.lua @@ -10,6 +10,7 @@ Inventory = Inventory or {} ---@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" diff --git a/modules/inventory/core_inventory/server.lua b/modules/inventory/core_inventory/server.lua index 1fbfaca..f4aa30d 100644 --- a/modules/inventory/core_inventory/server.lua +++ b/modules/inventory/core_inventory/server.lua @@ -8,6 +8,7 @@ local core = exports.core_inventory ---@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" diff --git a/modules/inventory/jpr-inventory/client.lua b/modules/inventory/jpr-inventory/client.lua index 7f1afdd..f7deebc 100644 --- a/modules/inventory/jpr-inventory/client.lua +++ b/modules/inventory/jpr-inventory/client.lua @@ -20,6 +20,7 @@ end ---@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" diff --git a/modules/inventory/jpr-inventory/server.lua b/modules/inventory/jpr-inventory/server.lua index 06b4f12..9c7cf01 100644 --- a/modules/inventory/jpr-inventory/server.lua +++ b/modules/inventory/jpr-inventory/server.lua @@ -43,6 +43,7 @@ end ---@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" diff --git a/modules/inventory/origen_inventory/client.lua b/modules/inventory/origen_inventory/client.lua index 7f86414..a7f8359 100644 --- a/modules/inventory/origen_inventory/client.lua +++ b/modules/inventory/origen_inventory/client.lua @@ -43,6 +43,7 @@ end ---@param item string ---@return string 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" diff --git a/modules/inventory/origen_inventory/server.lua b/modules/inventory/origen_inventory/server.lua index 5605d56..4bc27d4 100644 --- a/modules/inventory/origen_inventory/server.lua +++ b/modules/inventory/origen_inventory/server.lua @@ -104,6 +104,7 @@ Inventory.SetMetadata = function(src, item, 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" diff --git a/modules/inventory/ox_inventory/client.lua b/modules/inventory/ox_inventory/client.lua index 721f8ca..766c571 100644 --- a/modules/inventory/ox_inventory/client.lua +++ b/modules/inventory/ox_inventory/client.lua @@ -40,6 +40,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item)) local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/ox_inventory/server.lua b/modules/inventory/ox_inventory/server.lua index e16db1e..a195b31 100644 --- a/modules/inventory/ox_inventory/server.lua +++ b/modules/inventory/ox_inventory/server.lua @@ -16,6 +16,24 @@ 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 + local repackedTable = { + 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) + ), + } + return repackedTable +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 @@ -148,6 +166,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item)) local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/ps-inventory/client.lua b/modules/inventory/ps-inventory/client.lua index 7e459e2..6d37dd6 100644 --- a/modules/inventory/ps-inventory/client.lua +++ b/modules/inventory/ps-inventory/client.lua @@ -22,6 +22,7 @@ end ---@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" diff --git a/modules/inventory/ps-inventory/server.lua b/modules/inventory/ps-inventory/server.lua index 3854241..ff95702 100644 --- a/modules/inventory/ps-inventory/server.lua +++ b/modules/inventory/ps-inventory/server.lua @@ -36,6 +36,7 @@ end ---@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" diff --git a/modules/inventory/qb-inventory/client.lua b/modules/inventory/qb-inventory/client.lua index 2507543..0818f4f 100644 --- a/modules/inventory/qb-inventory/client.lua +++ b/modules/inventory/qb-inventory/client.lua @@ -21,6 +21,7 @@ end ---@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" @@ -35,7 +36,7 @@ Inventory.GetItemInfo = function(item) stack = itemData.unique, weight = itemData.weight, description = itemData.description, - image = Inventory.GetImagePath(itemData.name) + 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 03b43ff..ba70836 100644 --- a/modules/inventory/qb-inventory/server.lua +++ b/modules/inventory/qb-inventory/server.lua @@ -40,10 +40,26 @@ Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coo end +Inventory.GetItemInfo = function(item) + local itemData = Framework.Shared.Items[item] + if not itemData then return {} end + local repackedTable = { + name = itemData.name, + label = itemData.label, + stack = itemData.unique, + weight = itemData.weight, + description = itemData.description, + image = Inventory.GetImagePath(itemData.image or itemData.name) + } + return repackedTable +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" diff --git a/modules/inventory/qs-inventory/client.lua b/modules/inventory/qs-inventory/client.lua index 99a9c8b..91a1671 100644 --- a/modules/inventory/qs-inventory/client.lua +++ b/modules/inventory/qs-inventory/client.lua @@ -39,6 +39,7 @@ 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" diff --git a/modules/inventory/qs-inventory/server.lua b/modules/inventory/qs-inventory/server.lua index a3496d1..699917f 100644 --- a/modules/inventory/qs-inventory/server.lua +++ b/modules/inventory/qs-inventory/server.lua @@ -153,6 +153,7 @@ 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" diff --git a/modules/inventory/tgiann-inventory/client.lua b/modules/inventory/tgiann-inventory/client.lua index 93183fd..5ddcee4 100644 --- a/modules/inventory/tgiann-inventory/client.lua +++ b/modules/inventory/tgiann-inventory/client.lua @@ -44,6 +44,7 @@ end ---@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) diff --git a/modules/inventory/tgiann-inventory/server.lua b/modules/inventory/tgiann-inventory/server.lua index 0456e1d..6219a5e 100644 --- a/modules/inventory/tgiann-inventory/server.lua +++ b/modules/inventory/tgiann-inventory/server.lua @@ -135,6 +135,7 @@ end ---@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) diff --git a/modules/progressbar/qb-progressbar/client.lua b/modules/progressbar/qb-progressbar/client.lua index a98cf58..5540dce 100644 --- a/modules/progressbar/qb-progressbar/client.lua +++ b/modules/progressbar/qb-progressbar/client.lua @@ -44,15 +44,19 @@ end ---@param options table ---@param cb any ---@param qbFormat boolean ----@return nil +---@return success boolean function ProgressBar.Open(options, cb, qbFormat) if not exports['progressbar'] then return false end if not qbFormat then options = convertFromOx(options) end - - exports['progressbar']:Progress(options, cb) + local prom = promise.new() + exports['progressbar']:Progress(options, function(cancelled) + if cb then cb(not cancelled) end + prom:resolve(not cancelled) + end) + return Citizen.Await(prom) end From 7d43d65058202249167905ffffed1b78636a8efd Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Sat, 19 Apr 2025 13:26:20 -0500 Subject: [PATCH 20/22] Jamazzz update to particles Huge shout out to jamazzz for fixing particles. Pending CreateOnEntity and CreateOnEntityBone (untested) --- init.lua | 2 +- lib/particles/client/particles.lua | 85 ++++++++++++++++++++---------- 2 files changed, 58 insertions(+), 29 deletions(-) diff --git a/init.lua b/init.lua index 646a1f0..a13bd78 100644 --- a/init.lua +++ b/init.lua @@ -110,7 +110,7 @@ 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) -- Fill the bridge tables with player data. diff --git a/lib/particles/client/particles.lua b/lib/particles/client/particles.lua index 89ed5f2..f0cc83a 100644 --- a/lib/particles/client/particles.lua +++ b/lib/particles/client/particles.lua @@ -1,22 +1,20 @@ Particle = {} -Particles = {} - ---- Load a particle dictionary. This function will block until the dictionary is loaded. ---- @param dict string -- The name of the particle dictionary to load. ---- @return boolean -- Returns true if the dictionary was loaded successfully, false otherwise. ---- @throws string -- Throws an error if the dictionary fails to load after 100 attempts. -function Particle.LoadDict(dict) - RequestNamedPtfxAsset(dict) +---Loads a ptfx asset into memory. +---@param dict string +---@return boolean +function LoadPtfxAsset(dict) local failed = 100 while not HasNamedPtfxAssetLoaded(dict) and failed >= 0 do + RequestNamedPtfxAsset(dict) failed = failed - 1 - Wait(50) + Wait(100) end - assert(failed >= 0, "Failed to load particle dictionary: " .. dict) - return true + assert(failed > 0, "Failed to load dict asset: " .. dict) + return HasNamedPtfxAssetLoaded(dict) end + --- Create a particle effect at the specified position and rotation. --- @param dict string --- @param ptfx string @@ -28,26 +26,57 @@ end --- @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) - if not Particle.LoadDict(dict) then return end - UseParticleFxAssetNextCall(dict) - local handle = nil - if looped then - handle = StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false) - SetParticleFxLoopedColour(handle, color.x, color.y, color.z, false) - if loopLength then - Wait(loopLength) - StopParticleFxLooped(handle, 0) - RemoveParticleFx(handle, false) - end - else + LoadPtfxAsset(dict) + CreateThread(function() + UseParticleFxAssetNextCall(dict) SetParticleFxNonLoopedColour(color.x, color.y, color.z) - handle = StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false) - RemoveParticleFx(handle, false) - end - return handle + if looped then + StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false) + if loopLength then + Wait(loopLength) + RemoveParticleFxInRange(pos.x, pos.y, pos.z, 0.01) + end + else + StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false) + end + RemoveNamedPtfxAsset(ptfx) + end) end --- need to add looping effects (regarless of if its a looped particle or not) +function Particle.CreateOnEntity(dict, ptfx, entity, offset, rot, scale, color, looped, loopLength) + LoadPtfxAsset(dict) + UseParticleFxAssetNextCall(dict) + SetParticleFxNonLoopedColour(color.x, color.y, color.z) + local particle = nil + if looped then + particle = StartNetworkedParticleFxLoopedOnEntity(ptfx, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, scale, false, false, false) + if loopLength then + Wait(loopLength) + RemoveParticleFxFromEntity(entity) + end + else + particle = StartNetworkedParticleFxLoopedOnEntity(ptfx, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, scale, false, false, false) + end + RemoveNamedPtfxAsset(ptfx) + return particle +end +function Particle.CreateOnEntityBone(dict, ptfx, entity, bone, offset, rot, scale, color, looped, loopLength) + LoadPtfxAsset(dict) + UseParticleFxAssetNextCall(dict) + SetParticleFxNonLoopedColour(color.x, color.y, color.z) + local particle = nil + if looped then + particle = StartNetworkedParticleFxLoopedOnEntityBone(ptfx, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, bone, scale, false, false, false) + if loopLength then + Wait(loopLength) + RemoveParticleFxFromEntity(entity) + end + else + particle = StartNetworkedParticleFxNonLoopedOnEntityBone(ptfx, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, bone, scale, false, false, false) + end + RemoveNamedPtfxAsset(ptfx) + return particle +end return Particle \ No newline at end of file From 2fb2edff9bd88e0623748d22ef8e25ecabf309f1 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Sat, 19 Apr 2025 14:36:10 -0400 Subject: [PATCH 21/22] Fuel.GetFuelName --- modules/fuel/_defualts/client.lua | 6 ++++++ modules/fuel/bigDaddy-Fuel/client.lua | 15 +++++++++++++-- modules/fuel/cdn-fuel/client.lua | 16 ++++++++++++++-- modules/fuel/esx-sna-fuel/client.lua | 18 +++++++++++++++--- modules/fuel/lc_fuel/client.lua | 19 +++++++++++++++---- modules/fuel/legacyfuel/client.lua | 14 +++++++++++++- modules/fuel/okokGasStation/client.lua | 15 ++++++++++++++- modules/fuel/ox_fuel/client.lua | 15 ++++++++++++++- modules/fuel/ps-fuel/client.lua | 15 ++++++++++++++- modules/fuel/qs-fuelstations/client.lua | 17 +++++++++++++++-- modules/fuel/renewed-Fuel/client.lua | 15 ++++++++++++++- modules/fuel/ti_fuel/client.lua | 15 ++++++++++++++- modules/fuel/x-fuel/client.lua | 15 ++++++++++++++- 13 files changed, 175 insertions(+), 20 deletions(-) diff --git a/modules/fuel/_defualts/client.lua b/modules/fuel/_defualts/client.lua index b453052..9663fd4 100644 --- a/modules/fuel/_defualts/client.lua +++ b/modules/fuel/_defualts/client.lua @@ -1,5 +1,11 @@ Fuel = Fuel or {} + +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return 'default' +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. diff --git a/modules/fuel/bigDaddy-Fuel/client.lua b/modules/fuel/bigDaddy-Fuel/client.lua index f1f0a46..d2e7a92 100644 --- a/modules/fuel/bigDaddy-Fuel/client.lua +++ b/modules/fuel/bigDaddy-Fuel/client.lua @@ -2,15 +2,26 @@ local resourceName = "BigDaddy-Fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading BigDaddy-Fuel") ---if GetResourceState('BigDaddy-Fuel') ~= 'started' then return end Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +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. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['BigDaddy-Fuel']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end exports['BigDaddy-Fuel']:SetFuel(vehicle, fuel) diff --git a/modules/fuel/cdn-fuel/client.lua b/modules/fuel/cdn-fuel/client.lua index bb5b1d7..c9ae93a 100644 --- a/modules/fuel/cdn-fuel/client.lua +++ b/modules/fuel/cdn-fuel/client.lua @@ -1,15 +1,27 @@ local resourceName = "cdn-fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end -----print("Fuel: Loading cdn-fuel") ---if GetResourceState('cdn-fuel') ~= 'started' then return end + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +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. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['cdn-fuel']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return exports['cdn-fuel']:SetFuel(vehicle, fuel) diff --git a/modules/fuel/esx-sna-fuel/client.lua b/modules/fuel/esx-sna-fuel/client.lua index acfac8d..6c4588c 100644 --- a/modules/fuel/esx-sna-fuel/client.lua +++ b/modules/fuel/esx-sna-fuel/client.lua @@ -1,16 +1,28 @@ local resourceName = "esx-sna-fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading esx-sna-fuel") ---if GetResourceState('esx-sna-fuel') ~= 'started' then return end + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +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. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['esx-sna-fuel']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end exports['esx-sna-fuel']:SetFuel(vehicle, fuel) -end +end \ No newline at end of file diff --git a/modules/fuel/lc_fuel/client.lua b/modules/fuel/lc_fuel/client.lua index d455e9c..5df01b9 100644 --- a/modules/fuel/lc_fuel/client.lua +++ b/modules/fuel/lc_fuel/client.lua @@ -1,17 +1,28 @@ local resourceName = "lc_fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading lc_fuel") -if GetResourceState('lc_fuel') ~= 'started' then return end + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +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. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports["lc_fuel"]:GetFuel(vehicle) end - +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports["lc_fuel"]:SetFuel(vehicle, fuel) -end +end \ No newline at end of file diff --git a/modules/fuel/legacyfuel/client.lua b/modules/fuel/legacyfuel/client.lua index d788982..1eb4e92 100644 --- a/modules/fuel/legacyfuel/client.lua +++ b/modules/fuel/legacyfuel/client.lua @@ -1,15 +1,27 @@ local resourceName = "LegacyFuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading LegacyFuel") Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +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. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['LegacyFuel']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports['LegacyFuel']:SetFuel(vehicle, fuel) diff --git a/modules/fuel/okokGasStation/client.lua b/modules/fuel/okokGasStation/client.lua index 147588f..8c5741b 100644 --- a/modules/fuel/okokGasStation/client.lua +++ b/modules/fuel/okokGasStation/client.lua @@ -1,14 +1,27 @@ local resourceName = "okokGasStation" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading okokGasStation") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +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. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['okokGasStation']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports['okokGasStation']:SetFuel(vehicle, fuel) diff --git a/modules/fuel/ox_fuel/client.lua b/modules/fuel/ox_fuel/client.lua index 730fe27..75da8d7 100644 --- a/modules/fuel/ox_fuel/client.lua +++ b/modules/fuel/ox_fuel/client.lua @@ -1,14 +1,27 @@ local resourceName = "ox_fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading ox_fuel") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +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. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return Entity(vehicle).state.fuel end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end local currentFuel = Entity(vehicle).state.fuel diff --git a/modules/fuel/ps-fuel/client.lua b/modules/fuel/ps-fuel/client.lua index 87ad695..310f484 100644 --- a/modules/fuel/ps-fuel/client.lua +++ b/modules/fuel/ps-fuel/client.lua @@ -1,14 +1,27 @@ local resourceName = "ps-fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading ps-fuel") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +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. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports["ps-fuel"]:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports["ps-fuel"]:SetFuel(vehicle, fuel) diff --git a/modules/fuel/qs-fuelstations/client.lua b/modules/fuel/qs-fuelstations/client.lua index 40007f8..9a4f5d7 100644 --- a/modules/fuel/qs-fuelstations/client.lua +++ b/modules/fuel/qs-fuelstations/client.lua @@ -1,15 +1,28 @@ local resourceName = "qs-fuelstations" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading qs-fuelstations") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +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. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['qs-fuelstations']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return exports['qs-fuelstations']:SetFuel(vehicle, fuel) -end +end \ No newline at end of file diff --git a/modules/fuel/renewed-Fuel/client.lua b/modules/fuel/renewed-Fuel/client.lua index 52cf8ac..ca6e225 100644 --- a/modules/fuel/renewed-Fuel/client.lua +++ b/modules/fuel/renewed-Fuel/client.lua @@ -1,14 +1,27 @@ local resourceName = "Renewed-Fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading Renewed-Fuel") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +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. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['Renewed-Fuel']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports['Renewed-Fuel']:SetFuel(vehicle, fuel) diff --git a/modules/fuel/ti_fuel/client.lua b/modules/fuel/ti_fuel/client.lua index 08779a8..253081c 100644 --- a/modules/fuel/ti_fuel/client.lua +++ b/modules/fuel/ti_fuel/client.lua @@ -1,15 +1,28 @@ local resourceName = "ti_fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading ti_fuel") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +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. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end local level, _ = exports["ti_fuel"]:getFuel(vehicle) return level end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return exports['ti_fuel']:setFuel(vehicle, fuel, "RON91") diff --git a/modules/fuel/x-fuel/client.lua b/modules/fuel/x-fuel/client.lua index 0af0b38..6eeaba5 100644 --- a/modules/fuel/x-fuel/client.lua +++ b/modules/fuel/x-fuel/client.lua @@ -1,15 +1,28 @@ local resourceName = "x-fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading x-fuel") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +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. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end local level, _ = exports["x-fuel"]:getFuel(vehicle) return level end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return exports['x-fuel']:SetFuel(vehicle, fuel) From ad80c94833d49ad2c3cbb922c689252ac4d4abdc Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Sat, 19 Apr 2025 14:37:10 -0400 Subject: [PATCH 22/22] notes --- modules/doorlock/doors_creator/client.lua | 2 ++ modules/doorlock/ox_doorlock/server.lua | 4 ++++ modules/doorlock/qb-doorlock/client.lua | 2 ++ modules/doorlock/qb-doorlock/server.lua | 4 ++++ modules/doorlock/rcore_doorlock/client.lua | 2 ++ modules/doorlock/rcore_doorlock/server.lua | 4 ++++ 6 files changed, 18 insertions(+) diff --git a/modules/doorlock/doors_creator/client.lua b/modules/doorlock/doors_creator/client.lua index dbf6c86..88b9745 100644 --- a/modules/doorlock/doors_creator/client.lua +++ b/modules/doorlock/doors_creator/client.lua @@ -2,6 +2,8 @@ if GetResourceState('doors_creator') ~= 'started' then return end Doorlock = Doorlock or {} +---This will get the closest door to the ped +---@return string | nil Doorlock.GetClosestDoor = function() return exports["doors_creator"]:getClosestActiveDoor() end \ No newline at end of file diff --git a/modules/doorlock/ox_doorlock/server.lua b/modules/doorlock/ox_doorlock/server.lua index 1594980..a0324ba 100644 --- a/modules/doorlock/ox_doorlock/server.lua +++ b/modules/doorlock/ox_doorlock/server.lua @@ -2,6 +2,10 @@ if GetResourceState('ox_doorlock') ~= 'started' then return end Doorlock = Doorlock or {} +---This will toggle the lock status of the door. +---@param doorID string +---@param toggle boolean +---@return boolean Doorlock.ToggleDoorLock = function(doorID, toggle) local state = toggle if state then diff --git a/modules/doorlock/qb-doorlock/client.lua b/modules/doorlock/qb-doorlock/client.lua index ba8166e..11929e5 100644 --- a/modules/doorlock/qb-doorlock/client.lua +++ b/modules/doorlock/qb-doorlock/client.lua @@ -2,6 +2,8 @@ if GetResourceState('qb-doorlock') ~= 'started' then return end Doorlock = Doorlock or {} +---This will get the closest door to the ped +---@return string | nil Doorlock.GetClosestDoor = function() local closestDoor = exports["qb-doorlock"]:GetClosestDoor() if Table.CheckPopulated(closestDoor) then return closestDoor end diff --git a/modules/doorlock/qb-doorlock/server.lua b/modules/doorlock/qb-doorlock/server.lua index 3a48b0c..21648e3 100644 --- a/modules/doorlock/qb-doorlock/server.lua +++ b/modules/doorlock/qb-doorlock/server.lua @@ -2,6 +2,10 @@ if GetResourceState('qb-doorlock') ~= 'started' then return end Doorlock = Doorlock or {} +---This will toggle the lock status of the door. +---@param doorID string +---@param toggle boolean +---@return boolean Doorlock.ToggleDoorLock = function(doorID, toggle) TriggerClientEvent('qb-doorlock:client:setState', -1, 0, doorID, toggle, false, false, false) return true diff --git a/modules/doorlock/rcore_doorlock/client.lua b/modules/doorlock/rcore_doorlock/client.lua index 041307f..efb90be 100644 --- a/modules/doorlock/rcore_doorlock/client.lua +++ b/modules/doorlock/rcore_doorlock/client.lua @@ -2,6 +2,8 @@ if GetResourceState('rcore_doorlock') ~= 'started' then return end Doorlock = Doorlock or {} +---This will get the closest door to the ped +---@return string | nil Doorlock.GetClosestDoor = function() local allDoors = exports.rcore_doorlock:getLoadedDoors() local pedCoords = GetEntityCoords(cache.ped) diff --git a/modules/doorlock/rcore_doorlock/server.lua b/modules/doorlock/rcore_doorlock/server.lua index 1af685e..9535aab 100644 --- a/modules/doorlock/rcore_doorlock/server.lua +++ b/modules/doorlock/rcore_doorlock/server.lua @@ -2,6 +2,10 @@ if GetResourceState('rcore_doorlock') ~= 'started' then return end Doorlock = Doorlock or {} +---This will toggle the lock status of the door. +---@param doorID string +---@param toggle boolean +---@return boolean Doorlock.ToggleDoorLock = function(doorID, toggle) local state = toggle if state then