From 17d68505a69d7892461d67d04af6f6972f303fa9 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Sun, 16 Feb 2025 07:14:27 -0500 Subject: [PATCH] UpdatePlate added for all bridged inventories --- modules/inventory/jpr-inventory/server.lua | 12 ++++++++++++ modules/inventory/origen_inventory/server.lua | 12 ++++++++++++ modules/inventory/ps-inventory/server.lua | 12 ++++++++++++ modules/inventory/qs-inventory/server.lua | 12 ++++++++++++ modules/inventory/tgiann-inventory/server.lua | 12 ++++++++++++ 5 files changed, 60 insertions(+) diff --git a/modules/inventory/jpr-inventory/server.lua b/modules/inventory/jpr-inventory/server.lua index 41225eb..ff40531 100644 --- a/modules/inventory/jpr-inventory/server.lua +++ b/modules/inventory/jpr-inventory/server.lua @@ -22,4 +22,16 @@ Inventory.GetItemBySlot = function(src, slot) local slotData = jpr:GetItemBySlot(src, slot) if not slotData then return {} end return { name = slotData.name, label = slotData.label, weight = slotData.weight, slot = slot, count = slotData.amount, metadata = slotData.info, stack = slotData.unique, description = slotData.description } +end + +Inventory.UpdatePlate = function(oldplate, newplate) + local queries = { + 'UPDATE gloveboxitems SET plate = @newplate WHERE plate = @oldplate', + 'UPDATE trunkitems SET plate = @newplate WHERE plate = @oldplate', + } + local values = { newplate = newplate, oldplate = oldplate } + MySQL.transaction.await(queries, values) + if GetResourceState('jg-mechanic') ~= 'started' then return true end + exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) + return true end \ No newline at end of file diff --git a/modules/inventory/origen_inventory/server.lua b/modules/inventory/origen_inventory/server.lua index a281302..4b35b94 100644 --- a/modules/inventory/origen_inventory/server.lua +++ b/modules/inventory/origen_inventory/server.lua @@ -98,4 +98,16 @@ Inventory.GetImagePath = function(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" +end + +Inventory.UpdatePlate = function(oldplate, newplate) + local queries = { + 'UPDATE gloveboxitems SET plate = @newplate WHERE plate = @oldplate', + 'UPDATE trunkitems SET plate = @newplate WHERE plate = @oldplate', + } + local values = { newplate = newplate, oldplate = oldplate } + MySQL.transaction.await(queries, values) + if GetResourceState('jg-mechanic') ~= 'started' then return true end + exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) + return true end \ No newline at end of file diff --git a/modules/inventory/ps-inventory/server.lua b/modules/inventory/ps-inventory/server.lua index a747948..d3d2184 100644 --- a/modules/inventory/ps-inventory/server.lua +++ b/modules/inventory/ps-inventory/server.lua @@ -35,3 +35,15 @@ Inventory.RemoveItem = function(src, item, amount, slot, metadata) TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = amount, slot = slot, metadata = metadata}) return exports['ps-inventory']:RemoveItem(src, item, amount, slot, 'community_bridge') end + +Inventory.UpdatePlate = function(oldplate, newplate) + local queries = { + 'UPDATE gloveboxitems SET plate = @newplate WHERE plate = @oldplate', + 'UPDATE trunkitems SET plate = @newplate WHERE plate = @oldplate', + } + local values = { newplate = newplate, oldplate = oldplate } + MySQL.transaction.await(queries, values) + if GetResourceState('jg-mechanic') ~= 'started' then return true end + exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) + return true +end \ No newline at end of file diff --git a/modules/inventory/qs-inventory/server.lua b/modules/inventory/qs-inventory/server.lua index d8aecb9..f42b0a1 100644 --- a/modules/inventory/qs-inventory/server.lua +++ b/modules/inventory/qs-inventory/server.lua @@ -87,4 +87,16 @@ Inventory.GetImagePath = function(item) local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end + +Inventory.UpdatePlate = function(oldplate, newplate) + local queries = { + 'UPDATE inventory_trunk SET plate = @newplate WHERE plate = @oldplate', + 'UPDATE inventory_glovebox SET plate = @newplate WHERE plate = @oldplate', + } + local values = { newplate = newplate, oldplate = oldplate } + MySQL.transaction.await(queries, values) + if GetResourceState('jg-mechanic') ~= 'started' then return true end + exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) + return true end \ No newline at end of file diff --git a/modules/inventory/tgiann-inventory/server.lua b/modules/inventory/tgiann-inventory/server.lua index 8a0a914..48e1bd6 100644 --- a/modules/inventory/tgiann-inventory/server.lua +++ b/modules/inventory/tgiann-inventory/server.lua @@ -75,4 +75,16 @@ Inventory.GetImagePath = function(item) local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item)) local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end + +Inventory.UpdatePlate = function(oldplate, newplate) + local queries = { + 'UPDATE tgiann_inventory_trunkitems SET plate = @newplate WHERE plate = @oldplate', + 'UPDATE tgiann_inventory_gloveboxitems SET plate = @newplate WHERE plate = @oldplate', + } + local values = { newplate = newplate, oldplate = oldplate } + MySQL.transaction.await(queries, values) + if GetResourceState('jg-mechanic') ~= 'started' then return true end + exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) + return true end \ No newline at end of file