TUNING
This commit is contained in:
@@ -23,9 +23,7 @@ export default function playerBlips() {
|
||||
mp.gui.chat.push(parseInt(entity.blip) == 0 ? "Blip was not created" : "Blip was created");
|
||||
|
||||
mp.gui.chat.push("entity.blip is actually " + entity.blip);
|
||||
var blip = mp.blips.at(entity.blip);
|
||||
|
||||
blip.dimension = entityMp.dimension;
|
||||
var blip = entity.blip;
|
||||
|
||||
mp.gui.chat.push("1 -" + blip.getAlpha() + " 2- " + blip.doesExist() + " 3-" + blip.dimension + " 4-" + entityMp.dimension);
|
||||
|
||||
@@ -34,7 +32,7 @@ export default function playerBlips() {
|
||||
mp.game.invoke(Natives.SET_BLIP_CATEGORY, entity.blip, 7);
|
||||
mp.game.invoke(Natives.SHOW_HEADING_INDICATOR_ON_BLIP, entity.blip, true);
|
||||
mp.game.invoke(Natives.SET_BLIP_AS_SHORT_RANGE, entity.blip, true);
|
||||
//mp.game.invoke(Natives.SET_BLIP_DISPLAY, entity.blip, 8);
|
||||
mp.game.invoke(Natives.SET_BLIP_DISPLAY, entity.blip, 8);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -12,6 +12,7 @@ const Point = NativeUI.Point;
|
||||
const Color = NativeUI.Color;
|
||||
let screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
||||
import vehicleColors from './colors';
|
||||
import moneyformat from '../moneyformat';
|
||||
|
||||
export default function tuning(globalData: IGlobalData) {
|
||||
var keyBound = false;
|
||||
@@ -53,6 +54,10 @@ export default function tuning(globalData: IGlobalData) {
|
||||
{ Slot: 38, Name: "Hydraulik", Price: 2000 },
|
||||
{ Slot: 39, Name: "Motorabdeckung", Price: 2000 },
|
||||
{ Slot: 40, Name: "Luftfilter", Price: 2000 },
|
||||
{ Slot: 41, Name: "Domstrebe", Price: 2000 },
|
||||
{ Slot: 42, Name: "Scheinwerferabdeckung", Price: 2000 },
|
||||
{ Slot: 43, Name: "Nebelscheinwerfer", Price: 2000 },
|
||||
{ Slot: 44, Name: "Dach-Extra", Price: 2000 },
|
||||
{ Slot: 46, Name: "Fenster", Price: 2000 },
|
||||
{ Slot: 48, Name: "Design", Price: 2000 }
|
||||
];
|
||||
@@ -156,6 +161,10 @@ export default function tuning(globalData: IGlobalData) {
|
||||
}
|
||||
});
|
||||
|
||||
var currentMod = new Array<number>();
|
||||
var currentActiveModItem = new Array<NativeUI.UIMenuItem>();
|
||||
var currentSelectedItem: VehicleModMenuItem = null;
|
||||
|
||||
mp.events.add("showTuningMenu", () => {
|
||||
mp.events.call("hideTuningInfo", false);
|
||||
mp.gui.chat.show(false);
|
||||
@@ -178,12 +187,8 @@ export default function tuning(globalData: IGlobalData) {
|
||||
repairItem.BackColor = new Color(94, 94, 94);
|
||||
repairItem.HighlightedBackColor = new Color(105, 105, 105);
|
||||
|
||||
var currentMod = new Array<number>();
|
||||
var currentActiveModItem = new Array<NativeUI.UIMenuItem>();
|
||||
|
||||
carModTypes.forEach((modType) => {
|
||||
|
||||
var mod = null;
|
||||
var mod: number = null;
|
||||
|
||||
if (modType === 22) { // Lichter
|
||||
var hlColor = localVehicle.getVariable("headlightColor");
|
||||
@@ -221,6 +226,10 @@ export default function tuning(globalData: IGlobalData) {
|
||||
}
|
||||
}
|
||||
|
||||
mp.gui.chat.push("getting price for modtype = " + modType.toString() + ", modtypename = " + modName);
|
||||
var price = getModSlotPrice(modType);
|
||||
|
||||
|
||||
if (mod === null) {
|
||||
mod = localVehicle.getMod(modType);
|
||||
}
|
||||
@@ -247,7 +256,8 @@ export default function tuning(globalData: IGlobalData) {
|
||||
modText = mp.game.ui.getLabelText(localVehicle.getModTextLabel(modType, x));
|
||||
if (modText === "NULL") modText = getModName(localVehicle, modType, x);
|
||||
}
|
||||
var item = new UIMenuItem(modText);
|
||||
var item = new VehicleModMenuItem(modText);
|
||||
item.price = price;
|
||||
modMenu.AddItem(item);
|
||||
|
||||
if (x === mod) {
|
||||
@@ -255,6 +265,9 @@ export default function tuning(globalData: IGlobalData) {
|
||||
currentActiveModItem[modType] = item;
|
||||
modMenu.CurrentSelection = x;
|
||||
}
|
||||
else {
|
||||
item.SetRightLabel("$"+ moneyformat(price));
|
||||
}
|
||||
}
|
||||
|
||||
modMenu.IndexChange.on((index: number) => {
|
||||
@@ -272,13 +285,13 @@ export default function tuning(globalData: IGlobalData) {
|
||||
}
|
||||
});
|
||||
|
||||
modMenu.ItemSelect.on((item: NativeUI.UIMenuItem, index: number) => {
|
||||
currentMod[modType] = index - 1;
|
||||
currentActiveModItem[modType].SetRightBadge(BadgeStyle.None);
|
||||
item.SetRightBadge(BadgeStyle.Car);
|
||||
currentActiveModItem[modType] = item;
|
||||
modMenu.ItemSelect.on((item: VehicleModMenuItem, index: number) => {
|
||||
if (currentMod[modType] == index - 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
mp.events.callRemote("setVehicleMod", modType, index);
|
||||
currentSelectedItem = item;
|
||||
mp.events.callRemote("setVehicleMod", modType, index, price);
|
||||
});
|
||||
|
||||
modMenu.MenuClose.on(() => {
|
||||
@@ -311,6 +324,13 @@ export default function tuning(globalData: IGlobalData) {
|
||||
|
||||
});
|
||||
|
||||
mp.events.add("SERVER:Tuning_ModSucessfull", (modType: number, index: number) => {
|
||||
currentMod[modType] = index - 1;
|
||||
currentActiveModItem[modType].SetRightLabel("$" + moneyformat(currentSelectedItem.price));
|
||||
currentSelectedItem.SetRightBadge(BadgeStyle.Car);
|
||||
currentActiveModItem[modType] = currentSelectedItem;
|
||||
});
|
||||
|
||||
mp.events.add("playerLeaveVehicle", () => {
|
||||
if (keyBound) {
|
||||
mp.events.call("hideTuningInfo", true);
|
||||
@@ -435,6 +455,10 @@ export default function tuning(globalData: IGlobalData) {
|
||||
return realModName;
|
||||
}
|
||||
|
||||
function getModSlotPrice(modType: number): number {
|
||||
return carModSlotName.filter(x => x.Slot == modType)[0].Price;
|
||||
}
|
||||
|
||||
function setHeadlightsColor(vehicle, index) {
|
||||
|
||||
if (!vehicle) {
|
||||
@@ -552,4 +576,8 @@ export default function tuning(globalData: IGlobalData) {
|
||||
|
||||
mp.events.callRemote("CLIENT:TuningManager_SetVehicleColor", false, color);
|
||||
}
|
||||
|
||||
class VehicleModMenuItem extends UIMenuItem {
|
||||
public price: number;
|
||||
}
|
||||
}
|
||||
@@ -92,8 +92,22 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
|
||||
[RemoteEvent("setVehicleMod")]
|
||||
public void SetVehicleMod(Player player, int slot, int index)
|
||||
public void SetVehicleMod(Player player, int slot, int index, int price)
|
||||
{
|
||||
using var dbContext = new DatabaseContext();
|
||||
User user = player.GetUser(dbContext);
|
||||
if (user.BankAccount.Balance < price)
|
||||
{
|
||||
player.SendNotification("Du hast nicht genug Geld für dieses Tuningteil!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
user.BankAccount.Balance -= price;
|
||||
}
|
||||
|
||||
player.TriggerEvent("SERVER:Tuning_ModSucessfull", slot, index);
|
||||
|
||||
Vehicle pV = player.Vehicle;
|
||||
if (index == 0) index--;
|
||||
|
||||
@@ -118,11 +132,11 @@ namespace ReallifeGamemode.Server.Managers
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("vehicleToggleMod", pV, slot, newVal);
|
||||
}
|
||||
|
||||
ServerVehicle sV = player.Vehicle.GetServerVehicle();
|
||||
dbContext.SaveChanges();
|
||||
|
||||
ServerVehicle sV = player.Vehicle.GetServerVehicle(dbContext);
|
||||
if (sV == null) return;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
VehicleMod vMod = dbContext.VehicleMods.FirstOrDefault(m => m.ServerVehicleId == sV.Id && m.Slot == slot);
|
||||
if (vMod == null && index != -1)
|
||||
{
|
||||
@@ -153,7 +167,6 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:TuningManager_SetVehicleColor")]
|
||||
public void TuningManagerSetVehicleColor(Player player, bool primarySecondary, int color)
|
||||
|
||||
Reference in New Issue
Block a user