From 33b2cdaf50c285f31bbebf977ed4e99dea44fa33 Mon Sep 17 00:00:00 2001 From: Fabian Date: Mon, 26 Apr 2021 23:03:25 +0200 Subject: [PATCH] =?UTF-8?q?aufger=C3=A4umt=20im=20knast?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReallifeGamemode.Client/Player/polygons.ts | 6 +----- ReallifeGamemode.Server/Wanted/Jail.cs | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ReallifeGamemode.Client/Player/polygons.ts b/ReallifeGamemode.Client/Player/polygons.ts index 0ee4f550..ea468a4b 100644 --- a/ReallifeGamemode.Client/Player/polygons.ts +++ b/ReallifeGamemode.Client/Player/polygons.ts @@ -88,11 +88,7 @@ export default function polygonHandler() { } if (polygon == polygon_prison) { - mp.events.callRemote("SERVER:CheckPlayerInJail"); + mp.events.callRemote("SERVER:BreakOutIfInPrison"); } }); - - mp.events.add('CLIENT:PrisonBreakout', () => { - mp.events.callRemote("SERVER:PrisonBreakout"); - }); } diff --git a/ReallifeGamemode.Server/Wanted/Jail.cs b/ReallifeGamemode.Server/Wanted/Jail.cs index 0630228b..0db1d8dc 100644 --- a/ReallifeGamemode.Server/Wanted/Jail.cs +++ b/ReallifeGamemode.Server/Wanted/Jail.cs @@ -208,8 +208,7 @@ namespace ReallifeGamemode.Server.Wanted } } - [RemoteEvent("SERVER:PrisonBreakout")] - public static void BrakeOut_Elapsed(Player player) + public static void BreakOut(Player player) { User user = player.GetUser(); @@ -224,13 +223,22 @@ namespace ReallifeGamemode.Server.Wanted } } - [RemoteEvent("SERVER:CheckPlayerInJail")] - public void checkPlayerInJail(Player player) + [RemoteEvent("SERVER:BreakOutIfInPrison")] + public void breakOutIfInPrison(Player player) { User user = player.GetUser(); - if (Jailtime.ContainsKey(user.Id)) + + using (var dbContext = new DatabaseContext()) { - player.TriggerEvent("CLIENT:PrisonBreakout"); + if (Jailtime.ContainsKey(user.Id)) + { + user = player.GetUser(dbContext); + user.JailTime = 0; + user.GiveWanteds(null, 50, "Knast-Ausbruch"); + player.TriggerEvent("jailTime", 0); + dbContext.SaveChanges(); + Jailtime.Remove(user.Id); + } } } }