diff --git a/modules/inventory/core_inventory/client.lua b/modules/inventory/core_inventory/client.lua new file mode 100644 index 0000000..206e39e --- /dev/null +++ b/modules/inventory/core_inventory/client.lua @@ -0,0 +1,13 @@ +if GetResourceState('core_inventory') ~= 'started' then return end + +Inventory = Inventory or {} + +local core = exports.core_inventory + +Inventory = Inventory or {} + +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 \ No newline at end of file diff --git a/modules/inventory/core_inventory/server.lua b/modules/inventory/core_inventory/server.lua new file mode 100644 index 0000000..6ff7faa --- /dev/null +++ b/modules/inventory/core_inventory/server.lua @@ -0,0 +1,30 @@ +if GetResourceState('core_inventory') ~= 'started' then return end + +Inventory = Inventory or {} + +local core = exports.core_inventory + +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.UpdatePlate = function(oldplate, newplate) + -- have no clue if this will work but fingers crossed + local queries = { + 'UPDATE coreinventories SET name = @newplate WHERE name = @oldplate', + 'UPDATE coreinventories SET name = @newplate WHERE name = @glovebox_oldplate', + 'UPDATE coreinventories SET name = @newplate WHERE name = @trunk_oldplate', + } + local values = { + newplate = newplate, + oldplate = oldplate, + glovebox_oldplate = 'glovebox-' .. oldplate, + trunk_oldplate = 'trunk-' .. 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