From 0ab081cccb1e371b83ab5a8336dd7194a8383609 Mon Sep 17 00:00:00 2001 From: Fabian Date: Mon, 26 Apr 2021 21:18:51 +0200 Subject: [PATCH] =?UTF-8?q?neuer=20knast:=20punkte=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReallifeGamemode.Server/Events/Death.cs | 2 +- ReallifeGamemode.Server/Events/Login.cs | 4 +-- ReallifeGamemode.Server/Finance/Economy.cs | 2 +- ReallifeGamemode.Server/Wanted/Jail.cs | 42 +++++++++++++++------- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/ReallifeGamemode.Server/Events/Death.cs b/ReallifeGamemode.Server/Events/Death.cs index 872632fa..5f980db3 100644 --- a/ReallifeGamemode.Server/Events/Death.cs +++ b/ReallifeGamemode.Server/Events/Death.cs @@ -148,7 +148,7 @@ namespace ReallifeGamemode.Server.Events if (copNearby) { user.SetJailTime(true, dbContext); - Jail.Check_PutBehindBars(user); + Jail.Check_PutBehindBars(user, "cell"); ChatService.HQMessage(user.Name + " wurde ins Gefängnis eingeliefert."); } else diff --git a/ReallifeGamemode.Server/Events/Login.cs b/ReallifeGamemode.Server/Events/Login.cs index a4357238..639baff4 100644 --- a/ReallifeGamemode.Server/Events/Login.cs +++ b/ReallifeGamemode.Server/Events/Login.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using GTANetworkAPI; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; @@ -164,7 +164,7 @@ namespace ReallifeGamemode.Server.Events } else { - Jail.Check_PutBehindBars(user); + Jail.Check_PutBehindBars(user, "cell"); } player.Dimension = 0; diff --git a/ReallifeGamemode.Server/Finance/Economy.cs b/ReallifeGamemode.Server/Finance/Economy.cs index 3e5cfce8..4bf28832 100644 --- a/ReallifeGamemode.Server/Finance/Economy.cs +++ b/ReallifeGamemode.Server/Finance/Economy.cs @@ -200,7 +200,7 @@ namespace ReallifeGamemode.Server.Finance if (putInJail != 0 && minusJail) { - Jail.Check_PutBehindBars(u); + Jail.Check_PutBehindBars(u, "cell"); } } diff --git a/ReallifeGamemode.Server/Wanted/Jail.cs b/ReallifeGamemode.Server/Wanted/Jail.cs index 745a12e1..f5c06a7c 100644 --- a/ReallifeGamemode.Server/Wanted/Jail.cs +++ b/ReallifeGamemode.Server/Wanted/Jail.cs @@ -19,7 +19,18 @@ namespace ReallifeGamemode.Server.Wanted { private static Dictionary Jailtime { get; set; } = new Dictionary(); //time in seconds - public static void Check_PutBehindBars(User user) + private static Vector3 JailIn_Point = new Vector3(1690.754, 2591.0464, 45.914402); + private static int JailIn_Range = 3; + private static Vector3 JailOut_Point = new Vector3(1848.3097, 2585.9036, 45.67201); + + private static List prisonCells = new List() { + new Vector3(1629.2026, 2569.8057, 45.564846), + new Vector3(1642.7831, 2570.2622, 45.56483), + new Vector3(1651.512, 2570.2249, 45.564907) + }; + + //positionInJail: ENTWEDER "cell" ODER "outside" + public static void Check_PutBehindBars(User user, String positionInJail) { user.SetBlipAndNametagColor(); Player player = user.Player; @@ -31,15 +42,19 @@ namespace ReallifeGamemode.Server.Wanted player.ClearAnimation(); player.SafeSetHealth(100); player.Armor = 0; - Random rnd = new Random(); - int rndInt = rnd.Next(1, 3); - Vector3 position = new Vector3(); - if (rndInt == 1) - position = new Vector3(458.9842, -997.2126, 24.91485); //send client to jail - if (rndInt == 2) - position = new Vector3(459.696, -994.3766, 24.91486); //send client to jail - if (rndInt == 3) - position = new Vector3(458.3372, -1001.258, 24.91485); //send client to jail + + Vector3 position = null; + + if (positionInJail == "cell") + { + Random rnd = new Random(); + int rndInt = rnd.Next(1, 3); + position = prisonCells[rndInt]; + + } else if (positionInJail == "outside") + { + position = new Vector3(1691.42, 2562.77, 45.56); + } player.SafeTeleport(position, 0, true); @@ -78,7 +93,7 @@ namespace ReallifeGamemode.Server.Wanted using var dbContext = new DatabaseContext(); foreach (var player in NAPI.Pools.GetAllPlayers()) { - if (player.Position.DistanceTo(new Vector3(458.9842, -997.2126, 24.91485)) > 7) + if (player.Position.DistanceTo(JailIn_Point) > JailIn_Range) { continue; } @@ -98,7 +113,8 @@ namespace ReallifeGamemode.Server.Wanted user.SetBlipAndNametagColor(); user.AnnouncePlayerJailedIn(); dbContext.SaveChanges(); - Check_PutBehindBars(user); + //HERE: Freilauf + Check_PutBehindBars(user, "outside"); break; } } @@ -139,7 +155,7 @@ namespace ReallifeGamemode.Server.Wanted if (user.JailTime <= 0) { Jailtime.Remove(user.Id); - player.SafeTeleport(new Vector3(427.879, -984.65, 30.71)); + player.SafeTeleport(JailOut_Point); player.TriggerEvent("jailTime", 0); return; }