[BUG-93][BUG-49] Tuning Preise angepasst und Fehler behoben

This commit is contained in:
hydrant
2021-04-29 15:10:06 +02:00
parent 5387465945
commit 07c6da7031
2 changed files with 88 additions and 18 deletions

View File

@@ -26,7 +26,7 @@ export default function tuning(globalData: IGlobalData) {
const carModSlotName = [
{ Slot: 0, Name: "Spoiler", Price: 1000 },
{ Slot: 1, Name: "Frontstoßstange", Price: 1500},
{ Slot: 1, Name: "Frontstoßstange", Price: 1500 },
{ Slot: 2, Name: "Heckstoßstange", Price: 1500 },
{ Slot: 3, Name: "Seitenschweller", Price: 1500 },
{ Slot: 4, Name: "Auspuff", Price: 500 },
@@ -36,12 +36,12 @@ export default function tuning(globalData: IGlobalData) {
{ Slot: 8, Name: "Extra 1", Price: 2000 },
{ Slot: 9, Name: "Extra 2", Price: 2000 },
{ Slot: 10, Name: "Dach", Price: 1500 },
{ Slot: 11, Name: "Motor", Price: 50000 },
{ Slot: 12, Name: "Bremsen", Price: 30000 },
{ Slot: 13, Name: "Getriebe", Price: 15000 },
{ Slot: 11, Name: "Motor", BasePercentage: 20, PriceIncreasePerLevel: 7.5 },
{ Slot: 12, Name: "Bremsen", BasePercentage: 5, PriceIncreasePerLevel: 2.5 },
{ Slot: 13, Name: "Getriebe", BasePercentage: 10, PriceIncreasePerLevel: 2.5 },
{ Slot: 14, Name: "Hupe", Price: 500 },
{ Slot: 15, Name: "Federung", Price: 2000 },
{ Slot: 18, Name: "Turbo", Price: 40000 },
{ Slot: 18, Name: "Turbo", BasePercentage: 45, PriceIncreasePerLevel: 0 },
{ Slot: 22, Name: "Licht", Price: 500 },
{ Slot: 23, Name: "Reifen", Price: 1000 },
{ Slot: -1, Name: "Lackierung", Price: 1000 },
@@ -165,7 +165,7 @@ export default function tuning(globalData: IGlobalData) {
var currentActiveModItem = new Array<NativeUI.UIMenuItem>();
var currentSelectedItem: VehicleModMenuItem = null;
mp.events.add("showTuningMenu", (noMoney) => {
mp.events.add("showTuningMenu", (noMoney, basePrice) => {
mp.events.call("hideTuningInfo", false);
mp.gui.chat.show(false);
@@ -226,9 +226,6 @@ export default function tuning(globalData: IGlobalData) {
}
}
var price = noMoney? 0 : getModSlotPrice(modType);
if (mod === null) {
mod = localVehicle.getMod(modType);
}
@@ -248,6 +245,7 @@ export default function tuning(globalData: IGlobalData) {
currentMod[modType] = mod;
for (var x = -1; x < modNum; x++) {
var price = noMoney ? 0 : getModSlotPrice(modType, basePrice, x);
var modText = "";
if (x === -1) {
modText = "Serie";
@@ -265,7 +263,7 @@ export default function tuning(globalData: IGlobalData) {
modMenu.CurrentSelection = x;
}
else {
item.SetRightLabel("$"+ moneyformat(price));
item.SetRightLabel("$" + moneyformat(price));
}
}
@@ -304,7 +302,7 @@ export default function tuning(globalData: IGlobalData) {
});
});
mainMenu.ItemSelect.on((item: NativeUI.UIMenuItem, index: number) => {
if (item === repairItem) {
@@ -315,7 +313,9 @@ export default function tuning(globalData: IGlobalData) {
mainMenu.Visible = true;
mainMenu.MenuClose.on(() => {
localVehicle.setLights(0);
if (localVehicle && mp.vehicles.exists(localVehicle)) {
localVehicle.setLights(0);
}
globalData.InTuning = false;
globalData.InMenu = false;
mp.events.call("hideTuningInfo", false);
@@ -456,8 +456,21 @@ export default function tuning(globalData: IGlobalData) {
return realModName;
}
function getModSlotPrice(modType: number): number {
return carModSlotName.filter(x => x.Slot == modType)[0].Price;
function getModSlotPrice(modType: number, basePrice: number, modIndex?: number): number {
if (modIndex === -1) {
return 0;
}
let price = 0;
let priceInfo = carModSlotName.filter(x => x.Slot == modType)[0];
if (priceInfo.BasePercentage) {
price = ((priceInfo.BasePercentage + priceInfo.PriceIncreasePerLevel * modIndex) / 100) * basePrice;
} else {
price = priceInfo.Price;
}
return price;
}
function setHeadlightsColor(vehicle, index) {