From c6c7ca63056e20797a83f72a1f039424130501a2 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Fri, 7 Apr 2023 14:04:04 -0500 Subject: [PATCH] enable support for custom say name on non IW4 games with tell/say raw --- Application/IW4MServer.cs | 4 ++-- SharedLibraryCore/Server.cs | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index 9f13a5a3a..af5e07e59 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -330,7 +330,7 @@ namespace IW4MAdmin else if (E.Type == GameEvent.EventType.ConnectionRestored) { ServerLogger.LogInformation( - "Connection restored with {server}", ToString()); + "Connection restored with {Server}", ToString()); if (!Manager.GetApplicationSettings().Configuration().IgnoreServerConnectionLost) { @@ -1347,7 +1347,7 @@ namespace IW4MAdmin if (Manager.GetApplicationSettings().Configuration().EnableCustomSayName) { - await this.SetDvarAsync("sv_sayname", Manager.GetApplicationSettings().Configuration().CustomSayName, + await this.SetDvarAsync("sv_sayname", CustomSayName, Manager.CancellationToken); } diff --git a/SharedLibraryCore/Server.cs b/SharedLibraryCore/Server.cs index 3acd4e968..81673fe02 100644 --- a/SharedLibraryCore/Server.cs +++ b/SharedLibraryCore/Server.cs @@ -239,8 +239,10 @@ namespace SharedLibraryCore /// Client that initiated the broadcast public GameEvent Broadcast(string message, EFClient sender = null) { + var hasRawSupport = RconParser.Configuration.CommandPrefixes.Say.Contains("raw"); var formattedMessage = string.Format(RconParser.Configuration.CommandPrefixes.Say ?? "", - $"{(CustomSayEnabled && GameName == Game.IW4 ? $"{CustomSayName}: " : "")}{message}"); + $"{(CustomSayEnabled && hasRawSupport ? $"{CustomSayName}: " : "")}{message}"); + ServerLogger.LogDebug("All-> {Message}", message.FormatMessageForEngine(RconParser.Configuration).StripColors()); @@ -294,9 +296,11 @@ namespace SharedLibraryCore var parsedClientId = string.IsNullOrEmpty(temporalClientId) ? (int?)null : int.Parse(temporalClientId); var clientNumber = parsedClientId ?? targetClient.ClientNumber; + var hasRawSupport = RconParser.Configuration.CommandPrefixes.Tell.Contains("raw"); var formattedMessage = string.Format(RconParser.Configuration.CommandPrefixes.Tell, clientNumber, - $"{(CustomSayEnabled && GameName == Game.IW4 ? $"{CustomSayName}: " : "")}{message}"); + $"{(CustomSayEnabled && hasRawSupport ? $"{CustomSayName}: " : "")}{message}"); + if (targetClient.ClientNumber > -1 && message.Length > 0 && targetClient.Level != Data.Models.Client.EFClient.Permission.Console) {