From f80eed6a6882cd65092db02d548e54edcaaabeb9 Mon Sep 17 00:00:00 2001 From: Fabian Fabian Date: Wed, 4 Sep 2019 23:51:58 +0200 Subject: [PATCH] admin unjail --- .../Commands/AdminCommands.cs | 11 ++++++++ ReallifeGamemode.Server/Wanted/Jail.cs | 27 +++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 35a852c1..76ebaef0 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -16,6 +16,7 @@ using ReallifeGamemode.Server.Factions.Medic; using ReallifeGamemode.Server.Models; using ReallifeGamemode.Server.Job; using ReallifeGamemode.Server.Finance; +using ReallifeGamemode.Server.Wanted; /** * @overview Life of German Reallife - Admin Commands (Admin.cs) @@ -352,6 +353,16 @@ namespace ReallifeGamemode.Server.Commands #endregion #region ALevel1 + [Command("aunjail", "~m~Benutzung: ~s~/aunjail [Spieler]", GreedyArg = true)] + public void CmdAdminAunjai(Client player, string targetname) + { + Client target = ClientService.GetClientByNameOrId(targetname); + if (target == null) + return; + + ReallifeGamemode.Server.Wanted.Jail.Release_Jail_Admin(player, target); + } + [Command("a", "~m~Benutzung: ~s~/a [Nachricht]", GreedyArg = true)] public void CmdAdminA(Client player, string message) { diff --git a/ReallifeGamemode.Server/Wanted/Jail.cs b/ReallifeGamemode.Server/Wanted/Jail.cs index 6bb59c0a..6d02b9c6 100644 --- a/ReallifeGamemode.Server/Wanted/Jail.cs +++ b/ReallifeGamemode.Server/Wanted/Jail.cs @@ -174,8 +174,6 @@ namespace ReallifeGamemode.Server.Wanted } } - - [RemoteEvent("setPrisonerFree")] public void Release_Jail(Client cop, string client) { @@ -206,6 +204,31 @@ namespace ReallifeGamemode.Server.Wanted } } } + + public static void Release_Jail_Admin(Client admin, Client target) + { + User user = target.GetUser(); + if (Jailtime.ContainsKey(user.Id)) + { + Jailtime.Remove(user.Id); + using (var dbContext = new DatabaseContext()) + { + target.GetUser(dbContext).JailTime = 0; + dbContext.SaveChanges(); + } + target.Health = 100; + target.Position = new Vector3(461.7256, -988.6035, 24.91487); + foreach (var copPlayer in NAPI.Pools.GetAllPlayers()) + { + User copUser = copPlayer.GetUser(); + if ((copUser.FactionId == 1 || copUser.FactionId == 3)) + { + ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Admin " + admin.Name + " hat " + user.Name + " aus dem Knast entlassen."); + } + + } + } + } } }