Added Custom Names for tuning parts
This commit is contained in:
@@ -30,6 +30,18 @@ var carModSlotName = [
|
|||||||
{ Slot: 23, Name: "Reifen"} // 23
|
{ Slot: 23, Name: "Reifen"} // 23
|
||||||
];
|
];
|
||||||
|
|
||||||
|
var customPartNames = [
|
||||||
|
{
|
||||||
|
Model: 1093792632,
|
||||||
|
Names: [
|
||||||
|
{
|
||||||
|
Slot: 8,
|
||||||
|
Name: "Lüftungsschlitze"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
var bikeModTypes = [];
|
var bikeModTypes = [];
|
||||||
|
|
||||||
const NativeUI = require("nativeui");
|
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.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um dein Fahrzeug zu modifizieren');
|
||||||
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
||||||
|
|
||||||
|
mp.gui.chat.push("Model: " + mp.players.local.vehicle.model);
|
||||||
|
|
||||||
mp.keys.bind(0x45, false, keyPressHandler);
|
mp.keys.bind(0x45, false, keyPressHandler);
|
||||||
keyBound = true;
|
keyBound = true;
|
||||||
});
|
});
|
||||||
@@ -80,7 +94,10 @@ mp.events.add("showTuningMenu", () => {
|
|||||||
if (localVehicle.getModSlotName(modType) !== "undefined") {
|
if (localVehicle.getModSlotName(modType) !== "undefined") {
|
||||||
var slotName = mp.game.ui.getLabelText(localVehicle.getModSlotName(modType));
|
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);
|
var menuItem = new UIMenuItem(slotName);
|
||||||
|
|
||||||
@@ -144,10 +161,43 @@ function getSlotId(slotName) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (toReturn === "undefined") {
|
if (toReturn === "undefined") {
|
||||||
|
|
||||||
|
toReturn = getCustomId(mp.players.local.vehicle.model, slotName);
|
||||||
|
|
||||||
|
if (toReturn === undefined) {
|
||||||
carModTypes.forEach((modType) => {
|
carModTypes.forEach((modType) => {
|
||||||
if (mp.game.ui.getLabelText(mp.players.local.vehicle.getModSlotName(modType)) === slotName) toReturn = getSlotId(getSlotName(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;
|
return toReturn;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user