From d7e679a81caa4c524f9016224d839fb4426dba09 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 2 Aug 2020 21:13:34 +0200 Subject: [PATCH] evtl fix crash bei tot --- ReallifeGamemode.Server/Events/Death.cs | 13 +++++++++++-- ReallifeGamemode.Server/Wanted/Autowanted.cs | 12 ++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ReallifeGamemode.Server/Events/Death.cs b/ReallifeGamemode.Server/Events/Death.cs index 99632a7b..16567deb 100644 --- a/ReallifeGamemode.Server/Events/Death.cs +++ b/ReallifeGamemode.Server/Events/Death.cs @@ -27,7 +27,11 @@ namespace ReallifeGamemode.Server.Events [ServerEvent(Event.PlayerDeath)] public void OnPlayerDeath(Player player, Player killer, uint reason) { - if (!player.IsLoggedIn()) player.Kick(); + if (!player.IsLoggedIn()) + { + player.Kick(); + return; + } player.SetData("isDead", true); //TODO: Zum Full Release entfernen @@ -49,7 +53,12 @@ namespace ReallifeGamemode.Server.Events } else { - killerId = killer.GetUser().Id; + var killerUser = killer.GetUser(); + if (killerUser == null) + { + return; + } + killerId = killerUser.Id; killerPosX = killer.Position.X; killerPosY = killer.Position.Y; killerPosZ = killer.Position.Z; diff --git a/ReallifeGamemode.Server/Wanted/Autowanted.cs b/ReallifeGamemode.Server/Wanted/Autowanted.cs index bb708f31..6ca6db5a 100644 --- a/ReallifeGamemode.Server/Wanted/Autowanted.cs +++ b/ReallifeGamemode.Server/Wanted/Autowanted.cs @@ -9,11 +9,19 @@ namespace ReallifeGamemode.Server.Wanted { public static void Check_AutoWanted(Player killerPlayer, Player copPlayer) { - User killer = killerPlayer.GetUser(); + User killer = killerPlayer?.GetUser(); + if (killer == null) + { + return; + } if (killer.FactionId == 1 || killer.FactionId == 3) return; - User cop = copPlayer.GetUser(); + User cop = copPlayer?.GetUser(); + if (cop == null) + { + return; + } if (!cop.GetData("duty")) return; if (cop.FactionId == 1 || cop.FactionId == 3) {