From 44aaea6021b37a7cce29ab1c7c878c4fa94c4aae Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 3 Apr 2021 22:56:06 +0200 Subject: [PATCH] =?UTF-8?q?/lc=20und=20/ga=20f=C3=BCr=20admins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/FactionCommands.cs | 14 +++++++++----- ReallifeGamemode.Server/Services/ChatService.cs | 9 +++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/FactionCommands.cs b/ReallifeGamemode.Server/Commands/FactionCommands.cs index 6a75bf9c..c0668be5 100644 --- a/ReallifeGamemode.Server/Commands/FactionCommands.cs +++ b/ReallifeGamemode.Server/Commands/FactionCommands.cs @@ -10,6 +10,7 @@ using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Factions.Medic; using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Services; +using ReallifeGamemode.Server.Types; using ReallifeGamemode.Services; /** @@ -43,20 +44,21 @@ namespace ReallifeGamemode.Server.Commands [Command("ga", "~m~Benutzung: ~s~/ga [Nachricht]", GreedyArg = true)] public void CmdFactionGA(Player player, string message) { - Faction f = player.GetUser()?.Faction; + User user = player.GetUser(); + Faction f = user?.Faction; if (f == null || f.StateOwned) { ChatService.NotAuthorized(player); return; } - if (player.GetUser().Faction.Name == "Ballas" || player.GetUser().Faction.Name == "Grove") + if (f.Name == "Ballas" || f.Name == "Grove" || user.IsAdmin(AdminLevel.ADMIN)) { message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", ""); string broadcastMessage = "!{FF0000}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + " **"; using (var context = new DatabaseContext()) { - ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.GangOwned)); + ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.GangOwned), true); } } else @@ -177,7 +179,8 @@ namespace ReallifeGamemode.Server.Commands [Command("lc", "~m~Benutzung: ~s~/lc [Nachricht]", GreedyArg = true)] public void CmdFactionLc(Player player, string message) { - if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false) + User user = player.GetUser(); + if (user?.FactionId == null || user.FactionLeader == false || !user.IsAdmin(AdminLevel.ADMIN)) { ChatService.NotAuthorized(player); return; @@ -189,7 +192,8 @@ namespace ReallifeGamemode.Server.Commands NAPI.Pools.GetAllPlayers().ForEach(p => { - if (p.GetUser()?.FactionLeader ?? false) ChatService.SendMessage(p, broadcastMsg); + User pUser = p.GetUser(); + if (pUser?.FactionLeader ?? false || pUser.IsAdmin(AdminLevel.ADMIN)) ChatService.SendMessage(p, broadcastMsg); }); } diff --git a/ReallifeGamemode.Server/Services/ChatService.cs b/ReallifeGamemode.Server/Services/ChatService.cs index 196d123f..d63d16c2 100644 --- a/ReallifeGamemode.Server/Services/ChatService.cs +++ b/ReallifeGamemode.Server/Services/ChatService.cs @@ -52,11 +52,12 @@ namespace ReallifeGamemode.Server.Services /// /// Die Nachricht, die gesendet werden soll /// Die Liste an Fraktionen, die diese Nachricht bekommen sollen - public static void BroadcastFaction(string message, List factions) + public static void BroadcastFaction(string message, List factions, bool toAdmins = false) { foreach (Player c in NAPI.Pools.GetAllPlayers()) { - Faction f = c.GetUser()?.Faction; + User user = c.GetUser(); + Faction f = user.Faction; if (f != null) { if (factions.Find(fT => fT.Id == f.Id) != null) @@ -64,6 +65,10 @@ namespace ReallifeGamemode.Server.Services ChatService.SendMessage(c, message); } } + else if(user.IsAdmin(AdminLevel.ADMIN) && toAdmins) + { + ChatService.SendMessage(c, message); + } } }