From 512ca96774cab5483fdb9359fb9921f08a8eaf78 Mon Sep 17 00:00:00 2001 From: hydrant Date: Tue, 11 Dec 2018 18:49:49 +0100 Subject: [PATCH 1/8] Removed double tuning garages --- Main.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Main.cs b/Main.cs index 3f03b549..cc2b1ea7 100644 --- a/Main.cs +++ b/Main.cs @@ -37,9 +37,6 @@ namespace reallife_gamemode InventoryManager.LoadItems(); - TuningManager.AddTuningGarage(new Vector3(-341, -134, 38.5)); - TuningManager.AddTuningGarage(new Vector3(732, -1088, 21)); - TuningManager.AddTuningGarage(new Vector3(-1155, -2006, 12)); TuningManager.AddTuningGarage(new Vector3(-341, -134, 38.5)); // Downtown LS TuningManager.AddTuningGarage(new Vector3(732, -1088, 21)); // LS Intersection TuningManager.AddTuningGarage(new Vector3(-1155, -2006, 12)); // LS Airport From 3fc109ff8b0f04829744f034963c244bad90b3b3 Mon Sep 17 00:00:00 2001 From: hydrant Date: Fri, 14 Dec 2018 18:08:01 +0100 Subject: [PATCH 2/8] Fixed tuning issue, added new dlc cars to car list, added command to open tuning menu --- Client/Login/main.js | 6 +--- Client/Tuning/main.js | 12 +++++--- Server/Commands/Admin.cs | 15 +++++++++- Server/Managers/VehicleManager.cs | 48 ++++++++++++++++++++++++++++++- 4 files changed, 70 insertions(+), 11 deletions(-) diff --git a/Client/Login/main.js b/Client/Login/main.js index 1ddf9076..b69b8db2 100644 --- a/Client/Login/main.js +++ b/Client/Login/main.js @@ -87,9 +87,5 @@ mp.events.add('disableLogin', () => { }); function showCefError(error) { - loginBrowser.execute(`showError(\`` + error + `\`)`); + loginBrowser.execute(`showError('${error}')`); } - -//function isPlayerBanned() { - -//} \ No newline at end of file diff --git a/Client/Tuning/main.js b/Client/Tuning/main.js index 30355d12..600af6d2 100644 --- a/Client/Tuning/main.js +++ b/Client/Tuning/main.js @@ -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, 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]; var carModSlotName = [ { Slot: 0, Name: "Spoiler" }, @@ -35,6 +35,7 @@ var carModSlotName = [ { Slot: 34, Name: "Schalthebel" }, { Slot: 35, Name: "Schild" }, { Slot: 38, Name: "Hydraulik" }, + { Slot: 46, Name: "Fenster" }, { Slot: 48, Name: "Design" } ]; @@ -220,6 +221,7 @@ mp.events.add("showTuningMenu", () => { var oldToggleValue; if (modSlot === 18 || modSlot === 22) { oldToggleValue = localVehicle.isToggleModOn(modSlot); + mp.gui.chat.push("oldToggleValue = " + oldToggleValue.toString()); currentMod = oldToggleValue ? 0 : -1; } var currentModItem; @@ -263,7 +265,7 @@ mp.events.add("showTuningMenu", () => { mp.events.callRemote("setVehicleMod", modSlot, index); if (modSlot === 18 || modSlot === 22) { - oldToggleValue = index === 0 ? false : true; + oldToggleValue = index; return; } @@ -298,8 +300,7 @@ mp.events.add("showTuningMenu", () => { modMenu.Visible = false; if (modSlot === 18 || modSlot === 22) { - oldToggleValue = (oldToggleValue === false) ? 0 : 1; - localVehicle.toggleMod(modSlot, oldToggleValue === 0 ? false : true); + localVehicle.toggleMod(modSlot, !!oldToggleValue); return; } localVehicle.setMod(modSlot, currentMod); @@ -452,6 +453,9 @@ function getModName(vehicle, slot, mod) { case 3: realModName = "Rennfederung"; break; + case 4: + realModName = "Wettkampffederung"; + break; } } diff --git a/Server/Commands/Admin.cs b/Server/Commands/Admin.cs index 1fdf724d..e821f2da 100644 --- a/Server/Commands/Admin.cs +++ b/Server/Commands/Admin.cs @@ -878,7 +878,8 @@ namespace reallife_gamemode.Server.Commands return; } - uint uHash = NAPI.Util.GetHashKey(hash); + if(!uint.TryParse(hash, out uint uHash)) + uHash = NAPI.Util.GetHashKey(hash); if(!VehicleManager.IsValidHash(uHash)) { @@ -2028,6 +2029,18 @@ namespace reallife_gamemode.Server.Commands BankManager.SetMoney(player, business, amount, "Admin"); } + [Command("showtuningmenu", "~m~Benutzung: ~s~/showtuningmenu")] + public void CmdAdminShowtuningmenu(Client player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + player.TriggerEvent("showTuningMenu"); + } + #endregion #region ALevel1338 diff --git a/Server/Managers/VehicleManager.cs b/Server/Managers/VehicleManager.cs index 6359dbd3..43028d8b 100644 --- a/Server/Managers/VehicleManager.cs +++ b/Server/Managers/VehicleManager.cs @@ -11,7 +11,53 @@ namespace reallife_gamemode.Server.Managers { private static readonly List _enabledMods = new List() { - "polamggtr" + "polamggtr", + "impaler3", + "monster4", + "monster5", + "slamvan6", + "issi6", + "cerberus2", + "cerberus3", + "deathbike2", + "dominator6", + "deathbike3", + "impaler4", + "slamvan4", + "slamvan5", + "brutus", + "brutus2", + "brutus3", + "deathbike", + "dominator4", + "dominator5", + "bruiser", + "bruiser2", + "bruiser3", + "rcbandito", + "italigto", + "cerberus", + "impaler2", + "monster3", + "tulip", + "scarab", + "scarab2", + "scarab3", + "issi4", + "issi5", + "clique", + "deveste", + "vamos", + "imperator", + "imperator2", + "imperator3", + "toros", + "deviant", + "schlagen", + "impaler", + "zr380", + "zr3802", + "zr3803" }; private static Dictionary _serverVehicles = new Dictionary(); From e927eee2275b858c557e1a8ecd24e7e3d3d98e36 Mon Sep 17 00:00:00 2001 From: hydrant Date: Fri, 14 Dec 2018 18:19:21 +0100 Subject: [PATCH 3/8] Fixed new issue with vehicle sync --- Client/vehiclesync/vehiclesync.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Client/vehiclesync/vehiclesync.js b/Client/vehiclesync/vehiclesync.js index 96500cea..a2edf974 100644 --- a/Client/vehiclesync/vehiclesync.js +++ b/Client/vehiclesync/vehiclesync.js @@ -441,6 +441,7 @@ mp.events.add("VehStream_SetVehicleWheelStatus", (...args) => { //Sync data on stream in mp.events.add("entityStreamIn", (entity) => { + if (entity === undefined) return; if (entity.type === "vehicle") { let typeor = typeof entity.getVariable('VehicleSyncData'); let actualData = entity.getVariable('VehicleSyncData'); @@ -539,4 +540,4 @@ mp.events.add("entityStreamIn", (entity) => { } }, 1500); } -}); \ No newline at end of file +}); From a05f93296a7ef1958949f4f90ea588f1216bbd2f Mon Sep 17 00:00:00 2001 From: hydrant Date: Fri, 14 Dec 2018 18:19:38 +0100 Subject: [PATCH 4/8] Ordered players by admin rank in /team --- Server/Commands/Admin.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Server/Commands/Admin.cs b/Server/Commands/Admin.cs index e821f2da..6d894db2 100644 --- a/Server/Commands/Admin.cs +++ b/Server/Commands/Admin.cs @@ -126,13 +126,10 @@ namespace reallife_gamemode.Server.Commands player.SendChatMessage("Online Teammitglieder:"); - List playerlist = NAPI.Pools.GetAllPlayers(); + List playerlist = NAPI.Pools.GetAllPlayers().FindAll(c => c.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? false).OrderByDescending(c => c.GetUser().AdminLevel).ToList(); foreach (Client currentPlayer in playerlist) { - if (currentPlayer.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? false) - { - player.SendChatMessage(currentPlayer.Name); - } + player.SendChatMessage(currentPlayer.GetUser().AdminLevel.GetName() + " | " + currentPlayer.Name); } } From c2483f102fd7df0623fb5578f25a564bf42ac3e6 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 15 Dec 2018 11:13:19 +0100 Subject: [PATCH 5/8] Added ID parameter to /vdestroy --- Server/Commands/Admin.cs | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/Server/Commands/Admin.cs b/Server/Commands/Admin.cs index 6d894db2..f8c5ddb2 100644 --- a/Server/Commands/Admin.cs +++ b/Server/Commands/Admin.cs @@ -907,8 +907,8 @@ namespace reallife_gamemode.Server.Commands player.Vehicle.Repair(); } - [Command("vdestroy")] - public void CmdAdminVdestroy(Client player) + [Command("vdestroy", "~m~Benutzung: ~s~/vdestroy (ID)")] + public void CmdAdminVdestroy(Client player, int vid = -1) { if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? true) { @@ -916,22 +916,35 @@ namespace reallife_gamemode.Server.Commands return; } - if (!player.IsInVehicle) + Vehicle targetVeh; + + if (vid == -1) { - player.SendChatMessage("~r~[FEHLER]~s~ Du sitzt momentan nicht in einem Fahrzeug."); - return; + if (!player.IsInVehicle) + { + player.SendChatMessage("~m~Benutzung: ~s~/vdestroy (ID)"); + return; + } + targetVeh = player.Vehicle; + } + else + { + targetVeh = VehicleManager.GetVehicleFromId(vid); + if(targetVeh == null) + { + player.SendChatMessage("~r~[FEHLER]~s~ Dieses Fahrzeug existiert nicht."); + return; + } } - Vehicle playerVeh = player.Vehicle; - - ServerVehicle veh = VehicleManager.GetServerVehicleFromVehicle(playerVeh); + ServerVehicle veh = VehicleManager.GetServerVehicleFromVehicle(targetVeh); if(veh != null) { player.SendChatMessage("~r~[FEHLER]~s~ Dieses Fahrzeug wird von einem Server-System benutzt: ~m~" + veh.GetType().Name); return; } - VehicleManager.DeleteVehicle(playerVeh); + VehicleManager.DeleteVehicle(targetVeh); } [Command("vlivery", "~m~Benutzung: ~s~/vlivery [Livery]")] From 7a5f82006860e42bef666bf556e90b46a1e2c6e9 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 15 Dec 2018 11:13:34 +0100 Subject: [PATCH 6/8] Fixing issues from vehiclesync --- Client/vehiclesync/vehiclesync.js | 300 +++++++++++++++--------------- reallife-gamemode.csproj | 2 + 2 files changed, 154 insertions(+), 148 deletions(-) diff --git a/Client/vehiclesync/vehiclesync.js b/Client/vehiclesync/vehiclesync.js index a2edf974..facee9ee 100644 --- a/Client/vehiclesync/vehiclesync.js +++ b/Client/vehiclesync/vehiclesync.js @@ -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,7 +445,7 @@ mp.events.add("VehStream_SetVehicleWheelStatus", (...args) => { //Sync data on stream in mp.events.add("entityStreamIn", (entity) => { - if (entity === undefined) return; + if (entity === undefined || entity === null || !entity.isAVehicle()) return; if (entity.type === "vehicle") { let typeor = typeof entity.getVariable('VehicleSyncData'); let actualData = entity.getVariable('VehicleSyncData'); diff --git a/reallife-gamemode.csproj b/reallife-gamemode.csproj index 4d431f2e..344664f3 100644 --- a/reallife-gamemode.csproj +++ b/reallife-gamemode.csproj @@ -5,6 +5,7 @@ true true true + AnyCPU;x64 @@ -31,6 +32,7 @@ + From 2818fd351342cd51af6732e68b3285224a79a3ab Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 15 Dec 2018 14:00:01 +0100 Subject: [PATCH 7/8] Added tuning support for colored lights --- Client/Tuning/main.js | 112 ++++++++++++++++++++++++++----- Client/Tuning/sync.js | 5 -- Client/coloredhlights/index.js | 19 ++++++ Client/index.js | 2 + Server/Managers/TuningManager.cs | 27 ++++++-- 5 files changed, 139 insertions(+), 26 deletions(-) create mode 100644 Client/coloredhlights/index.js diff --git a/Client/Tuning/main.js b/Client/Tuning/main.js index 600af6d2..14530ee3 100644 --- a/Client/Tuning/main.js +++ b/Client/Tuning/main.js @@ -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); + } } \ No newline at end of file diff --git a/Client/Tuning/sync.js b/Client/Tuning/sync.js index bee8e5a0..bda0fead 100644 --- a/Client/Tuning/sync.js +++ b/Client/Tuning/sync.js @@ -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); - } } }); diff --git a/Client/coloredhlights/index.js b/Client/coloredhlights/index.js new file mode 100644 index 00000000..8dcd352a --- /dev/null +++ b/Client/coloredhlights/index.js @@ -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); +}); \ No newline at end of file diff --git a/Client/index.js b/Client/index.js index 9d437a43..8fd9f6c1 100644 --- a/Client/index.js +++ b/Client/index.js @@ -13,6 +13,8 @@ mp.game.gameplay.enableMpDlcMaps(true); require('./CharCreator/index.js'); +require('./coloredhlights'); + require('./FactionManagement/main.js'); require('./DoorManager/doormanager.js'); diff --git a/Server/Managers/TuningManager.cs b/Server/Managers/TuningManager.cs index 7e0a7089..dd76271b 100644 --- a/Server/Managers/TuningManager.cs +++ b/Server/Managers/TuningManager.cs @@ -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) { - pV.SetMod(slot, index - 1); + 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); } From dd671df43abb69c5b50acd4a88f76950d5d9ded1 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 15 Dec 2018 16:21:02 +0100 Subject: [PATCH 8/8] Improved tuning, reimplemented /time (use /time -1 to resume time manager) --- Client/Tuning/main.js | 19 +++++++++++++++++++ Server/Commands/Admin.cs | 16 +++++++++++++++- Server/Managers/TimeManager.cs | 16 +++++++++++++--- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/Client/Tuning/main.js b/Client/Tuning/main.js index 14530ee3..21cc5530 100644 --- a/Client/Tuning/main.js +++ b/Client/Tuning/main.js @@ -6,6 +6,8 @@ var keyBound = false; +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 = [ @@ -119,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; @@ -140,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); @@ -147,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; } @@ -231,6 +247,7 @@ mp.events.add("showTuningMenu", () => { } if (modSlot === 22) { + localVehicle.setLights(2); var hlColor = localVehicle.getVariable("headlightColor"); if (typeof hlColor !== "number" || isNaN(hlColor) || hlColor < 0 || hlColor === 255) { currentMod = -1; @@ -318,6 +335,7 @@ mp.events.add("showTuningMenu", () => { if (modSlot === 18) return; else if (modSlot === 22) { + localVehicle.setLights(1); setHeadlightsColor(localVehicle, currentMod); return; } @@ -329,6 +347,7 @@ mp.events.add("showTuningMenu", () => { }); mainMenu.MenuClose.on(() => { + localVehicle.setLights(0); globalData.InTuning = false; mp.events.call("hideTuningInfo", false); }); diff --git a/Server/Commands/Admin.cs b/Server/Commands/Admin.cs index f8c5ddb2..a17fac1a 100644 --- a/Server/Commands/Admin.cs +++ b/Server/Commands/Admin.cs @@ -1302,7 +1302,7 @@ namespace reallife_gamemode.Server.Commands } [Command("time", "~m~Benutzung: ~s~/time [Stunde] (Minuten) (Sekunden)")] - public void CmdAdminSetTime(Client player, int hour, int min = 0, int sec = 0) + public void CmdAdminTime(Client player, int hour, int min = 0, int sec = 0) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -1310,8 +1310,22 @@ namespace reallife_gamemode.Server.Commands return; } + if(hour > 23 || min > 59 || sec > 59) + { + player.SendChatMessage("~r~[FEHLER]~s~ Es wurde eine ungültige Zeit eingegeben."); + return; + } + + if(hour == -1) + { + player.SendChatMessage("Es wird nun wieder die Echtzeit genutzt."); + TimeManager.StartTimeManager(); + return; + } + string broadcastMsg = $"Serverzeit wurde auf {hour:D2}:{min:D2}:{sec:D2} gesetzt!"; NAPI.Notification.SendNotificationToAll(broadcastMsg); + TimeManager.PauseTimeManager(); NAPI.World.SetTime(hour, min, sec); return; diff --git a/Server/Managers/TimeManager.cs b/Server/Managers/TimeManager.cs index 43f2a843..9020c2f5 100644 --- a/Server/Managers/TimeManager.cs +++ b/Server/Managers/TimeManager.cs @@ -8,12 +8,22 @@ namespace reallife_gamemode.Server.Managers { public class TimeManager { + private static Timer realTimeTimer; + public static void StartTimeManager() { - Timer t = new Timer(1000); - t.Elapsed += SetTime; + if(realTimeTimer == null) + { + realTimeTimer = new Timer(1000); + realTimeTimer.Elapsed += SetTime; + } - t.Start(); + realTimeTimer.Start(); + } + + public static void PauseTimeManager() + { + realTimeTimer.Stop(); } private static void SetTime(object sender, ElapsedEventArgs args)