From 97ee8f694e0afbf11e0f764e00453071307b91f3 Mon Sep 17 00:00:00 2001 From: hydrant Date: Wed, 24 Oct 2018 21:08:04 +0200 Subject: [PATCH] Added Custom Names for tuning parts --- Client/Tuning/main.js | 58 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/Client/Tuning/main.js b/Client/Tuning/main.js index 40e33c94..d73c9532 100644 --- a/Client/Tuning/main.js +++ b/Client/Tuning/main.js @@ -30,6 +30,18 @@ var carModSlotName = [ { Slot: 23, Name: "Reifen"} // 23 ]; +var customPartNames = [ + { + Model: 1093792632, + Names: [ + { + Slot: 8, + Name: "Lüftungsschlitze" + } + ] + } +]; + var bikeModTypes = []; const NativeUI = require("nativeui"); @@ -49,6 +61,8 @@ mp.events.add('showTuningInfo', () => { mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um dein Fahrzeug zu modifizieren'); mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1); + mp.gui.chat.push("Model: " + mp.players.local.vehicle.model); + mp.keys.bind(0x45, false, keyPressHandler); keyBound = true; }); @@ -80,7 +94,10 @@ mp.events.add("showTuningMenu", () => { if (localVehicle.getModSlotName(modType) !== "undefined") { var slotName = mp.game.ui.getLabelText(localVehicle.getModSlotName(modType)); - if(slotName === "NULL") slotName = getSlotName(modType); + if (slotName === "NULL") { + slotName = getCustomName(localVehicle.model, modType); + if (slotName === undefined) slotName = getSlotName(modType); + } var menuItem = new UIMenuItem(slotName); @@ -144,10 +161,43 @@ function getSlotId(slotName) { }); if (toReturn === "undefined") { - carModTypes.forEach((modType) => { - if (mp.game.ui.getLabelText(mp.players.local.vehicle.getModSlotName(modType)) === slotName) toReturn = getSlotId(getSlotName(modType)); - }); + + toReturn = getCustomId(mp.players.local.vehicle.model, slotName); + + if (toReturn === undefined) { + carModTypes.forEach((modType) => { + if (mp.game.ui.getLabelText(mp.players.local.vehicle.getModSlotName(modType)) === slotName) toReturn = getSlotId(getSlotName(modType)); + }); + } } + return toReturn; +} + +function getCustomName(model, slot) { + var toReturn = undefined; + + customPartNames.forEach((cpn) => { + if (cpn.Model === model) { + cpn.Names.forEach((names) => { + if (names.Slot === slot) toReturn = names.Name; + }); + } + }); + + return toReturn; +} + +function getCustomId(model, name) { + var toReturn = undefined; + + customPartNames.forEach((cpn) => { + if (cpn.Model === model) { + cpn.Names.forEach((names) => { + if (names.Name === name) toReturn = names.Slot; + }); + } + }); + return toReturn; } \ No newline at end of file