From 1bb125ed31c9b0be011a9595b2d3686f3456e288 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Fri, 6 Jun 2025 00:38:51 +0100 Subject: [PATCH] Add `clearStash()` function --- shared/stashcontrol.lua | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/shared/stashcontrol.lua b/shared/stashcontrol.lua index b94cd1e..a7f2edd 100644 --- a/shared/stashcontrol.lua +++ b/shared/stashcontrol.lua @@ -222,6 +222,60 @@ RegisterNetEvent(getScript()..":server:openServerStash", function(data) end end) +function clearStash(stashId) + if isStarted(QBInv) then + debugPrint("^5Bridge^7: ^2Cleared ^3"..QBInv.."^2 Stash^7", stashId) + if QBInvNew then + exports[QBInv]:ClearStash(stashId) + else + MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', { + ['stash'] = stashId, + ['items'] = json.encode({}) + }) + end + + elseif isStarted(OXInv) then + debugPrint("^5Bridge^7: ^2Cleared ^3"..OXInv.."^2 Stash^7", stashId) + exports[OXInv]:ClearInventory(stashId) + + elseif isStarted(PSInv) then + debugPrint("^5Bridge^7: ^2Cleared ^3"..PSInv.."^2 Stash^7", stashId) + if QBInvNew then + exports[QBInv]:ClearStash(stashId) + else + MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', { + ['stash'] = stashId, + ['items'] = json.encode({}) + }) + end + + elseif isStarted(QSInv) then + debugPrint("^5Bridge^7: ^2Cleared ^3"..QSInv.."^2 Stash^7", stashId) + exports[QSInv]:ClearOtherInventory('stash', stashId) + + elseif isStarted(CoreInv) then + debugPrint("^5Bridge^7: ^2Cleared ^3"..CoreInv.."^2 Stash^7", stashId) + exports[CoreInv]:clearInventory("stash-"..stashId) + + elseif isStarted(CodeMInv) then + debugPrint("^5Bridge^7: ^2Cleared ^3"..CodeMInv.."^2 Stash^7", stashId) + exports[CodeMInv]:ClearInventory(stashId) + + elseif isStarted(OrigenInv) then + debugPrint("^5Bridge^7: ^2Cleared ^3"..OrigenInv.."^2 Stash^7", stashId) + exports[OrigenInv]:ClearInventory(stashId) + + elseif isStarted(TgiannInv) then + debugPrint("^5Bridge^7: ^2Cleared ^3"..TgiannInv.."^2 Stash^7", stashId) + exports["tgiann-inventory"]:DeleteInventory("stash", stashId) + + elseif isStarted(RSGInv) then + debugPrint("^5Bridge^7: ^2Cleared ^3"..RSGInv.."^2 Stash^7", stashId) + exports[RSGInv]:ClearStash(stashId) + + end +end + ------------------------------------------------------------- -- Stash Retrieval Function