From 8479aea1b0202198ea51cece67eedef1645d45ad Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Mon, 22 Jan 2024 17:14:56 +0000 Subject: [PATCH] Origen inv experimental support --- crafting.lua | 19 +++++++++++++++++++ exports.lua | 3 ++- functions.lua | 23 ++++++++++++++++++++++- wrapper.lua | 3 +++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/crafting.lua b/crafting.lua index 85be5cd..5da23c9 100644 --- a/crafting.lua +++ b/crafting.lua @@ -240,6 +240,14 @@ function hasItem(items, amount, src) local amount = amount and amount or 1 else grabInv = exports[QSInv]:getUserInventory() end + elseif GetResourceState(OrigenInv):find("start") then + foundInv = OrigenInv + if src then + grabInv = exports[OrigenInv]:getPlayerInventory(src) + else + grabInv = exports[OrigenInv]:getPlayerInventory() + end + elseif GetResourceState(CoreInv):find("start") then foundInv = CoreInv if src then @@ -329,6 +337,10 @@ function getStash(stashName) if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..CodeMInv) end stashItems = exports[CodeMInv]:GetInventoryItems('Stash', stashName) + elseif GetResourceState(OrigenInv):find("start") then + if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..OrigenInv) end + stashItems = exports[OrigenInv]:GetStash(stashName) + elseif GetResourceState(QBInv):find("start") then if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..QBInv) end local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName }) @@ -410,6 +422,13 @@ function stashRemoveItem(stashItems, stashName, items) local amount = amount and if Config.System.Debug then print("^6Bridge^7: ^3saveStash^7: ^2Saving ^3QB^2 stash ^7'^6"..stashName.."^7'") end + + elseif GetResourceState(OrigenInv):find("start") then + for k, v in pairs(items) do + exports[OrigenInv]:RemoveItem(stashName, k, v) + if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OrigenInv, k, v) end + end + elseif GetResourceState(QBInv):find("start") then for k, v in pairs(items) do for l in pairs(stashItems) do diff --git a/exports.lua b/exports.lua index 1a92d42..bab1fa0 100644 --- a/exports.lua +++ b/exports.lua @@ -7,8 +7,9 @@ Exports = { OXInv = "ox_inventory", QBInv = "qb-inventory", QSInv = "qs-inventory", - CoreInv = "core-inventory", + CoreInv = "core_inventory", CodeMInv = "codem-inventory", + OrigenInv = "origen_inventory", OXLibExport = "ox_lib", diff --git a/functions.lua b/functions.lua index f9d6d82..d7700aa 100644 --- a/functions.lua +++ b/functions.lua @@ -586,11 +586,13 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, if Config.System.Debug then print("^6Bridge^7: ^3"..addremove.."^7[^6"..OXInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") end + elseif GetResourceState(QSInv):find("start") then local success = exports[QSInv]:RemoveItem(src, item, amount) if Config.System.Debug then print("^6Bridge^7: ^3"..addremove.."^7[^6"..QSInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") end + elseif GetResourceState(CoreInv):find("start") then if GetResourceState(QBExport):find("start") then Core.Functions.GetPlayer(src).Functions.RemoveItem(item, amount, nil) @@ -600,11 +602,19 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, if Config.System.Debug then print("^6Bridge^7: ^3"..addremove.."^7[^6"..CoreInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") end - elseif GetResourceState(CodeMInv):find("start") then + + elseif GetResourceState(OrigenInv):find("start") then + local success = exports[OrigenInv]:RemoveItem(src, item, amount) + if Config.System.Debug then + print("^6Bridge^7: ^3"..addremove.."^7[^6"..OrigenInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") + end + + elseif GetResourceState(CodeMInv):find("start") then local success = exports[CodeMInv]:RemoveItem(src, item, amount) if Config.System.Debug then print("^6Bridge^7: ^3"..addremove.."^7[^6"..CodeMInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") end + elseif GetResourceState(QBInv):find("start") then while remamount > 0 do if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1) then end @@ -629,11 +639,13 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, if Config.System.Debug then print("^6Bridge^7: ^3"..addremove.."^7[^6"..OXInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") end + elseif GetResourceState(QSInv):find("start") then local success = exports[QSInv]:AddItem(src, item, amount) if Config.System.Debug then print("^6Bridge^7: ^3"..addremove.."^7[^6"..QSInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") end + elseif GetResourceState(CoreInv):find("start") then if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then Core.Functions.GetPlayer(src).Functions.AddItem(item, amount, nil, nil) @@ -643,11 +655,19 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, if Config.System.Debug then print("^6Bridge^7: ^3"..addremove.."^7[^6"..CoreInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") end + elseif GetResourceState(CodeMInv):find("start") then local success = exports[CodeMInv]:AddItem(src, item, amount) if Config.System.Debug then print("^6Bridge^7: ^3"..addremove.."^7[^6"..CodeMInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") end + + elseif GetResourceState(OrigenInv):find("start") then + local success = exports[OrigenInv]:AddItem(src, item, amount) + if Config.System.Debug then + print("^6Bridge^7: ^3"..addremove.."^7[^6"..OrigenInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") + end + elseif GetResourceState(QBInv):find("start") then if Core.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then --if Config.Crafting.showItemBox then @@ -657,6 +677,7 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, if Config.System.Debug then print("^6Bridge^7: ^3"..addremove.."^7[^6"..QBInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") end + else print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7") end diff --git a/wrapper.lua b/wrapper.lua index a29aec3..02d367f 100644 --- a/wrapper.lua +++ b/wrapper.lua @@ -15,6 +15,7 @@ QBInv = Exports and Exports.QBInv or "" QSInv = Exports and Exports.QSInv or "" CoreInv = Exports and Exports.CoreInv or "" CodeMInv = Exports and Exports.CodeMInv or "" +OrigenInv = Exports and Exports.OrigenInv or "" QBMenuExport = Exports and Exports.QBMenuExport or "" @@ -1243,6 +1244,8 @@ function invImg(item) imgLink = "nui://"..QSInv.."/html/images/"..(Items[item].image or "") elseif GetResourceState(CoreInv and CoreInv or ""):find("start") then imgLink = "nui://"..CoreInv.."/html/img/"..(Items[item].image or "") + elseif GetResourceState(OrigenInv and OrigenInv or ""):find("start") then + imgLink = "nui://"..OrigenInv.."/html/img/"..(Items[item].image or "") elseif GetResourceState(QBInv and QBInv or ""):find("start") then imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "") else