From d58a19033dd404750fcae20f640052f3451d85bb Mon Sep 17 00:00:00 2001 From: "michael.reiswich" Date: Tue, 25 May 2021 15:28:41 +0200 Subject: [PATCH] add selbsteinknasten --- ReallifeGamemode.Server/Events/Key.cs | 31 +++++++++++++++++-- .../Managers/PositionManager.cs | 25 +++++++++++++++ ReallifeGamemode.Server/Wanted/Jail.cs | 4 +++ 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index dde1e8cf..fa4449a5 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -21,6 +21,7 @@ using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.WeaponDeal; using ReallifeGamemode.Server.Log; +using ReallifeGamemode.Server.Wanted; /** * @overview Life of German Reallife - Event Key (Key.cs) @@ -241,6 +242,7 @@ namespace ReallifeGamemode.Server.Events Player nearestCuffPlayer = PositionManager.cuffPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6 && user.GetData("duty")); AmmunationPoint nearestAmmunationPoint = PositionManager.AmmunationPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5); RentcarPoint nearestRentcarPoint = PositionManager.rentcarPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5); + JailPoint nearestjailPoint = PositionManager.jailPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5); if (user?.FactionId != null) { @@ -502,8 +504,33 @@ namespace ReallifeGamemode.Server.Events } } - //Rentcar Points - if (nearestRentcarPoint != null) + using var dbcontext = new DatabaseContext(); + + User client = player.GetUser(dbcontext); + + if (nearestjailPoint != null) + { + int oStaatsfrak = NAPI.Pools.GetAllPlayers().Where(p => !p.IsAfk() && p.IsLoggedIn() && p.GetUser(dbcontext).FactionId == 1).Count() + + NAPI.Pools.GetAllPlayers().Where(p => !p.IsAfk() && p.IsLoggedIn() && p.GetUser(dbcontext).FactionId == 3).Count(); + if(oStaatsfrak > 0) + { + player.SendNotification("~y~[Info]~w~ Es sind genügend Beamte online!"); + return; + } + + if (client.Wanteds <= 0) + { + player.SendNotification("~y~[Info]~w~ Du wirst nicht gesucht!"); + return; + } + client.SetJailTime(true, dbcontext); + Jail.Check_PutBehindBars(client, JailInLocations.Outside); + player.SendNotification("Du hast dich selbst eingeknastet"); + ChatService.HQMessage(player.Name + " wurde ins Gefängnis eingeliefert."); + } + + //Rentcar Points + if (nearestRentcarPoint != null) { if (player.IsInVehicle) { diff --git a/ReallifeGamemode.Server/Managers/PositionManager.cs b/ReallifeGamemode.Server/Managers/PositionManager.cs index 76e9ad3f..44a3172b 100644 --- a/ReallifeGamemode.Server/Managers/PositionManager.cs +++ b/ReallifeGamemode.Server/Managers/PositionManager.cs @@ -40,6 +40,7 @@ namespace ReallifeGamemode.Server.Managers public static List carwashPoints = new List(); + public static List jailPoints = new List(); public static Vector3 eventportPosition; public static bool eventportActive = false; @@ -121,6 +122,25 @@ namespace ReallifeGamemode.Server.Managers #endregion WeaponPoints + #region JailPoints + + JailPoint jail = new JailPoint() + { + Position = new Vector3(1854.06, 2582.38, 45.67) + }; + + + jailPoints.Add(jail); + + foreach (JailPoint j in jailPoints) + { + NAPI.Marker.CreateMarker(1, new Vector3(j.Position.X, j.Position.Y, j.Position.Z - 2), new Vector3(j.Position.X, j.Position.Y, j.Position.Z + 1), + new Vector3(0, 0, 0), 1.5f, new Color(255, 255, 255, 0), false, 0); + NAPI.TextLabel.CreateTextLabel("Stellen - Dr\u00fccke ~y~E", j.Position, 7, 1, 0, new Color(255, 255, 255), false, 0); + } + + #endregion JailReleasePoints + #region JailReleasePoints JailReleasePoint jailPointLSPD = new JailReleasePoint() @@ -558,3 +578,8 @@ public class CarwashPoint public Vector3 Position { get; set; } } +public class JailPoint +{ + public Vector3 Position { get; set; } +} + diff --git a/ReallifeGamemode.Server/Wanted/Jail.cs b/ReallifeGamemode.Server/Wanted/Jail.cs index f3aadfdf..76479d30 100644 --- a/ReallifeGamemode.Server/Wanted/Jail.cs +++ b/ReallifeGamemode.Server/Wanted/Jail.cs @@ -134,8 +134,10 @@ namespace ReallifeGamemode.Server.Wanted if (user.JailTime <= 0) { Jailtime.Remove(user.Id); + user.Wanteds = 0; player.SafeTeleport(JailOut_Point); player.TriggerEvent("jailTime", 0); + dbContext.SaveChanges(); return; } if (user.JailTime > 0) @@ -175,6 +177,7 @@ namespace ReallifeGamemode.Server.Wanted using (var dbContext = new DatabaseContext()) { player.GetUser(dbContext).JailTime = 0; + player.GetUser(dbContext).Wanteds = 0; dbContext.SaveChanges(); } player.SafeSetHealth(100); @@ -195,6 +198,7 @@ namespace ReallifeGamemode.Server.Wanted Jailtime.Remove(user.Id); user.JailTime = 0; + user.Wanteds = 0; dbContext.SaveChanges(); target.SafeSetHealth(100);