From 51a051cd8fb103fe3206e520ee30dcf6997e717d Mon Sep 17 00:00:00 2001 From: hydrant Date: Mon, 5 Apr 2021 02:25:56 +0200 Subject: [PATCH] =?UTF-8?q?d=20chat=20f=C3=BCr=20admins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/FactionCommands.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/FactionCommands.cs b/ReallifeGamemode.Server/Commands/FactionCommands.cs index b7e32058..8cebc338 100644 --- a/ReallifeGamemode.Server/Commands/FactionCommands.cs +++ b/ReallifeGamemode.Server/Commands/FactionCommands.cs @@ -97,8 +97,9 @@ namespace ReallifeGamemode.Server.Commands [Command("d", "~m~Benutzung: ~s~/d [Nachricht]", GreedyArg = true)] public void CmdFactionD(Player player, string message) { + User u = player.GetUser(); Faction f = player.GetUser()?.Faction; - if (f == null || !f.StateOwned) + if ((f == null || !f.StateOwned) && !u.IsAdmin(AdminLevel.ADMIN)) { ChatService.NotAuthorized(player); return; @@ -106,10 +107,21 @@ namespace ReallifeGamemode.Server.Commands message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", ""); - string broadcastMessage = "!{CC3333}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + ", over **"; + string factionName = string.Empty; + + if(f.StateOwned) + { + factionName = player.GetUser().GetFactionRank().RankName; + } + else + { + factionName = "[ADMIN]"; + } + + string broadcastMessage = "!{CC3333}** " + factionName + " " + player.Name + ": " + message + ", over **"; using (var context = new DatabaseContext()) { - ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.StateOwned)); + ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.StateOwned), true); } }