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); + } } } }