public static void Broadcast(string message, string username = "******", string color = "#eee", ulong userid = 0) { if (Interface.CallHook("OnServerMessage", (object)message, (object)username, (object)color, (object)userid) != null) { return; } string str = StringEx.EscapeRichText(username); ConsoleNetwork.BroadcastToAllClients("chat.add", (object)0, (object)("<color=" + color + ">" + str + "</color> " + message)); Chat.ChatEntry chatEntry = new Chat.ChatEntry() { Message = message, UserId = userid, Username = username, Color = color, Time = Epoch.get_Current() }; Chat.History.Add(chatEntry); RCon.Broadcast(RCon.LogType.Chat, (object)chatEntry); }
public static void Broadcast(string message, string username = "******", string color = "#eee", ulong userid = 0L) { if (Interface.CallHook("OnServerMessage", message, username, color, userid) != null) { return; } string str = username.EscapeRichText(); object[] objArray = new object[] { 0, null }; objArray[1] = string.Concat(new string[] { "<color=", color, ">", str, "</color> ", message }); ConsoleNetwork.BroadcastToAllClients("chat.add", objArray); Chat.ChatEntry chatEntry = new Chat.ChatEntry() { Message = message, UserId = userid, Username = username, Color = color, Time = Epoch.Current }; Chat.ChatEntry chatEntry1 = chatEntry; Chat.History.Add(chatEntry1); RCon.Broadcast(RCon.LogType.Chat, chatEntry1); }
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(""); } } } }