Added tuning support for colored lights
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
var keyBound = false;
|
||||
|
||||
var carModTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 22, 25, 27, 28, 33, 34, 35, 38, 39, 40, 41, 42, 43, 44, 46, 48];
|
||||
var carModTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 22, 25, 27, 28, 33, 34, 35, 38, 39, 40, 41, 42, 43, 44, 46, 48, 69];
|
||||
|
||||
var carModSlotName = [
|
||||
{ Slot: 0, Name: "Spoiler" },
|
||||
@@ -46,6 +46,10 @@ var customPartNames = [
|
||||
{
|
||||
Slot: 8,
|
||||
Name: "Lüftungsschlitze"
|
||||
},
|
||||
{
|
||||
Slot: 43,
|
||||
Name: "Motorhaubenstifte"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -194,8 +198,9 @@ mp.events.add("showTuningMenu", () => {
|
||||
if (slotName === "undefined") slotName = "Slot " + modType;
|
||||
|
||||
var menuItem = new UIMenuItem(slotName);
|
||||
|
||||
if(localVehicle.getNumMods(modType) !== 0 || modType === 18 || modType === 22) mainMenu.AddItem(menuItem);
|
||||
var num = localVehicle.getNumMods(modType);
|
||||
if (num === undefined && modType !== 18 && modType !== 22) return;
|
||||
if (num !== 0 || modType === 18 || modType === 22) mainMenu.AddItem(menuItem);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -207,6 +212,7 @@ mp.events.add("showTuningMenu", () => {
|
||||
restStr = item.Text.substring(5);
|
||||
modSlot = parseInt(restStr);
|
||||
}
|
||||
if (modSlot === undefined) return;
|
||||
|
||||
if (modSlot === 38) {
|
||||
localVehicle.setDoorOpen(5, false, false);
|
||||
@@ -219,15 +225,24 @@ mp.events.add("showTuningMenu", () => {
|
||||
|
||||
var currentMod = localVehicle.getMod(modSlot);
|
||||
var oldToggleValue;
|
||||
if (modSlot === 18 || modSlot === 22) {
|
||||
if (modSlot === 18) {
|
||||
oldToggleValue = localVehicle.isToggleModOn(modSlot);
|
||||
mp.gui.chat.push("oldToggleValue = " + oldToggleValue.toString());
|
||||
currentMod = oldToggleValue ? 0 : -1;
|
||||
}
|
||||
|
||||
if (modSlot === 22) {
|
||||
var hlColor = localVehicle.getVariable("headlightColor");
|
||||
if (typeof hlColor !== "number" || isNaN(hlColor) || hlColor < 0 || hlColor === 255) {
|
||||
currentMod = -1;
|
||||
} else if (hlColor === 13) currentMod = 0;
|
||||
else currentMod = hlColor + 2;
|
||||
}
|
||||
|
||||
var currentModItem;
|
||||
|
||||
var modNum = localVehicle.getNumMods(modSlot);
|
||||
if (modSlot === 18 || modSlot === 22) modNum = 1;
|
||||
if (modSlot === 18) modNum = 1;
|
||||
if (modSlot === 22) modNum = 14;
|
||||
|
||||
modMenu = new Menu(item.Text, "Änderung: " + item.Text, new Point(50, 50));
|
||||
|
||||
@@ -239,16 +254,12 @@ mp.events.add("showTuningMenu", () => {
|
||||
} else {
|
||||
var modName = getModName(localVehicle, modSlot, i);
|
||||
|
||||
if (modSlot === 18) modName = "Turbolader";
|
||||
if (modSlot === 22) modName = "Xenon-Licht";
|
||||
|
||||
modItem = new UIMenuItem(modName, "");
|
||||
}
|
||||
|
||||
if (i === currentMod) {
|
||||
if (i === currentMod - (modSlot === 22 ? 1 : 0)) {
|
||||
modItem.SetRightBadge(BadgeStyle.Car);
|
||||
currentModItem = modItem;
|
||||
modFound = true;
|
||||
}
|
||||
|
||||
modMenu.AddItem(modItem);
|
||||
@@ -264,18 +275,24 @@ mp.events.add("showTuningMenu", () => {
|
||||
}
|
||||
mp.events.callRemote("setVehicleMod", modSlot, index);
|
||||
|
||||
if (modSlot === 18 || modSlot === 22) {
|
||||
if (modSlot === 18) {
|
||||
oldToggleValue = index;
|
||||
return;
|
||||
}
|
||||
|
||||
if (modSlot === 22) {
|
||||
currentMod = index;
|
||||
return;
|
||||
}
|
||||
|
||||
if (index === 0) index = -1;
|
||||
currentMod = index - 1;
|
||||
});
|
||||
|
||||
modMenu.IndexChange.on((index) => {
|
||||
if (modSlot === 18 || modSlot === 22) {
|
||||
localVehicle.toggleMod(modSlot, index === 0 ? false : true);
|
||||
if (modSlot === 18) return;
|
||||
if (modSlot === 22) {
|
||||
setHeadlightsColor(localVehicle, index);
|
||||
return;
|
||||
}
|
||||
if (index === 0) index = -1;
|
||||
@@ -299,8 +316,9 @@ mp.events.add("showTuningMenu", () => {
|
||||
mainMenu.Visible = true;
|
||||
modMenu.Visible = false;
|
||||
|
||||
if (modSlot === 18 || modSlot === 22) {
|
||||
localVehicle.toggleMod(modSlot, !!oldToggleValue);
|
||||
if (modSlot === 18) return;
|
||||
else if (modSlot === 22) {
|
||||
setHeadlightsColor(localVehicle, currentMod);
|
||||
return;
|
||||
}
|
||||
localVehicle.setMod(modSlot, currentMod);
|
||||
@@ -457,7 +475,69 @@ function getModName(vehicle, slot, mod) {
|
||||
realModName = "Wettkampffederung";
|
||||
break;
|
||||
}
|
||||
} else if (slot === 18) {
|
||||
realModName = "Turbotuning";
|
||||
} else if (slot === 22) {
|
||||
switch (mod) {
|
||||
case 0:
|
||||
realModName = "Xenon Licht";
|
||||
break;
|
||||
case 1:
|
||||
realModName = "Weißes Licht";
|
||||
break;
|
||||
case 2:
|
||||
realModName = "Blaues Licht";
|
||||
break;
|
||||
case 3:
|
||||
realModName = "Hell-blaues Licht";
|
||||
break;
|
||||
case 4:
|
||||
realModName = "Grünes Licht";
|
||||
break;
|
||||
case 5:
|
||||
realModName = "Hell-grünes Licht";
|
||||
break;
|
||||
case 6:
|
||||
realModName = "Hell-gelbes Licht";
|
||||
break;
|
||||
case 7:
|
||||
realModName = "Gelbes Licht";
|
||||
break;
|
||||
case 8:
|
||||
realModName = "Orangenes Licht";
|
||||
break;
|
||||
case 9:
|
||||
realModName = "Rotes Licht";
|
||||
break;
|
||||
case 10:
|
||||
realModName = "Hell-pinkes Licht";
|
||||
break;
|
||||
case 11:
|
||||
realModName = "Pinkes Licht";
|
||||
break;
|
||||
case 12:
|
||||
realModName = "Lila Licht";
|
||||
break;
|
||||
case 13:
|
||||
realModName = "Hell-lila Licht";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return realModName;
|
||||
}
|
||||
|
||||
function setHeadlightsColor(vehicle, index) {
|
||||
var color = index - 2;
|
||||
if (index === 0) color = -1;
|
||||
if (index === 1) color = 13;
|
||||
if (typeof color !== "number" || isNaN(color) || color < 0 || color === 255) {
|
||||
// Disable
|
||||
vehicle.toggleMod(22, false);
|
||||
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, 255);
|
||||
} else {
|
||||
// Enable
|
||||
vehicle.toggleMod(22, true);
|
||||
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, color);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,10 @@
|
||||
mp.events.add('entityStreamIn', (entity) => {
|
||||
if (entity.isAVehicle()) {
|
||||
var mod18 = entity.getVariable('mod18');
|
||||
var mod22 = entity.getVariable('mod22');
|
||||
|
||||
if (mod18 !== undefined) {
|
||||
entity.toggleMod(18, mod18);
|
||||
}
|
||||
|
||||
if (mod22 !== undefined) {
|
||||
entity.toggleMod(22, mod22);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
19
Client/coloredhlights/index.js
Normal file
19
Client/coloredhlights/index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
function setHeadlightsColor(vehicle, color) {
|
||||
if (typeof color !== "number" || isNaN(color) || color < 0 || color === 255) {
|
||||
// Disable
|
||||
vehicle.toggleMod(22, false);
|
||||
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, 255);
|
||||
} else {
|
||||
// Enable
|
||||
vehicle.toggleMod(22, true);
|
||||
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, color);
|
||||
}
|
||||
}
|
||||
|
||||
mp.events.add("entityStreamIn", (entity) => {
|
||||
if (entity.type === "vehicle") setHeadlightsColor(entity, parseInt(entity.getVariable("headlightColor")));
|
||||
});
|
||||
|
||||
mp.events.addDataHandler("headlightColor", (entity, value) => {
|
||||
if (entity.type === "vehicle") setHeadlightsColor(entity, value);
|
||||
});
|
||||
@@ -13,6 +13,8 @@ mp.game.gameplay.enableMpDlcMaps(true);
|
||||
|
||||
require('./CharCreator/index.js');
|
||||
|
||||
require('./coloredhlights');
|
||||
|
||||
require('./FactionManagement/main.js');
|
||||
|
||||
require('./DoorManager/doormanager.js');
|
||||
|
||||
@@ -47,17 +47,23 @@ namespace reallife_gamemode.Server.Managers
|
||||
|
||||
|
||||
veh.SetSharedData("mod18", false);
|
||||
veh.SetSharedData("mod22", false);
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach(VehicleMod vMod in dbContext.VehicleMods.ToList().FindAll(vM => vM.ServerVehicleId == sVeh.Id))
|
||||
{
|
||||
if(vMod.Slot == 18 || vMod.Slot == 22)
|
||||
if(vMod.Slot == 18)
|
||||
{
|
||||
veh.SetSharedData("mod" + vMod.Slot, true);
|
||||
}
|
||||
veh.SetMod(vMod.Slot, vMod.ModId - 1);
|
||||
else if(vMod.Slot == 22)
|
||||
{
|
||||
int color = vMod.ModId - 2;
|
||||
if (vMod.ModId == 0) color = -1;
|
||||
if (vMod.ModId == 1) color = 13;
|
||||
veh.SetSharedData("headlightColor", color);
|
||||
}
|
||||
else veh.SetMod(vMod.Slot, vMod.ModId - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,13 +89,24 @@ namespace reallife_gamemode.Server.Managers
|
||||
Vehicle pV = player.Vehicle;
|
||||
if (index == 0) index--;
|
||||
|
||||
if(slot != 18 && slot != 22)
|
||||
if(slot != 18)
|
||||
{
|
||||
if(slot == 22)
|
||||
{
|
||||
int color = index - 2;
|
||||
if (index == 0) color = -1;
|
||||
if (index == 1) color = 13;
|
||||
pV.SetSharedData("headlightColor", color);
|
||||
}
|
||||
else
|
||||
{
|
||||
pV.SetMod(slot, index - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool newVal = index == -1 ? false : true;
|
||||
NAPI.Util.ConsoleOutput("Setting turbo to: " + newVal.ToString());
|
||||
pV.SetSharedData("mod" + slot, newVal);
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("vehicleToggleMod", pV, slot, newVal);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user