public static void cinematic_stop(Arg arg) { if (!arg.IsServerside) { return; } BasePlayer basePlayer = ArgEx.Player(arg); if (!(basePlayer == null)) { string strCommand = string.Empty; if (basePlayer.IsAdmin || basePlayer.IsDeveloper) { strCommand = arg.cmd.FullName + " " + arg.FullString + " " + basePlayer.UserIDString; } else if (Server.cinematic) { strCommand = arg.cmd.FullName + " " + basePlayer.UserIDString; } if (Server.cinematic) { ConsoleNetwork.BroadcastToAllClients(strCommand); } else if (basePlayer.IsAdmin || basePlayer.IsDeveloper) { ConsoleNetwork.SendClientCommand(arg.Connection, strCommand); } } }
object OnPlayerChat(ConsoleSystem.Arg arg, Chat.ChatChannel chatchannel) { BasePlayer inputChatBasePlayer = arg.Connection.player as BasePlayer; String playerName = arg.Connection.username; String message = arg.GetString(0); String convertMessage = "KR".Equals(InfoUtils.GetUserMode(inputChatBasePlayer, User[inputChatBasePlayer.UserIDString])) ? StringUtils.getConvertKor(message) : message; // 콘솔로그 Puts(playerName + ": " + convertMessage); // 욕설 변환 convertMessage = this.getChangeForbiddenWord(convertMessage, inputChatBasePlayer, chatchannel); if (!isUsePlugin("BetterChat")) { if (chatchannel == Chat.ChatChannel.Team) { List <Connection> sendUserList = new List <Connection>(); RelationshipManager.PlayerTeam team = inputChatBasePlayer.Team; if (null == team || team.members.Count < 1) { return(true); } foreach (ulong teamUserId in team.members) { Connection inUser = BasePlayer.FindByID(teamUserId).Connection; if (null != inUser) { sendUserList.Add(inUser); } } // 메시지 전송 if (sendUserList.Count > 0) { ConsoleNetwork.SendClientCommand(sendUserList, "chat.add2", new object[] { chatchannel, inputChatBasePlayer.UserIDString, convertMessage, "[TEAM] " + inputChatBasePlayer.displayName, "#" + InfoUtils.GetUserNameColor() }); } } else { List <Connection> sendUserList = new List <Connection>(); foreach (BasePlayer basePlayer in BasePlayer.activePlayerList) { sendUserList.Add(basePlayer.Connection); } // 메시지 전송 if (sendUserList.Count > 0) { ConsoleNetwork.SendClientCommand(sendUserList, "chat.add2", new object[] { chatchannel, inputChatBasePlayer.UserIDString, convertMessage, inputChatBasePlayer.displayName, "#" + InfoUtils.GetUserNameColor() }); } } return(false); } return(null); }
private static void sayImpl(ChatChannel targetChannel, Arg arg) { if (!enabled) { arg.ReplyWith("Chat is disabled."); return; } BasePlayer basePlayer = ArgEx.Player(arg); if (!basePlayer || basePlayer.HasPlayerFlag(BasePlayer.PlayerFlags.ChatMute)) { return; } if (!basePlayer.IsAdmin && !basePlayer.IsDeveloper) { if (basePlayer.NextChatTime == 0f) { basePlayer.NextChatTime = UnityEngine.Time.realtimeSinceStartup - 30f; } if (basePlayer.NextChatTime > UnityEngine.Time.realtimeSinceStartup) { basePlayer.NextChatTime += 2f; float num = basePlayer.NextChatTime - UnityEngine.Time.realtimeSinceStartup; ConsoleNetwork.SendClientCommand(basePlayer.net.connection, "chat.add", 2, 0, "You're chatting too fast - try again in " + (num + 0.5f).ToString("0") + " seconds"); if (num > 120f) { basePlayer.Kick("Chatting too fast"); } return; } } string @string = arg.GetString(0, "text"); if (sayAs(targetChannel, basePlayer.userID, basePlayer.displayName, @string, basePlayer)) { basePlayer.NextChatTime = UnityEngine.Time.realtimeSinceStartup + 1.5f; } }
private object OnUserChat(IPlayer player, string message) { #endif if (message.Length > _instance._config.MaxMessageLength) { message = message.Substring(0, _instance._config.MaxMessageLength); } BetterChatMessage chatMessage = ChatGroup.FormatMessage(player, message); if (chatMessage == null) { return(null); } Dictionary <string, object> chatMessageDict = chatMessage.ToDictionary(); #if RUST chatMessageDict.Add("ChatChannel", chatchannel); #endif foreach (Plugin plugin in plugins.GetAll()) { object hookResult = plugin.CallHook("OnBetterChat", chatMessageDict); if (hookResult is Dictionary <string, object> ) { try { chatMessageDict = hookResult as Dictionary <string, object>; } catch (Exception e) { PrintError($"Failed to load modified OnBetterChat hook data from plugin '{plugin.Title} ({plugin.Version})':{Environment.NewLine}{e}"); continue; } } else if (hookResult != null) { return(null); } } chatMessage = BetterChatMessage.FromDictionary(chatMessageDict); switch (chatMessage.CancelOption) { case BetterChatMessage.CancelOptions.BetterChatOnly: return(null); case BetterChatMessage.CancelOptions.BetterChatAndDefault: return(true); } var output = chatMessage.GetOutput(); #if RUST switch (chatchannel) { case Chat.ChatChannel.Team: RelationshipManager.PlayerTeam team = BasePlayer.Find(player.Id).Team; if (team == null || team.members.Count == 0) { return(true); } team.BroadcastTeamChat(Convert.ToUInt64(player.Id), player.Name, chatMessage.Message, chatMessage.UsernameSettings.Color); List <Network.Connection> onlineMemberConnections = team.GetOnlineMemberConnections(); if (onlineMemberConnections != null) { ConsoleNetwork.SendClientCommand(onlineMemberConnections, "chat.add", new object[] { (int)chatchannel, player.Id, output.Chat }); } break; default: foreach (BasePlayer p in BasePlayer.activePlayerList.Where(p => !chatMessage.BlockedReceivers.Contains(p.UserIDString))) { p.SendConsoleCommand("chat.add", new object[] { (int)chatchannel, player.Id, output.Chat }); } break; } #else foreach (IPlayer p in players.Connected.Where(p => !chatMessage.BlockedReceivers.Contains(p.Id))) { p.Message(output.Chat); } #endif #if RUST Puts($"[{chatchannel}] {output.Console}"); RCon.Broadcast(RCon.LogType.Chat, new Chat.ChatEntry { Channel = chatchannel, Message = output.Console, UserId = player.Id, Username = player.Name, Color = chatMessage.UsernameSettings.Color, Time = Epoch.Current }); #else Puts(output.Console); #endif return(true); }
void OnClientAuth(Connection connection) { if (connection.protocol > serverProtocol) { if (!antiSpam.ContainsKey(connection.userid)) { antiSpam.Add(connection.userid, -1); } if (!quitTimer.ContainsKey(connection.userid)) { quitTimer.Add(connection.userid, 0); } if (quitTimer[connection.userid] == 2) { ConsoleNetwork.SendClientCommand(connection, "global.quit", new object[] {}); quitTimer[connection.userid] = 0; return; } if (antiSpam[connection.userid] != DateTime.Now.Minute) { quitTimer[connection.userid] = 0; var player = rust.FindPlayerById(connection.userid); if (player != null) { Puts($"Kicked '{player.displayName}' with client protocol '{connection.protocol}' | server has '{serverProtocol}'"); } else { Puts($"Kicked '{connection}' with client protocol '{connection.protocol}' | server has '{serverProtocol}'"); } antiSpam[connection.userid] = DateTime.Now.Minute; } else { quitTimer[connection.userid]++; } Network.Net.sv.Kick(connection, lang.GetMessage("msgServerWrong", this, connection.userid.ToString())); //connection.protocol = (uint)serverProtocol; NextTick(() => ServerMgr.Instance.connectionQueue.RemoveConnection(connection)); } if (connection.protocol < serverProtocol) { if (!antiSpam.ContainsKey(connection.userid)) { antiSpam.Add(connection.userid, -1); } if (!quitTimer.ContainsKey(connection.userid)) { quitTimer.Add(connection.userid, 0); } if (quitTimer[connection.userid] == 2) { ConsoleNetwork.SendClientCommand(connection, "global.quit", new object[] {}); quitTimer[connection.userid] = 0; return; } if (antiSpam[connection.userid] != DateTime.Now.Minute) { quitTimer[connection.userid] = 0; var player = rust.FindPlayerById(connection.userid); if (player != null) { Puts($"Kicked '{player.displayName}' with client protocol '{connection.protocol}' | server has '{serverProtocol}'"); } else { Puts($"Kicked '{connection}' with client protocol '{connection.protocol}' | server has '{serverProtocol}'"); } antiSpam[connection.userid] = DateTime.Now.Minute; } else { quitTimer[connection.userid]++; } Network.Net.sv.Kick(connection, lang.GetMessage("msgClientWrong", this, connection.userid.ToString())); //connection.protocol = (uint)serverProtocol; NextTick(() => ServerMgr.Instance.connectionQueue.RemoveConnection(connection)); } }
internal static bool sayAs(ChatChannel targetChannel, ulong userId, string username, string message, BasePlayer player = null) { if (!player) { player = null; } if (!enabled) { return(false); } if (player != null && player.HasPlayerFlag(BasePlayer.PlayerFlags.ChatMute)) { return(false); } ServerUsers.UserGroup userGroup = ServerUsers.Get(userId)?.group ?? ServerUsers.UserGroup.None; if (userGroup == ServerUsers.UserGroup.Banned) { return(false); } string text = message.Replace("\n", "").Replace("\r", "").Trim(); if (text.Length > 128) { text = text.Substring(0, 128); } if (text.Length <= 0) { return(false); } if (text.StartsWith("/") || text.StartsWith("\\")) { Interface.CallHook("IOnPlayerCommand", player, message); return(false); } text = text.EscapeRichText(); object obj = Interface.CallHook("IOnPlayerChat", userId, username, text, targetChannel, player); if (obj is bool) { return((bool)obj); } if (serverlog) { ServerConsole.PrintColoured(ConsoleColor.DarkYellow, string.Concat("[", targetChannel, "] ", username, ": "), ConsoleColor.DarkGreen, text); string text2 = player?.ToString() ?? $"{username}[{userId}]"; switch (targetChannel) { case ChatChannel.Team: DebugEx.Log("[TEAM CHAT] " + text2 + " : " + text); break; case ChatChannel.Cards: DebugEx.Log("[CARDS CHAT] " + text2 + " : " + text); break; default: DebugEx.Log("[CHAT] " + text2 + " : " + text); break; } } bool flag = userGroup == ServerUsers.UserGroup.Owner || userGroup == ServerUsers.UserGroup.Moderator; bool num = ((player != null) ? player.IsDeveloper : DeveloperList.Contains(userId)); string text3 = "#5af"; if (flag) { text3 = "#af5"; } if (num) { text3 = "#fa5"; } string text4 = username.EscapeRichText(); ChatEntry chatEntry = default(ChatEntry); chatEntry.Channel = targetChannel; chatEntry.Message = text; chatEntry.UserId = ((player != null) ? player.UserIDString : userId.ToString()); chatEntry.Username = username; chatEntry.Color = text3; chatEntry.Time = Epoch.Current; ChatEntry chatEntry2 = chatEntry; History.Add(chatEntry2); RCon.Broadcast(RCon.LogType.Chat, chatEntry2); switch (targetChannel) { case ChatChannel.Cards: { if (player == null) { return(false); } if (!player.isMounted) { return(false); } CardTable cardTable = player.GetMountedVehicle() as CardTable; if (cardTable == null || !cardTable.GameController.PlayerIsInGame(player)) { return(false); } List <Network.Connection> obj2 = Facepunch.Pool.GetList <Network.Connection>(); cardTable.GameController.GetConnectionsInGame(obj2); if (obj2.Count > 0) { ConsoleNetwork.SendClientCommand(obj2, "chat.add2", 3, userId, text, text4, text3, 1f); } Facepunch.Pool.FreeList(ref obj2); return(true); } case ChatChannel.Global: if (Server.globalchat) { ConsoleNetwork.BroadcastToAllClients("chat.add2", 0, userId, text, text4, text3, 1f); return(true); } break; case ChatChannel.Team: { RelationshipManager.PlayerTeam playerTeam = RelationshipManager.ServerInstance.FindPlayersTeam(userId); if (playerTeam == null) { return(false); } List <Network.Connection> onlineMemberConnections = playerTeam.GetOnlineMemberConnections(); if (onlineMemberConnections != null) { ConsoleNetwork.SendClientCommand(onlineMemberConnections, "chat.add2", 1, userId, text, text4, text3, 1f); } Util.BroadcastTeamChat(playerTeam, userId, text4, text, text3); return(true); } } if (player != null) { float num2 = 2500f; foreach (BasePlayer activePlayer in BasePlayer.activePlayerList) { float sqrMagnitude = (activePlayer.transform.position - player.transform.position).sqrMagnitude; if (!(sqrMagnitude > num2)) { ConsoleNetwork.SendClientCommand(activePlayer.net.connection, "chat.add2", 0, userId, text, text4, text3, Mathf.Clamp01(num2 - sqrMagnitude + 0.2f)); } } return(true); } return(false); }
private bool OnPlayerChat(ConsoleSystem.Arg arg, Chat.ChatChannel channel) { var player = arg.Player(); var text = arg.GetString(0, "text").Replace("\n", "").Replace("\r", "").Trim().EscapeRichText(); if (Chat.serverlog) { ServerConsole.PrintColoured(ConsoleColor.DarkYellow, string.Concat("[", channel.ToString(), "] ", player.displayName, ": "), ConsoleColor.DarkGreen, text); DebugEx.Log(channel == Chat.ChatChannel.Team ? $"[TEAM CHAT] {player} : {text}" : $"[CHAT] {player} : {text}"); } var color = "#5af"; var displayName = player.displayName.EscapeRichText(); player.NextChatTime = Time.realtimeSinceStartup + 1.5f; var chatEntry = new Chat.ChatEntry { Channel = channel, Message = text, UserId = player.UserIDString, Username = player.displayName, Color = color, Time = Epoch.Current }; RCon.Broadcast(RCon.LogType.Chat, chatEntry); if (channel != Chat.ChatChannel.Global) { if (channel == Chat.ChatChannel.Team) { var team = arg.Player().Team; var list = team?.GetOnlineMemberConnections(); if (list == null) { return(false); } ConsoleNetwork.SendClientCommand(list, "chat.add2", new object[] { 1, player.userID, text, displayName, color, 1f }); return(false); } } else if (ConVar.Server.globalchat) { ConsoleNetwork.BroadcastToAllClients("chat.add2", 0, player.userID, text, displayName, color, 1f); return(false); } var radius = 2500f; foreach (var basePlayer2 in BasePlayer.activePlayerList) { var sqrMagnitude = (basePlayer2.transform.position - player.transform.position).sqrMagnitude; if (sqrMagnitude <= radius) { ConsoleNetwork.SendClientCommand(basePlayer2.net.connection, "chat.add2", 0, player.userID, text, displayName, color, Mathf.Clamp01(radius - sqrMagnitude + 0.2f)); } } return(false); }
public static void say(ConsoleSystem.Arg arg) { if (!Chat.enabled) { arg.ReplyWith("Chat is disabled."); return; } BasePlayer basePlayer = arg.Player(); if (!basePlayer) { return; } if (basePlayer.HasPlayerFlag(BasePlayer.PlayerFlags.ChatMute)) { return; } if (!basePlayer.IsAdmin && !basePlayer.IsDeveloper) { if (basePlayer.NextChatTime == 0f) { basePlayer.NextChatTime = UnityEngine.Time.realtimeSinceStartup - 30f; } if (basePlayer.NextChatTime > UnityEngine.Time.realtimeSinceStartup) { basePlayer.NextChatTime += 2f; float nextChatTime = basePlayer.NextChatTime - UnityEngine.Time.realtimeSinceStartup; Connection connection = basePlayer.net.connection; object[] objArray = new object[] { 0, null }; float single = nextChatTime + 0.5f; objArray[1] = string.Concat("You're chatting too fast - try again in ", single.ToString("0"), " seconds"); ConsoleNetwork.SendClientCommand(connection, "chat.add", objArray); if (nextChatTime > 120f) { basePlayer.Kick("Chatting too fast"); } return; } } string str = arg.GetString(0, "text").Trim(); if (str.Length > 128) { str = str.Substring(0, 128); } if (str.Length <= 0) { return; } if (str.StartsWith("/") || str.StartsWith("\\")) { if (Interface.CallHook("IOnPlayerCommand", arg) != null) { return; } return; } str = str.EscapeRichText(); if (Interface.CallHook("IOnPlayerChat", arg, str) != null) { return; } if (Chat.serverlog) { ServerConsole.PrintColoured(new object[] { ConsoleColor.DarkYellow, string.Concat(basePlayer.displayName, ": "), ConsoleColor.DarkGreen, str }); DebugEx.Log(string.Format("[CHAT] {0} : {1}", basePlayer.ToString(), str), StackTraceLogType.None); } string str1 = "#5af"; if (basePlayer.IsAdmin) { str1 = "#af5"; } if (basePlayer.IsDeveloper) { str1 = "#fa5"; } string str2 = basePlayer.displayName.EscapeRichText(); basePlayer.NextChatTime = UnityEngine.Time.realtimeSinceStartup + 1.5f; Chat.ChatEntry chatEntry = new Chat.ChatEntry() { Message = str, UserId = basePlayer.userID, Username = basePlayer.displayName, Color = str1, Time = Epoch.Current }; Chat.ChatEntry chatEntry1 = chatEntry; Chat.History.Add(chatEntry1); RCon.Broadcast(RCon.LogType.Chat, chatEntry1); if (ConVar.Server.globalchat) { ConsoleNetwork.BroadcastToAllClients("chat.add2", new object[] { basePlayer.userID, str, str2, str1, 1f }); arg.ReplyWith(""); return; } float single1 = 2500f; foreach (BasePlayer basePlayer1 in BasePlayer.activePlayerList) { Vector3 vector3 = basePlayer1.transform.position - basePlayer.transform.position; float single2 = vector3.sqrMagnitude; if (single2 > single1) { continue; } ConsoleNetwork.SendClientCommand(basePlayer1.net.connection, "chat.add2", new object[] { basePlayer.userID, str, str2, str1, Mathf.Clamp01(single1 - single2 + 0.2f) }); } arg.ReplyWith(""); }
public static void say(ConsoleSystem.Arg arg) { if (!Chat.enabled) { arg.ReplyWith("Chat is disabled."); } else { BasePlayer basePlayer = arg.Player(); if (!Object.op_Implicit((Object)basePlayer) || basePlayer.HasPlayerFlag(BasePlayer.PlayerFlags.ChatMute)) { return; } if (!basePlayer.IsAdmin && !basePlayer.IsDeveloper) { if ((double)basePlayer.NextChatTime == 0.0) { basePlayer.NextChatTime = Time.get_realtimeSinceStartup() - 30f; } if ((double)basePlayer.NextChatTime > (double)Time.get_realtimeSinceStartup()) { basePlayer.NextChatTime += 2f; float num = basePlayer.NextChatTime - Time.get_realtimeSinceStartup(); ConsoleNetwork.SendClientCommand(basePlayer.net.get_connection(), "chat.add", (object)0, (object)("You're chatting too fast - try again in " + (num + 0.5f).ToString("0") + " seconds")); if ((double)num <= 120.0) { return; } basePlayer.Kick("Chatting too fast"); return; } } string str1 = arg.GetString(0, "text").Trim(); if (str1.Length > 128) { str1 = str1.Substring(0, 128); } if (str1.Length <= 0) { return; } if (str1.StartsWith("/") || str1.StartsWith("\\")) { if (Interface.CallHook("IOnPlayerCommand", (object)arg) != null) { ; } } else { string str2 = StringEx.EscapeRichText(str1); if (Interface.CallHook("IOnPlayerChat", (object)arg) != null) { return; } if (Chat.serverlog) { ServerConsole.PrintColoured((object)ConsoleColor.DarkYellow, (object)(basePlayer.displayName + ": "), (object)ConsoleColor.DarkGreen, (object)str2); DebugEx.Log((object)string.Format("[CHAT] {0} : {1}", (object)((object)basePlayer).ToString(), (object)str2), (StackTraceLogType)0); } string str3 = "#5af"; if (basePlayer.IsAdmin) { str3 = "#af5"; } if (basePlayer.IsDeveloper) { str3 = "#fa5"; } string str4 = StringEx.EscapeRichText(basePlayer.displayName); basePlayer.NextChatTime = Time.get_realtimeSinceStartup() + 1.5f; Chat.ChatEntry chatEntry = new Chat.ChatEntry() { Message = str2, UserId = basePlayer.userID, Username = basePlayer.displayName, Color = str3, Time = Epoch.get_Current() }; Chat.History.Add(chatEntry); RCon.Broadcast(RCon.LogType.Chat, (object)chatEntry); if (Server.globalchat) { ConsoleNetwork.BroadcastToAllClients("chat.add2", (object)basePlayer.userID, (object)str2, (object)str4, (object)str3, (object)1f); arg.ReplyWith(""); } else { float num = 2500f; foreach (BasePlayer activePlayer in BasePlayer.activePlayerList) { Vector3 vector3 = Vector3.op_Subtraction(((Component)activePlayer).get_transform().get_position(), ((Component)basePlayer).get_transform().get_position()); float sqrMagnitude = ((Vector3) ref vector3).get_sqrMagnitude(); if ((double)sqrMagnitude <= (double)num) { ConsoleNetwork.SendClientCommand(activePlayer.net.get_connection(), "chat.add2", (object)basePlayer.userID, (object)str2, (object)str4, (object)str3, (object)Mathf.Clamp01((float)((double)num - (double)sqrMagnitude + 0.200000002980232))); } } arg.ReplyWith(""); } } } }
private bool OnPlayerChat(BasePlayer player, string message, Chat.ChatChannel channel) { if (Chat.serverlog) { ServerConsole.PrintColoured(ConsoleColor.DarkYellow, string.Concat("[", channel, "] ", player.displayName, ": "), ConsoleColor.DarkGreen, message); var str = (player != null ? player.ToString() : null) ?? $"{player.displayName}[{player.userID}]"; if (channel == Chat.ChatChannel.Team) { DebugEx.Log("[TEAM CHAT] " + str + " : " + message); } else { DebugEx.Log("[CHAT] " + str + " : " + message); } } var color = "#5af"; var displayName = player.displayName.EscapeRichText(); var chatEntry = new Chat.ChatEntry { Channel = channel, Message = message, UserId = player.UserIDString, Username = displayName, Color = color, Time = Epoch.Current }; RCon.Broadcast(RCon.LogType.Chat, chatEntry); if (channel != Chat.ChatChannel.Global) { if (channel == Chat.ChatChannel.Team) { var playerTeam = RelationshipManager.Instance.FindPlayersTeam(player.userID); if (playerTeam == null) { return(false); } var onlineMemberConnections = playerTeam.GetOnlineMemberConnections(); if (onlineMemberConnections != null) { ConsoleNetwork.SendClientCommand(onlineMemberConnections, "chat.add2", 1, player.userID, message, displayName, color, 1f); } playerTeam.BroadcastTeamChat(player.userID, displayName, message, color); return(true); } } else if (ConVar.Server.globalchat) { ConsoleNetwork.BroadcastToAllClients("chat.add2", 0, player.userID, message, displayName, color, 1f); return(true); } if (player == null) { return(true); } var radius = 2500f; foreach (var basePlayer in BasePlayer.activePlayerList) { var sqrMagnitude = (basePlayer.transform.position - player.transform.position).sqrMagnitude; if (sqrMagnitude <= radius) { ConsoleNetwork.SendClientCommand(basePlayer.net.connection, "chat.add2", 0, player.userID, message, displayName, color, Mathf.Clamp01(radius - sqrMagnitude + 0.2f)); } } return(true); }
private BetterChatMessage.CancelOptions SendBetterChatMessage(BetterChatMessage chatMessage) #endif { Dictionary <string, object> chatMessageDict = chatMessage.ToDictionary(); #if RUST chatMessageDict.Add("ChatChannel", chatchannel); #endif foreach (Plugin plugin in plugins.GetAll()) { object hookResult = plugin.CallHook("OnBetterChat", chatMessageDict); if (hookResult is Dictionary <string, object> ) { try { chatMessageDict = hookResult as Dictionary <string, object>; } catch (Exception e) { PrintError($"Failed to load modified OnBetterChat hook data from plugin '{plugin.Title} ({plugin.Version})':{Environment.NewLine}{e}"); continue; } } else if (hookResult != null) { return(BetterChatMessage.CancelOptions.BetterChatOnly); } } chatMessage = BetterChatMessage.FromDictionary(chatMessageDict); if (chatMessage.CancelOption != BetterChatMessage.CancelOptions.None) { return(chatMessage.CancelOption); } var output = chatMessage.GetOutput(); #if RUST BasePlayer basePlayer = chatMessage.Player.Object as BasePlayer; switch (chatchannel) { case Chat.ChatChannel.Team: RelationshipManager.PlayerTeam team = basePlayer.Team; if (team == null || team.members.Count == 0) { throw new InvalidOperationException("Chat channel is set to Team, however the player is not in a team."); } team.BroadcastTeamChat(basePlayer.userID, chatMessage.Player.Name, chatMessage.Message, chatMessage.UsernameSettings.Color); List <Network.Connection> onlineMemberConnections = team.GetOnlineMemberConnections(); if (onlineMemberConnections != null) { ConsoleNetwork.SendClientCommand(onlineMemberConnections, "chat.add", (int)chatchannel, chatMessage.Player.Id, output.Chat); } break; case Chat.ChatChannel.Cards: CardTable cardTable = basePlayer.GetMountedVehicle() as CardTable; if (cardTable == null /* || !cardTable.GameController.PlayerIsInGame(basePlayer) */) { throw new InvalidOperationException("Chat channel is set to Cards, however the player is not in a participating in a card game."); } List <Network.Connection> list = Facepunch.Pool.GetList <Network.Connection>(); foreach (CardPlayerData playerData in cardTable.GameController.playerData) { if (playerData.HasUser) { list.Add(BasePlayer.FindByID(playerData.UserID).net.connection); } } if (list.Count > 0) { ConsoleNetwork.SendClientCommand(list, "chat.add", (int)chatchannel, chatMessage.Player.Id, output.Chat); } Facepunch.Pool.FreeList(ref list); break; default: foreach (BasePlayer p in BasePlayer.activePlayerList.Where(p => !chatMessage.BlockedReceivers.Contains(p.UserIDString))) { p.SendConsoleCommand("chat.add", (int)chatchannel, chatMessage.Player.Id, output.Chat); } break; } #else foreach (IPlayer p in players.Connected.Where(p => !chatMessage.BlockedReceivers.Contains(p.Id))) { p.Message(output.Chat); } #endif #if RUST Puts($"[{chatchannel}] {output.Console}"); var chatEntry = new Chat.ChatEntry { Channel = chatchannel, Message = output.Console, UserId = chatMessage.Player.Id, Username = chatMessage.Player.Name, Color = chatMessage.UsernameSettings.Color, Time = Epoch.Current }; Chat.Record(chatEntry); RCon.Broadcast(RCon.LogType.Chat, chatEntry); #else Puts(output.Console); #endif return(chatMessage.CancelOption); }