Added Custom Names for tuning parts

This commit is contained in:
hydrant
2018-10-24 21:08:04 +02:00
parent 5d581ed66d
commit 3a4b210f87

View File

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