ChatLog() public static method

public static ChatLog ( string Sender, string Msg ) : void
Sender string
Msg string
return void
Exemplo n.º 1
0
        // chat.say()
        public static void Chat(ConsoleSystem.Arg arg)
        {
            if (arg.ArgsStr.StartsWith("\"/"))
            {
                Command(arg);
                return;
            }

            if (!chat.enabled)
            {
                arg.ReplyWith("Chat is disabled.");
            }
            else
            {
                if (arg.ArgsStr == "\"\"")
                {
                    return;
                }

                BasePlayer basePlayer = ArgExtension.Player(arg);
                if (!(bool)((UnityEngine.Object)basePlayer))
                {
                    return;
                }

                Chat pChat = new Chat(new Player(basePlayer), arg);

                string str = arg.GetString(0, "text");

                if (str.Length > 128)
                {
                    str = str.Substring(0, 128);
                }

                if (chat.serverlog)
                {
                    Debug.Log((object)(basePlayer.displayName + ": " + str));
                }

                OnChat.OnNext(pChat);

                if (pChat.FinalText != "")
                {
                    ConsoleSystem.Broadcast("chat.add " + StringExtensions.QuoteSafe(pChat.BroadcastName) + " " + StringExtensions.QuoteSafe(pChat.FinalText));
                    arg.ReplyWith(pChat.ReplyWith);
                }

                Logger.ChatLog(pChat.BroadcastName, pChat.FinalText);
            }
        }
Exemplo n.º 2
0
        public static void On_Chat(ConsoleSystem.Arg arg)
        {
            if (arg.ArgsStr.StartsWith("\"/") && !arg.ArgsStr.StartsWith("\"/ "))
            {
                On_Command(arg);
                return;
            }

            if (!ConVar.Chat.enabled)
            {
                arg.ReplyWith("Chat is disabled.");
            }
            else
            {
                if (arg.ArgsStr == "\"\"")
                {
                    return;
                }

                BasePlayer basePlayer = arg.Player();
                if (!basePlayer)
                {
                    return;
                }

                ChatEvent pChat = new ChatEvent(Server.GetPlayer(basePlayer), arg);

                string str = arg.GetString(0, "text");

                if (str.Length > 128)
                {
                    str = str.Substring(0, 128);
                }

                if (str.Length <= 0)
                {
                    return;
                }


                if (ConVar.Chat.serverlog)
                {
                    ServerConsole.PrintColoured(new object[] {
                        ConsoleColor.DarkYellow,
                        basePlayer.displayName + ": ",
                        ConsoleColor.DarkGreen,
                        str
                    });
                    ConVar.Server.Log("Log.Chat.txt", string.Format("{0}/{1}: {2}\r\n", basePlayer.userID, basePlayer.displayName, str));
                    Debug.Log(string.Format("[CHAT] {0}: {1}", basePlayer.displayName, str));
                }

                string arg2 = "#5af";
                if (basePlayer.IsAdmin())
                {
                    arg2 = "#af5";
                }

                if (DeveloperList.IsDeveloper(basePlayer))
                {
                    arg2 = "#fa5";
                }

                OnNext("On_Chat", pChat);

                string text2 = string.Format("<color={2}>{0}</color>: {1}", basePlayer.displayName.Replace('<', '[').Replace('>', ']'), pChat.FinalText, arg2);

                if (pChat.FinalText != "")
                {
                    Logger.ChatLog(pChat.BroadcastName, pChat.OriginalText);
                    arg.ReplyWith(pChat.Reply);

                    if (ConVar.Server.globalchat)
                    {
                        ConsoleSystem.Broadcast("chat.add", basePlayer.userID, text2, 1);
                    }
                    else
                    {
                        float num = 2500;
                        foreach (Connection current in Net.sv.connections)
                        {
                            if (current.player != null)
                            {
                                float sqrMagnitude = (current.player.transform.position - basePlayer.transform.position).sqrMagnitude;
                                if (sqrMagnitude <= num)
                                {
                                    ConsoleSystem.SendClientCommand(current, "chat.add", basePlayer.userID, text2, Mathf.Clamp01(num - sqrMagnitude + 0.2f));
                                }
                            }
                        }
                    }
                }
            }
        }