From cef952487ee23d2dfc78b7382575d67df2bd9a98 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 1 Jul 2020 22:23:32 +0200 Subject: [PATCH] fix servercrash taxifahrer --- ReallifeGamemode.Client/Gui/taximeter.ts | 7 +++++++ ReallifeGamemode.Client/Jobs/main.ts | 1 + ReallifeGamemode.Server/Job/TaxiDriverJob.cs | 8 ++++++-- ReallifeGamemode.Server/Managers/JobManager.cs | 9 ++++++--- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ReallifeGamemode.Client/Gui/taximeter.ts b/ReallifeGamemode.Client/Gui/taximeter.ts index aca73950..4d8acc11 100644 --- a/ReallifeGamemode.Client/Gui/taximeter.ts +++ b/ReallifeGamemode.Client/Gui/taximeter.ts @@ -33,6 +33,13 @@ export default function taximeterInput(globalData: IGlobalData) { myVar = setInterval(myTimer, 100); }); + mp.events.add('CLIENT:stopFare', () => { + browser.destroy() + browser = null; + globalData.InInput = false; + return; + }); + function myTimer() { if (totalPrice == lastPrice) return; let payPrice = +totalPrice - +lastPrice; diff --git a/ReallifeGamemode.Client/Jobs/main.ts b/ReallifeGamemode.Client/Jobs/main.ts index 6f167125..67aa1dc3 100644 --- a/ReallifeGamemode.Client/Jobs/main.ts +++ b/ReallifeGamemode.Client/Jobs/main.ts @@ -51,6 +51,7 @@ export default function (globalData: IGlobalData) { mp.events.callRemote("CLIENT:Job_StartJob"); } else if (index === 1) { // Job stoppen mp.events.callRemote("CLIENT:Job_StopJob"); + mp.events.callRemote("CLIENT:stopFare"); } else { return; } diff --git a/ReallifeGamemode.Server/Job/TaxiDriverJob.cs b/ReallifeGamemode.Server/Job/TaxiDriverJob.cs index 463264a0..57adfdc0 100644 --- a/ReallifeGamemode.Server/Job/TaxiDriverJob.cs +++ b/ReallifeGamemode.Server/Job/TaxiDriverJob.cs @@ -47,7 +47,9 @@ namespace ReallifeGamemode.Server.Job private void TaxiDriverJobJobStop(Player player) { - // player.Vehicle.SetSharedData("vehicleTaxiLight", false); + if (!player.IsInVehicle) + return; + player.Vehicle.SetSharedData("vehicleTaxiLight", false); int Id = player.GetUser().Id; player.ResetData("DriverPrice"); Vehicle v = player.Vehicle; @@ -105,7 +107,8 @@ namespace ReallifeGamemode.Server.Job if (u.JobId != 1) return; if (!player.HasData("hasPassager")) { player.SetData("hasPassager", false); continue; } int playerId = player.GetUser().Id; - + if (player.IsInVehicle) + { Vehicle v = player.Vehicle; Vector3 lastPosition = v.Position; if (lastPositions.ContainsKey(v.Handle)) lastPosition = lastPositions[v.Handle]; @@ -118,6 +121,7 @@ namespace ReallifeGamemode.Server.Job { occupant.TriggerEvent("CLIENT:updateFare", JsonConvert.SerializeObject(distance)); } + } } } } diff --git a/ReallifeGamemode.Server/Managers/JobManager.cs b/ReallifeGamemode.Server/Managers/JobManager.cs index 51f8114b..5f8b46de 100644 --- a/ReallifeGamemode.Server/Managers/JobManager.cs +++ b/ReallifeGamemode.Server/Managers/JobManager.cs @@ -274,7 +274,9 @@ namespace ReallifeGamemode.Server.Managers { if (player.GetUser().JobId == 1)//Taxifahrer { - //VehicleManager.DeleteVehicle(v); + player.TriggerEvent("CLIENT:stopFare"); + player.Position = new Vector3(-628.598388671875, -2107.609130859375, 6.072586536407471); + player.Heading = (-171.50303649902344f); } if (player.GetUser().JobId == 2)//Müllmann { @@ -327,11 +329,12 @@ namespace ReallifeGamemode.Server.Managers } job.StopJob(player); - /*if (player.GetUser().JobId == 1)//Taxifahrer + if (player.GetUser().JobId == 1)//Taxifahrer { player.Position = new Vector3(-628.598388671875, -2107.609130859375, 6.072586536407471); player.Heading = (-171.50303649902344f); - }*/ + + } if (player.GetUser().JobId == 2)//Müllmann { player.Position = new Vector3(485.4114685058594, -2173.25, 5.918273448944092);