From 28e6a461f0b9f77e1a603385479f3eeb589cb569 Mon Sep 17 00:00:00 2001 From: Lukas Moungos Date: Sat, 20 Jul 2019 15:25:38 +0200 Subject: [PATCH] Day 254 : Fixes --- .../Commands/AdminCommands.cs | 2 +- ReallifeGamemode.Server/Events/Death.cs | 42 +++++++++-------- .../Extensions/ClientExtension.cs | 4 +- ReallifeGamemode.Server/Wanted/Jail.cs | 46 ++++++++----------- .../Wanted/WantedEscapeTimer.cs | 2 +- 5 files changed, 45 insertions(+), 51 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 4c97d5b2..fc5ec97e 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -2571,7 +2571,7 @@ namespace ReallifeGamemode.Server.Commands foreach (var target in NAPI.Pools.GetAllPlayers().Select(c => c.GetUser())) { - Economy.SetPaycheck(target.Client, target.Wage); + Economy.SetPaycheck(target.Client, target.Wage); } ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast ein Payday gedroppt."); diff --git a/ReallifeGamemode.Server/Events/Death.cs b/ReallifeGamemode.Server/Events/Death.cs index d1518cde..04e0d4a4 100644 --- a/ReallifeGamemode.Server/Events/Death.cs +++ b/ReallifeGamemode.Server/Events/Death.cs @@ -83,29 +83,31 @@ namespace ReallifeGamemode.Server.Events } //TODO PICTURE NOTIFICATION + SOUND für Medics - } - - - using (var userDeath = new DatabaseContext()) - { - var dead = new Entities.Logs.Death + using (var userDeath = new DatabaseContext()) { - VictimId = player.GetUser().Id, - KillerId = killerId, - KillerPositionX = killerPosX, - KillerPositionY = killerPosY, - KillerPositionZ = killerPosZ, - KillerHeading = killerHeading, - VictimPositionX = player.Position.X, - VictimPositionY = player.Position.Y, - VictimPositionZ = player.Position.Z, - VictimHeading = player.Heading, - CauseOfDeath = reason.ToString() - }; - userDeath.DeathLogs.Add(dead); - userDeath.SaveChanges(); + var dead = new Entities.Logs.Death + { + VictimId = player.GetUser().Id, + KillerId = killerId, + KillerPositionX = killerPosX, + KillerPositionY = killerPosY, + KillerPositionZ = killerPosZ, + KillerHeading = killerHeading, + VictimPositionX = player.Position.X, + VictimPositionY = player.Position.Y, + VictimPositionZ = player.Position.Z, + VictimHeading = player.Heading, + CauseOfDeath = reason.ToString() + }; + userDeath.DeathLogs.Add(dead); + userDeath.SaveChanges(); + } } + + + + //JailTime.cs Jail.Check_PutBehindBars(player); diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index 1b7b39b4..b1138273 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -115,12 +115,12 @@ namespace ReallifeGamemode.Server.Extensions { ChatService.SendMessage(copPlayer, "~r~HQ: Straftat gemeldet von " + cop.Name + " mit Fahndungslevel "+ amount +". Straftäter: "+ user.Name + "."); ChatService.SendMessage(copPlayer, "~r~HQ: Grund: " + reason + "."); - ChatService.SendMessage(copPlayer, "~r~HQ: Der Straftäter: " + user.Name + " wird nun mit "+ user.Wanteds +" gesucht."); + ChatService.SendMessage(copPlayer, "~r~HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht."); } else if((copUser.FactionId == 1 || copUser.FactionId == 3) && cop == null) { ChatService.SendMessage(copPlayer, "~r~HQ: " + user.Name + " hat eine Straftat begangen. Grund: " + reason + "."); - ChatService.SendMessage(copPlayer, "~r~HQ: Der Straftäter: " + user.Name + " wird nun mit " + user.Wanteds + " gesucht."); + ChatService.SendMessage(copPlayer, "~r~HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht."); } } diff --git a/ReallifeGamemode.Server/Wanted/Jail.cs b/ReallifeGamemode.Server/Wanted/Jail.cs index 24981428..a51feeb9 100644 --- a/ReallifeGamemode.Server/Wanted/Jail.cs +++ b/ReallifeGamemode.Server/Wanted/Jail.cs @@ -21,8 +21,6 @@ namespace ReallifeGamemode.Server.Wanted User user = client.GetUser(); if (user.JailTime > 0) { - - client.SetData("isDead", false); client.RemoveAllWeapons(); client.Health = 100; client.Armor = 0; @@ -34,12 +32,6 @@ namespace ReallifeGamemode.Server.Wanted NAPI.Player.SpawnPlayer(client, new Vector3(459.696, -994.3766, 24.91486)); //send client to jail if (rndInt == 3) NAPI.Player.SpawnPlayer(client, new Vector3(458.3372, -1001.258, 24.91485)); //send client to jail - - client.TriggerEvent("onPlayerRevived"); - MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == client.Name); - Medic.RemoveTaskFromList(task); - client.Health = 100; - Jailtime[user.Id] = user.JailTime; // 54 sec for each wanted star -> in total 45min for 50 Wanteds return; } @@ -66,31 +58,31 @@ namespace ReallifeGamemode.Server.Wanted client.GetUser(dbContext).Wanteds = 0; dbContext.SaveChanges(); } + client.SetData("isDead", false); + client.RemoveAllWeapons(); + Random rnd = new Random(); + int rndInt = rnd.Next(1, 3); + if (rndInt == 1) + NAPI.Player.SpawnPlayer(client, new Vector3(458.9842, -997.2126, 24.91485)); //send client to jail + if (rndInt == 2) + NAPI.Player.SpawnPlayer(client, new Vector3(459.696, -994.3766, 24.91486)); //send client to jail + if (rndInt == 3) + NAPI.Player.SpawnPlayer(client, new Vector3(458.3372, -1001.258, 24.91485)); //send client to jail - } + client.TriggerEvent("onPlayerRevived"); + MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == client.Name); + Medic.RemoveTaskFromList(task); + client.Health = 100; - client.SetData("isDead", false); - client.RemoveAllWeapons(); - Random rnd = new Random(); - int rndInt = rnd.Next(1, 3); - if (rndInt == 1) - NAPI.Player.SpawnPlayer(client, new Vector3(458.9842, -997.2126, 24.91485)); //send client to jail - if (rndInt == 2) - NAPI.Player.SpawnPlayer(client, new Vector3(459.696, -994.3766, 24.91486)); //send client to jail - if (rndInt == 3) - NAPI.Player.SpawnPlayer(client, new Vector3(458.3372, -1001.258, 24.91485)); //send client to jail - - client.TriggerEvent("onPlayerRevived"); - MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == client.Name); - Medic.RemoveTaskFromList(task); - client.Health = 100; - - ChatService.SendMessage(client, "Du bist im Gefängnis für " + jailTime + " Sekunden."); - ChatService.BroadcastFaction("~r~HQ: " + user.Name + " wurde ins Gefängnis geliefert.", new List() { 1, 3 }); + ChatService.SendMessage(client, "Du bist im Gefängnis für " + jailTime + " Sekunden."); + ChatService.BroadcastFaction("~r~HQ: " + user.Name + " wurde ins Gefängnis geliefert.", new List() { 1, 3 }); + } } } } + + public static void JailTimer() { System.Timers.Timer timer = new System.Timers.Timer(60000); diff --git a/ReallifeGamemode.Server/Wanted/WantedEscapeTimer.cs b/ReallifeGamemode.Server/Wanted/WantedEscapeTimer.cs index 2e2e9390..c8046669 100644 --- a/ReallifeGamemode.Server/Wanted/WantedEscapeTimer.cs +++ b/ReallifeGamemode.Server/Wanted/WantedEscapeTimer.cs @@ -52,7 +52,7 @@ namespace ReallifeGamemode.Server.Wanted foreach (var playerCop in NAPI.Pools.GetAllPlayers()) { User cop = playerCop.GetUser(); - if (cop.FactionId == 1 || cop.FactionId == 3) + if (cop != null && (cop.FactionId == 1 || cop.FactionId == 3)) { if (cop.GetData("duty") && playerCop.Position.DistanceTo2D(player.Position) <= 500) {