/// <summary> Sends a chat message from the given player (e.g. regular player chat or /me) </summary> /// <remarks> Chat messages will increase player's total messages sent in /info, /// and count towards triggering automute for chat spamming </remarks> /// <remarks> Only players not ignoring the given player will see this message. </remarks> public static void MessageChat(ChatScope scope, Player source, string msg, object arg, ChatMessageFilter filter, bool relay = false) { Player[] players = PlayerInfo.Online.Items; ChatMessageFilter scopeFilter = scopeFilters[(int)scope]; bool counted = false; // Filter out bad words if (Server.Config.ProfanityFiltering) { msg = ProfanityFilter.Parse(msg); } OnChatEvent.Call(scope, source, msg, arg, ref filter, relay); foreach (Player pl in players) { if (Ignoring(pl, source)) { continue; } // Always show message to self too (unless ignoring self) if (pl != source) { if (!scopeFilter(pl, arg)) { continue; } if (filter != null && !filter(pl, arg)) { continue; } if (!counted) { source.TotalMessagesSent++; counted = true; } } else { // don't send PM back to self if (scope == ChatScope.PM) { continue; } } pl.Message(UnescapeMessage(pl, source, msg)); } source.CheckForMessageSpam(); }
public static void MessageChat(ChatScope scope, Player source, string msg, object arg, ChatMessageFilter filter, bool irc = false) { Player[] players = PlayerInfo.Online.Items; ChatMessageFilter scopeFilter = scopeFilters[(int)scope]; OnChatEvent.Call(scope, source, msg, arg, ref filter, irc); foreach (Player pl in players) { if (Ignoring(pl, source)) { continue; } // Always show message to self too (unless ignoring self) if (pl != source) { if (!scopeFilter(pl, arg)) { continue; } if (filter != null && !filter(pl, arg)) { continue; } } else { // don't send PM back to self if (scope == ChatScope.PM) { continue; } } pl.Message(UnescapeMessage(pl, source, msg)); } source.CheckForMessageSpam(); }