void OnPlayerChat(BasePlayer player, string message, Chat.ChatChannel channel) { if (LogChat() && channel.ToString() == "Global") { executeQuery("INSERT INTO server_log_chat (player_id, player_name, player_ip, chat_message, admin, time) VALUES (@0, @1, @2, @3, @4, @5)", player.userID, EncodeNonAsciiCharacters(player.displayName), player.net.connection.ipaddress, message, player.IsAdmin, getDateTime()); } if (LogTeamChat() && channel.ToString() == "Team") { executeQuery("INSERT INTO server_log_chat_team (player_id, player_name, player_ip, chat_message, admin, time) VALUES (@0, @1, @2, @3, @4, @5)", player.userID, EncodeNonAsciiCharacters(player.displayName), player.net.connection.ipaddress, message, player.IsAdmin, getDateTime()); } //if player ask after admin if (message.Contains("admin")) { if (LogAdminCall() == true) { executeQuery("INSERT INTO admin_log (player_id, player_name, player_ip, text, time) VALUES (@0, @1, @2, @3, @4)", player.userID, EncodeNonAsciiCharacters(player.displayName), player.net.connection.ipaddress, message, getDateTime() ); } } else //check message after keywords { string words = Config["_AdminLogWords"].ToString(); string[] word = words.Split(new char[] { ' ', ',', ';', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); foreach (string a in word) { //PrintWarning(word); if (message.Contains(a) && LogAdminCall() == true) { //PrintWarning(a); executeQuery("INSERT INTO admin_log (player_id, player_name, player_ip, text, time) VALUES (@0, @1, @2, @3, @4)", player.userID, EncodeNonAsciiCharacters(player.displayName), player.net.connection.ipaddress, message, getDateTime() ); } } } }
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); }
// On Player Chat // Called when the player sends chat to the server object OnPlayerChat(BasePlayer player, string message, Chat.ChatChannel channel) { CreateLogEntry("on_player_chat.log", new ResidentChatMessage(player, message, channel.ToString())); return(null); }