From ad9d78a7e766ccb450c729090402ad8fbaae063d Mon Sep 17 00:00:00 2001 From: Lennart Kampshoff Date: Sun, 28 Oct 2018 00:29:40 +0200 Subject: [PATCH] Added error fix, when player leaves tuning menu and trys to tune vehicle --- Client/Tuning/main.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Client/Tuning/main.js b/Client/Tuning/main.js index 329b50f3..1517ebae 100644 --- a/Client/Tuning/main.js +++ b/Client/Tuning/main.js @@ -83,6 +83,8 @@ const ItemsCollection = NativeUI.ItemsCollection; const Color = NativeUI.Color; const ListItem = NativeUI.ListItem; +var mainMenu; + mp.events.add('showTuningInfo', () => { mp.game.ui.setTextComponentFormat('STRING'); mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um dein Fahrzeug zu modifizieren'); @@ -96,6 +98,10 @@ mp.events.add('hideTuningInfo', (unbind) => { mp.game.ui.clearHelp(true); mp.gui.chat.show(true); + if (typeof mainMenu !== "undefined" && unbind) { + mainMenu.Visible = false; + } + if (keyBound && unbind) { mp.keys.unbind(0x45, false, keyPressHandler); keyBound = false; @@ -113,7 +119,7 @@ mp.events.add("showTuningMenu", () => { var localPlayer = mp.players.local; var localVehicle = localPlayer.vehicle; - var mainMenu = new Menu("Fahrzeugwerkstatt", "Modifiziere dein Fahrzeug", new Point(50, 50)); + mainMenu = new Menu("Fahrzeugwerkstatt", "Modifiziere dein Fahrzeug", new Point(50, 50)); carModTypes.forEach((modType) => { if (localVehicle.getModSlotName(modType) !== "undefined") { @@ -168,6 +174,10 @@ mp.events.add("showTuningMenu", () => { }); +mp.events.add("playerLeaveVehicle", () => { + mp.events.call("hideTuningInfo", true); +}); + function getSlotName(slot) { var toReturn = "undefined";