Added error fix, when player leaves tuning menu and trys to tune vehicle

This commit is contained in:
Lennart Kampshoff
2018-10-28 00:29:40 +02:00
parent bbbee72399
commit ad9d78a7e7

View File

@@ -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";