Merge branch 'develop' of ssh://development.life-of-german.org:451/log-gtav/reallife-gamemode into develop

This commit is contained in:
VegaZ
2018-12-16 00:17:02 +01:00
12 changed files with 432 additions and 203 deletions

View File

@@ -87,9 +87,5 @@ mp.events.add('disableLogin', () => {
});
function showCefError(error) {
loginBrowser.execute(`showError(\`` + error + `\`)`);
loginBrowser.execute(`showError('${error}')`);
}
//function isPlayerBanned() {
//}

View File

@@ -6,7 +6,9 @@
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, 46, 48];
var disableInput = [75, 278, 279, 280, 281, 23, 59, 60, 71, 72, 74];
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" },
@@ -35,6 +37,7 @@ var carModSlotName = [
{ Slot: 34, Name: "Schalthebel" },
{ Slot: 35, Name: "Schild" },
{ Slot: 38, Name: "Hydraulik" },
{ Slot: 46, Name: "Fenster" },
{ Slot: 48, Name: "Design" }
];
@@ -45,6 +48,10 @@ var customPartNames = [
{
Slot: 8,
Name: "Lüftungsschlitze"
},
{
Slot: 43,
Name: "Motorhaubenstifte"
}
]
},
@@ -114,6 +121,10 @@ mp.events.add('hideTuningInfo', (unbind) => {
mp.game.ui.clearHelp(true);
mp.gui.chat.show(true);
if (mp.players.local.vehicle) {
mp.players.local.vehicle.setLights(0);
}
if (typeof mainMenu !== "undefined" && unbind) {
mainMenu.Close();
globalData.InTuning = false;
@@ -135,6 +146,14 @@ function keyPressHandler() {
mp.events.callRemote("startPlayerTuning");
}
mp.events.add("render", () => {
if (globalData.InTuning) {
disableInput.forEach((input) => {
mp.game.controls.disableControlAction(1, input, true);
});
}
});
mp.events.add("showTuningMenu", () => {
mp.events.call("hideTuningInfo" , false);
mp.gui.chat.show(false);
@@ -142,6 +161,8 @@ mp.events.add("showTuningMenu", () => {
var localPlayer = mp.players.local;
var localVehicle = localPlayer.vehicle;
localVehicle.setLights(1);
if (typeof mainMenu !== "undefined" && mainMenu.Visible) {
return;
}
@@ -193,8 +214,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);
}
});
@@ -206,6 +228,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);
@@ -218,14 +241,25 @@ mp.events.add("showTuningMenu", () => {
var currentMod = localVehicle.getMod(modSlot);
var oldToggleValue;
if (modSlot === 18 || modSlot === 22) {
if (modSlot === 18) {
oldToggleValue = localVehicle.isToggleModOn(modSlot);
currentMod = oldToggleValue ? 0 : -1;
}
if (modSlot === 22) {
localVehicle.setLights(2);
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));
@@ -237,16 +271,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);
@@ -262,8 +292,13 @@ mp.events.add("showTuningMenu", () => {
}
mp.events.callRemote("setVehicleMod", modSlot, index);
if (modSlot === 18 || modSlot === 22) {
oldToggleValue = index === 0 ? false : true;
if (modSlot === 18) {
oldToggleValue = index;
return;
}
if (modSlot === 22) {
currentMod = index;
return;
}
@@ -272,8 +307,9 @@ mp.events.add("showTuningMenu", () => {
});
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;
@@ -297,9 +333,10 @@ mp.events.add("showTuningMenu", () => {
mainMenu.Visible = true;
modMenu.Visible = false;
if (modSlot === 18 || modSlot === 22) {
oldToggleValue = (oldToggleValue === false) ? 0 : 1;
localVehicle.toggleMod(modSlot, oldToggleValue === 0 ? false : true);
if (modSlot === 18) return;
else if (modSlot === 22) {
localVehicle.setLights(1);
setHeadlightsColor(localVehicle, currentMod);
return;
}
localVehicle.setMod(modSlot, currentMod);
@@ -310,6 +347,7 @@ mp.events.add("showTuningMenu", () => {
});
mainMenu.MenuClose.on(() => {
localVehicle.setLights(0);
globalData.InTuning = false;
mp.events.call("hideTuningInfo", false);
});
@@ -452,8 +490,73 @@ function getModName(vehicle, slot, mod) {
case 3:
realModName = "Rennfederung";
break;
case 4:
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);
}
}

View File

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

View 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);
});

View File

@@ -13,6 +13,8 @@ mp.game.gameplay.enableMpDlcMaps(true);
require('./CharCreator/index.js');
require('./coloredhlights');
require('./FactionManagement/main.js');
require('./DoorManager/doormanager.js');

View File

@@ -2,7 +2,7 @@
//You don't need to worry about anything here
mp.events.add("VehStream_SetEngineStatus", (veh, status) => {
if (veh === undefined || veh === null) return;
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
if (veh !== undefined) {
if (veh.isSeatFree(-1)) //Turns engine on instantly if no driver, otherwise it will not turn on
{
@@ -17,7 +17,7 @@ mp.events.add("VehStream_SetEngineStatus", (veh, status) => {
});
mp.events.add("VehStream_SetLockStatus", (veh, status) => {
if (veh === undefined || veh === null) return;
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
if (veh !== undefined) {
if (status)
veh.setDoorsLocked(2);
@@ -27,7 +27,7 @@ mp.events.add("VehStream_SetLockStatus", (veh, status) => {
});
mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
if (entity === undefined || entity === null) return;
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') {
var toggle = entity.getVariable("VehicleSyncData");
entity.setEngineOn(toggle.Engine, false, true);
@@ -36,7 +36,7 @@ mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
});
mp.events.add("VehStream_PlayerExitVehicleAttempt", (entity) => {
if (entity === undefined || entity === null) return;
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
if (entity !== undefined) {
if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') {
var toggle = entity.getVariable("VehicleSyncData");
@@ -50,177 +50,181 @@ mp.events.add("VehStream_PlayerExitVehicleAttempt", (entity) => {
});
mp.events.add("VehStream_PlayerExitVehicle", (entity) => {
if (entity === undefined || entity === null) return;
setTimeout(() => {
var Status = [];
let y = 0;
for (y = 0; y < 8; y++) {
if (entity.isDoorDamaged(y)) {
try {
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
setTimeout(() => {
var Status = [];
let y = 0;
for (y = 0; y < 8; y++) {
if (entity.isDoorDamaged(y)) {
Status.push(2);
}
else if (entity.getDoorAngleRatio(y) > 0.15) {
Status.push(1);
}
else {
Status.push(0);
}
}
mp.events.callRemote("VehStream_SetDoorData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7]);
Status = [];
if (entity.isWindowIntact(0)) {
if (entity.getBoneIndexByName("window_rf") === -1) {
Status.push(1);
}
else {
Status.push(0);
}
}
else {
Status.push(2);
}
else if (entity.getDoorAngleRatio(y) > 0.15) {
if (entity.isWindowIntact(1)) {
if (entity.getBoneIndexByName("window_lf") === -1) {
Status.push(1);
}
else {
Status.push(0);
}
}
else {
Status.push(2);
}
if (entity.isWindowIntact(2)) {
if (entity.getBoneIndexByName("window_rr") === -1) {
Status.push(1);
}
else {
Status.push(0);
}
}
else {
Status.push(2);
}
if (entity.isWindowIntact(3)) {
if (entity.getBoneIndexByName("window_lr") === -1) {
Status.push(1);
}
else {
Status.push(0);
}
}
else {
Status.push(2);
}
mp.events.callRemote("VehStream_SetWindowData", entity, Status[0], Status[1], Status[2], Status[3]);
Status = [];
if (!entity.isTyreBurst(0, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(0, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(1, false)) {
Status.push(0);
}
}
mp.events.callRemote("VehStream_SetDoorData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7]);
Status = [];
if (entity.isWindowIntact(0)) {
if (entity.getBoneIndexByName("window_rf") === -1) {
else if (entity.isTyreBurst(1, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(2, false)) {
Status.push(0);
}
}
else {
Status.push(2);
}
if (entity.isWindowIntact(1)) {
if (entity.getBoneIndexByName("window_lf") === -1) {
else if (entity.isTyreBurst(2, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(3, false)) {
Status.push(0);
}
}
else {
Status.push(2);
}
if (entity.isWindowIntact(2)) {
if (entity.getBoneIndexByName("window_rr") === -1) {
else if (entity.isTyreBurst(3, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(4, false)) {
Status.push(0);
}
}
else {
Status.push(2);
}
if (entity.isWindowIntact(3)) {
if (entity.getBoneIndexByName("window_lr") === -1) {
else if (entity.isTyreBurst(4, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(5, false)) {
Status.push(0);
}
}
else {
Status.push(2);
}
mp.events.callRemote("VehStream_SetWindowData", entity, Status[0], Status[1], Status[2], Status[3]);
else if (entity.isTyreBurst(5, false)) {
Status.push(1);
}
else {
Status.push(2);
}
Status = [];
if (!entity.isTyreBurst(0, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(0, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(6, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(6, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(1, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(1, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(7, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(7, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(2, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(2, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(45, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(45, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(3, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(3, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(47, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(47, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(4, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(4, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(5, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(5, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(6, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(6, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(7, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(7, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(45, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(45, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(47, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(47, false)) {
Status.push(1);
}
else {
Status.push(2);
}
mp.events.callRemote("VehStream_SetWheelData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7], Status[8], Status[9]);
}, 2500);
mp.events.callRemote("VehStream_SetWheelData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7], Status[8], Status[9]);
}, 2500);
} catch (e) {
console.log("error: " + e);
}
});
mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
if (entity === undefined || entity === null) return;
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
setTimeout(() => {
var Status = [];
let y = 0;
@@ -287,14 +291,14 @@ mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
});
mp.events.add("VehStream_SetVehicleDirtLevel", (entity, dirt) => {
if (entity === undefined || entity === null) return;
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
if (entity !== undefined) {
entity.setDirtLevel(dirt);
}
});
mp.events.add("VehStream_SetVehicleDoorStatus_Single", (veh, door, state) => {
if (veh === undefined || veh === null) return;
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
if (veh !== undefined) {
if (state === 0) {
veh.setDoorShut(door, false);
@@ -309,7 +313,7 @@ mp.events.add("VehStream_SetVehicleDoorStatus_Single", (veh, door, state) => {
});
mp.events.add("VehStream_SetVehicleDoorStatus", (...args) => {
if (args[0] !== undefined && args[0] !== null) {
if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) {
let y = 0;
for (y = 1; y < args.length; y++) {
if (args[y] === 0) {
@@ -326,7 +330,7 @@ mp.events.add("VehStream_SetVehicleDoorStatus", (...args) => {
});
mp.events.add("VehStream_SetVehicleWindowStatus_Single", (veh, windw, state) => {
if (veh === undefined || veh === null) return;
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
if (veh !== undefined) {
if (state === 1) {
veh.rollDownWindow(windw);
@@ -342,7 +346,7 @@ mp.events.add("VehStream_SetVehicleWindowStatus_Single", (veh, windw, state) =>
});
mp.events.add("VehStream_SetVehicleWindowStatus", (...args) => {
if (args[0] !== undefined && args[0] !== null) {
if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) {
let y = 0;
for (y = 1; y < 4; y++) {
if (args[y] === 1) {
@@ -360,7 +364,7 @@ mp.events.add("VehStream_SetVehicleWindowStatus", (...args) => {
});
mp.events.add("VehStream_SetVehicleWheelStatus_Single", (veh, wheel, state) => {
if (veh === undefined || veh === null) return;
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
if (veh !== undefined) {
if (wheel === 9) {
if (state === 1) {
@@ -399,7 +403,7 @@ mp.events.add("VehStream_SetVehicleWheelStatus_Single", (veh, wheel, state) => {
});
mp.events.add("VehStream_SetVehicleWheelStatus", (...args) => {
if (args[0] !== undefined && args[0] !== null) {
if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) {
let y = 0;
for (y = 1; y < args.length; y++) {
if (y === 9) {
@@ -441,6 +445,7 @@ mp.events.add("VehStream_SetVehicleWheelStatus", (...args) => {
//Sync data on stream in
mp.events.add("entityStreamIn", (entity) => {
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
if (entity.type === "vehicle") {
let typeor = typeof entity.getVariable('VehicleSyncData');
let actualData = entity.getVariable('VehicleSyncData');
@@ -539,4 +544,4 @@ mp.events.add("entityStreamIn", (entity) => {
}
}, 1500);
}
});
});