/// <summary> Use only on server. </summary> public static void SendChatMessageToAllPlayers(string msg, string sender) { if (!NetStatus.IsServerStarted) { return; } foreach (var player in Player.AllPlayers) { SendChatMessageToPlayer(player, msg, sender); } if (!NetStatus.IsHost()) { // running as dedicated server // we should invoke the event here, because there is no local player to receive the chat message onChatMessage(new ChatMessage(msg, sender)); } }
public static void SendChatMessageToAllPlayersAsServer(string msg, string sender) { NetStatus.ThrowIfNotOnServer(); msg = ChatManager.ProcessChatMessage(msg, true); if (string.IsNullOrEmpty(msg)) { return; } foreach (var player in Player.AllPlayers) { SendChatMessageToPlayerAsServer(player, msg, sender); } if (!NetStatus.IsHost()) { // running as dedicated server // we should invoke the event here, because there is no local player to receive the chat message F.InvokeEventExceptionSafe(onChatMessage, new ChatMessage(msg, sender)); } }