From 7a356598a62d3c89041a2d175721f8b494590021 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 Jun 2020 18:44:11 +0200 Subject: [PATCH] inventory close when item is used --- .../inventory/inventory.ts | 21 +++++++++++++++++-- .../Managers/InventoryManager.cs | 3 ++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ReallifeGamemode.Client/inventory/inventory.ts b/ReallifeGamemode.Client/inventory/inventory.ts index dd284b3a..5b47fcb2 100644 --- a/ReallifeGamemode.Client/inventory/inventory.ts +++ b/ReallifeGamemode.Client/inventory/inventory.ts @@ -35,6 +35,22 @@ var tradeItemName; var tradeItemWeight; + mp.events.add('openInventory', () => { + globalData.InInput = true; + mp.gui.cursor.show(true, true); + itemArr = []; + vehItemArr = []; + invBrowser = mp.browsers.new('package://assets/html/inventory/inventory.html'); + }); + mp.events.add('closeInventory', () => { + invBrowser.destroy() + invBrowser = null; + globalData.InInput = false; + loaded = false; + mp.gui.cursor.show(false, false); + return; + }); + mp.events.addDataHandler("tradeOffer", (entity, value) => { if (entity.type === "player") { offer = parseInt(value); @@ -82,7 +98,7 @@ }); mp.events.add("CEF:useItem", (type, amount, id) => { - mp.events.callRemote("itemInteract", type, amount, id); + mp.events.callRemote("itemInteract", type, amount, id); }); mp.events.add("removeItem", (id, amount) => { @@ -94,7 +110,8 @@ mp.events.add("aproveUse", (amount, name) => { if (invBrowser !== null) { mp.game.audio.playSoundFrontend(1, "LOCAL_PLYR_CASH_COUNTER_COMPLETE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS", true); - invBrowser.execute(`alertGreen('${JSON.stringify(amount)}','${JSON.stringify(name)}')`); + invBrowser.execute(`alertGreen('${JSON.stringify(amount)}','${JSON.stringify(name)}')`); + mp.events.call("closeInventory"); } }); diff --git a/ReallifeGamemode.Server/Managers/InventoryManager.cs b/ReallifeGamemode.Server/Managers/InventoryManager.cs index c088ea80..42171966 100644 --- a/ReallifeGamemode.Server/Managers/InventoryManager.cs +++ b/ReallifeGamemode.Server/Managers/InventoryManager.cs @@ -15,6 +15,7 @@ using ReallifeGamemode.Server.Util; using ReallifeGamemode.Services; using ReallifeGamemode.Server.Types; + /** * @overview Life of German Reallife - Managers InventoryManager (InventoryManager.cs) * @author hydrant, VegaZ @@ -33,7 +34,7 @@ namespace ReallifeGamemode.Server.Managers public static Dictionary> backpackItems { get; set; } = new Dictionary>(); public static Dictionary> vehicleItems { get; set; } = new Dictionary>(); - + private static Timer aTimer; public class InventoryItem { public string Name;