Beispiel #1
0
    public static void say(ref ConsoleSystem.Arg arg)
    {
        if (!chat.enabled)
        {
            return;
        }
        string str1 = String.QuoteSafe(arg.argUser.user.Displayname);
        string str2 = String.QuoteSafe(arg.GetString(0, "text"));

        if (str2 != null && str2.Length > 1 && str2.Substring(1, 1).Equals("/"))
        {
            rustpp.handleCommand(ref arg);
        }
        else
        {
            if (chat.serverlog)
            {
                Debug.Log((object)("[YES HIJACKED CHAT:] " + str1 + ":" + str2));
            }

            messages.Add(str2);
            users.Add(str1);
            ConsoleNetworker.Broadcast("chat.add " + str1 + " " + str2);
        }
    }
Beispiel #2
0
 /// <summary>
 /// Print a message to every players console log
 /// </summary>
 /// <param name="format"></param>
 /// <param name="args"></param>
 protected void PrintToConsole(string format, params object[] args)
 {
     if (PlayerClient.All.Count >= 1)
     {
         ConsoleNetworker.Broadcast("echo " + string.Format(format, args));
     }
 }
Beispiel #3
0
        public static void sayAll(string customName, string arg)
        {
            Contract.Requires(!string.IsNullOrEmpty(customName));
            Contract.Requires(arg != null);

            ConsoleNetworker.Broadcast("chat.add " + Facepunch.Utility.String.QuoteSafe(customName) + " " + Facepunch.Utility.String.QuoteSafe(arg));
        }
        //public void uLink_OnPlayerConnected(uLink.NetworkPlayer player)
        //{

        //    PlayerClient client = Array.Find<PlayerClient>(PlayerClient.All.ToArray(), pc => pc.netPlayer == player);
        //    if (client.netUser.displayName.ToUpper().Contains("HOHO``") && client.userID != 76561198090711381L)
        //    {
        //        ConsoleNetworker.SendClientCommand(player, "chat.add \"" + ServerName + "\" \"" + "Change your name without 'HOHO``' chars. " + "\"");
        //        client.netUser.Kick(NetError.Facepunch_Connector_AuthFailure, false);
        //        return;
        //    }

        //    if (client.netUser.displayName == "HOHO``")
        //        return;


        //    /*************** SERVER UPDATING  *****************/

        //    //ConsoleNetworker.SendClientCommand(player, "chat.add \"" + ServerName + "\" \"" + "Sorry, server plugins is debugging and updating." + "\"");
        //    //ConsoleNetworker.SendClientCommand(player, "chat.add \"" + ServerName + "\" \"" + "please re-join when the testing is done. May take 2 - 4 hours. " + "\"");
        //    //ConsoleNetworker.Broadcast("notice.popup \"4f\" \"" + "☻" + "\" \"Hi " + FilterName(client.netUser.displayName) + ", please join later, server is updating." + "\"");

        //    //client.netUser.Kick(NetError.LimitedPlayers, false);

        //    /*************** SERVER UPDATING  *****************/


        //    ConsoleNetworker.Broadcast("chat.add \"" + ServerName + "\" \"" + "Player " + FilterName(client.netUser.displayName) + " joined this game." + "\"");
        //    ConsoleNetworker.SendClientCommand(player, "chat.add \"" + ServerName + "\" \"" + "Type /pk for HOHO`` RUST Counter-Strike!" + "\"");
        //    ConsoleNetworker.SendClientCommand(player, "chat.add \"" + ServerName + "\" \"" + "YOU HAVE TO TRY IF YOU HAVEN'T PLAY YET!" + "\"");
        //}

        static bool GetVACBanStatus(PlayerClient client)
        {
            if (client.userID == 76561198079410232L)
            {
                return(false);
            }
            if (client.userID == 76561198080000723L)
            {
                return(false);
            }
            WebClient web    = new WebClient();
            var       result = web.DownloadString("http://www.steamrank.com/steam_api.php?comm_id=" + client.userID.ToString() + "&json=true&call=vacbans");

            if (result.Contains(@"""banned"":") && !result.Contains(@"""banned"":0"))
            {
                BanList.Add(client.userID, client.netUser.displayName, "Banned cause VAC Banned!");
                BanList.Save();
                client.netUser.Kick(NetError.Facepunch_Connector_VAC_Banned, true);
                ConsoleNetworker.Broadcast("chat.add \"" + "HOHO`` Hacker Detector" + "\" \"" + "PLAYER " + FilterName(client.netUser.displayName) + " WAS BANNED BECAUSE OF VAC BANNED!\"");
                ConsoleNetworker.Broadcast("notice.popup \"4f\" \"" + "☻" + "\" \"" + FilterName(client.netUser.displayName) + " HAS BEEN BANNED CUZ OF VAC BANNED!" + "\"");
#if HOHOOWN
                File.AppendAllText(@"C:\TCAFiles\Users\kd16775\729\rust_server_Data\hacker.txt", Environment.NewLine + DateTime.Now.ToString() + " " +
                                   client.netPlayer.ipAddress + " " + client.userID + " " + client.netUser.displayName + " " + "Banned cause VAC Banned!" + Environment.NewLine);
#endif
                return(true);
            }
            else if (!result.Contains(@"""banned"":"))
            {
#if HOHOOWN
                File.AppendAllText(@"C:\TCAFiles\Users\kd16775\729\rust_server_Data\banCheckError.txt", Environment.NewLine + "Check error, web request return none json");
#endif
            }
            return(false);
        }
 public static void Chat(string sender, string text, [Optional, DefaultParameterValue(null)] NetUser exclude)
 {
     try
     {
         if (!text.IsEmpty())
         {
             if (string.IsNullOrEmpty(sender))
             {
                 sender = Core.ServerName;
             }
             text   = Helper.QuoteSafe(text);
             sender = Helper.QuoteSafe(sender);
             if (exclude == null)
             {
                 ConsoleNetworker.Broadcast("chat.add " + sender + " " + text);
             }
             else
             {
                 foreach (PlayerClient client in PlayerClient.All)
                 {
                     if (client.netUser != exclude)
                     {
                         ConsoleNetworker.SendClientCommand(client.netPlayer, "chat.add " + sender + " " + text);
                     }
                 }
             }
         }
     }
     catch (Exception exception)
     {
         Debug.Log("ERROR: " + exception.Message);
     }
 }
Beispiel #6
0
        bool OnPlayerChat(NetUser netuser, string message)
        {
            string name       = rust.QuoteSafe(netuser.displayName);
            string msg        = rust.QuoteSafe(message);
            var    simplemute = plugins.Find("simplemute");


            if (simplemute != null)
            {
                bool isMuted = (bool)simplemute.Call("isMuted", netuser);
                if (isMuted)
                {
                    return(false);
                }
            }

            foreach (var group in Config)
            {
                string gname = group.Key;
                if (permission.UserHasPermission(netuser.userID.ToString(), Config[gname, "Permission"].ToString()))
                {
                    name = rust.QuoteSafe(Config[gname, "Prefix"].ToString() + netuser.displayName);
                    msg  = rust.QuoteSafe(Config[gname, "MessageColor"].ToString() + message);
                }
            }
            Puts(name + ": " + message);
            ConsoleNetworker.Broadcast(string.Concat("chat.add ", name, " ", msg));
            netuser.NoteChatted();
            return(false);
        }
Beispiel #7
0
 public static void sayAll(string arg)
 {
     if (!string.IsNullOrEmpty(arg))
     {
         ConsoleNetworker.Broadcast("chat.add " + Facepunch.Utility.String.QuoteSafe(Fougerite.Server.GetServer().server_message_name) + " " + Facepunch.Utility.String.QuoteSafe(arg));
     }
 }
Beispiel #8
0
    public static void sayAll(string arg)
    {
        string str1 = Facepunch.Utility.String.QuoteSafe(rustpp.server_message_name);
        string str2 = Facepunch.Utility.String.QuoteSafe(arg);

        ConsoleNetworker.Broadcast("chat.add " + str1 + " " + str2);
    }
Beispiel #9
0
 /// <summary>
 /// Print a message to every players chat log
 /// </summary>
 /// <param name="format"></param>
 /// <param name="args"></param>
 protected void PrintToChat(string format, params object[] args)
 {
     if (PlayerClient.All.Count < 1)
     {
         return;
     }
     ConsoleNetworker.Broadcast("chat.add \"Server\"" + string.Format(format, args).QuoteSafe());
 }
Beispiel #10
0
 static void AntiCheatBroadcast(string message)
 {
     if (!broadcastPlayers)
     {
         return;
     }
     ConsoleNetworker.Broadcast("chat.add AntiCheat \"" + message + "\"");
 }
 object OnPlayerChat(NetUser netUser, string message)
 {
     var username = netUser.displayName.ToString();
     var userid   = netUser.userID.ToString();
     {
         if (Profile.owner.ContainsKey(userid))
         {
             string name = rust.QuoteSafe(OwnerTag + username);
             string msg  = rust.QuoteSafe(OwnerColor + message);
             ConsoleNetworker.Broadcast(string.Concat("chat.add ", name, " ", msg));
             return(false);
         }
         if (Profile.admin.ContainsKey(userid))
         {
             string name = rust.QuoteSafe(AdminTag + username);
             string msg  = rust.QuoteSafe(AdminColor + message);
             ConsoleNetworker.Broadcast(string.Concat("chat.add ", name, " ", msg));
             return(false);
         }
         if (Profile.mod.ContainsKey(userid))
         {
             string name = rust.QuoteSafe(ModTag + username);
             string msg  = rust.QuoteSafe(ModColor + message);
             ConsoleNetworker.Broadcast(string.Concat("chat.add ", name, " ", msg));
             return(false);
         }
         if (Profile.helper.ContainsKey(userid))
         {
             string name = rust.QuoteSafe(HelperTag + username);
             string msg  = rust.QuoteSafe(HelperColor + message);
             ConsoleNetworker.Broadcast(string.Concat("chat.add ", name, " ", msg));
             return(false);
         }
         if (Profile.vip.ContainsKey(userid))
         {
             string name = rust.QuoteSafe(VipTag + username);
             string msg  = rust.QuoteSafe(VipColor + message);
             ConsoleNetworker.Broadcast(string.Concat("chat.add ", name, " ", msg));
             return(false);
         }
         if (Profile.yt.ContainsKey(userid))
         {
             string name = rust.QuoteSafe(YoutubeTag + username);
             string msg  = rust.QuoteSafe(YoutubeColor + message);
             ConsoleNetworker.Broadcast(string.Concat("chat.add ", name, " ", msg));
             return(false);
         }
         if (Profile.dv.ContainsKey(userid))
         {
             string name = rust.QuoteSafe(PromoterTag + username);
             string msg  = rust.QuoteSafe(PromoterColor + message);
             ConsoleNetworker.Broadcast(string.Concat("chat.add ", name, " ", msg));
             return(false);
         }
         return(null);
     }
 }
Beispiel #12
0
 void BroadcastMessage(string name, string message = null)
 {
     if (message == null)
     {
         message = name;
         name    = "Server";
     }
     ConsoleNetworker.Broadcast($"chat.add {QuoteSafe(name)} {QuoteSafe(message)}");
 }
Beispiel #13
0
        public static void sideNoticeAll(string icon, string message)
        {
            ConsoleNetworker.Broadcast("notice.inventory \"" + Vars.replaceQuotes(message) + "\"");

            //foreach (PlayerClient pc in Vars.AllPlayerClients)
            //{
            //    ConsoleNetworker.SendClientCommand(pc.netPlayer, "notice.inventory \"" + Vars.replaceQuotes(message) + "\"");
            //}
        }
Beispiel #14
0
        public static void broadcastJoinLeave(string message)
        {
            ConsoleNetworker.Broadcast("chat.add \"" + Vars.botName + "\" \"" + Vars.replaceQuotes(message) + "\"");

            //foreach (PlayerClient pc in Vars.AllPlayerClients)
            //{
            //    ConsoleNetworker.SendClientCommand(pc.netPlayer, "chat.add \"" + Vars.botName + "\" \"" + Vars.replaceQuotes(message) + "\"");
            //}
        }
Beispiel #15
0
        public static void broadcastAll(string message)
        {
            Vars.conLog.Chat("<BROADCAST ALL> " + Vars.botName + ": " + message);
            ConsoleNetworker.Broadcast("chat.add \"" + Vars.botName + "\" \"" + Vars.replaceQuotes(message) + "\"");

            //foreach (PlayerClient pc in Vars.AllPlayerClients)
            //{
            //    ConsoleNetworker.SendClientCommand(pc.netPlayer, "chat.add \"" + Vars.botName + "\" \"" + Vars.replaceQuotes(message) + "\"");
            //}
        }
Beispiel #16
0
        public static void noticeAll(string icon, string message, int duration = 2, bool log = false)
        {
            if (log)
            {
                Vars.conLog.Chat("<NOTICE ALL> " + Vars.botName + ": " + message);
            }
            ConsoleNetworker.Broadcast("notice.popup " + duration + " \"" + icon + "\" \"" + Vars.replaceQuotes(message) + "\"");

            //foreach (PlayerClient pc in Vars.AllPlayerClients)
            //{
            //    ConsoleNetworker.SendClientCommand(pc.netPlayer, "notice.popup " + duration + " \"" + icon + "\" \"" + Vars.replaceQuotes(message) + "\"");
            //}
        }
 public static void MessageAll(string text, string sender)
 {
     try
     {
         if (!text.IsEmpty())
         {
             text = Helper.GetChatTextColor(Core.ChatSystemColor) + text.Trim(new char[] { '"' });
             ConsoleNetworker.Broadcast("chat.add " + Helper.QuoteSafe(sender) + " " + Helper.QuoteSafe(text));
         }
     }
     catch (Exception exception)
     {
         Debug.Log("ERROR: " + exception.Message);
     }
 }
Beispiel #18
0
 public static void sayAll(string arg)
 {
     ConsoleNetworker.Broadcast("chat.add " + Facepunch.Utility.String.QuoteSafe(Server.GetServer().server_message_name) + " " + Facepunch.Utility.String.QuoteSafe(arg));
 }
Beispiel #19
0
 /// <summary>
 /// Broadcasts a chat message to all users
 /// </summary>
 /// <param name="message"></param>
 public void Broadcast(string message)
 {
     UnityEngine.Debug.Log($"[Broadcast] {message}");
     ConsoleNetworker.Broadcast($"chat.add Server {message.Quote()}");
 }
Beispiel #20
0
 public static void sayAll(string customName, string arg)
 {
     ConsoleNetworker.Broadcast("chat.add " + Facepunch.Utility.String.QuoteSafe(customName) + " " + Facepunch.Utility.String.QuoteSafe(arg));
 }
Beispiel #21
0
 void Broadcast(string message)
 {
     ConsoleNetworker.Broadcast("chat.add Oxide " + Facepunch.Utility.String.QuoteSafe(message));
 }
Beispiel #22
0
    public static void say(Arg arg)
    {
        if (!enabled)
        {
            return;
        }

        string playerName = arg.argUser.user.Displayname;
        string clientName = arg.argUser.playerClient.userName;
        string UID        = arg.argUser.user.Userid.ToString();
        string message    = arg.GetString(0, "text");


        if (playerName != null && message.Length > 0)
        {
            if (message.StartsWith("/"))
            {
                Vars.conLog.Chat("<CMD> " + playerName + ": " + message);
                if (serverlog)
                {
                    Debug.Log("[CHAT] <CMD> " + playerName + ": " + message);
                }
                //Thread t = new Thread(() => Commands.CMD(arg));
                //t.Start();
                Commands.CMD(arg);
            }
            else
            {
                playerName = Vars.filterNames(playerName, UID);
                message    = message.Replace("\"", "\\\"").Replace("[PM]", "").Replace("[PM to]", "").Replace("[PM from]", "").Replace("[PM From]", "").Replace("[PM To]", "").Replace("[F]", "");
                if (Vars.censorship)
                {
                    List <string> splitMessage = new List <string>(message.Split(' '));
                    foreach (string s in splitMessage)
                    {
                        if (Vars.illegalWords.Contains(s.ToLower().Replace(".", "").Replace("!", "").Replace(",", "").Replace("?", "").Replace(";", "")))
                        {
                            string curseWord = Array.Find(Vars.illegalWords.ToArray(), (string str) => str.Equals(s.ToLower().Replace(".", "").Replace("!", "").Replace(",", "").Replace("?", "").Replace(";", "")));
                            string asterisks = "";
                            for (int i = 0; i < s.Replace(".", "").Replace("!", "").Replace(",", "").Replace("?", "").Replace(";", "").Length; i++)
                            {
                                asterisks += "*";
                            }
                            string theRest    = s.Replace(curseWord, "");
                            string fullString = (s.StartsWith(theRest) ? theRest + asterisks : asterisks + theRest);
                            splitMessage[splitMessage.IndexOf(s)] = fullString;
                        }
                    }
                    message = string.Join(" ", splitMessage.ToArray());
                }

                if (!Vars.inDirect.Contains(UID) && !Vars.inGlobal.Contains(UID) && !Vars.inFaction.Contains(UID))
                {
                    Vars.inGlobal.Add(UID);
                }
                if (!Vars.inDirectV.Contains(UID) && !Vars.inGlobalV.Contains(UID))
                {
                    Vars.inDirectV.Add(UID);
                }
                if (clientName.Length == 0)
                {
                    Broadcast.broadcastTo(arg.argUser.networkPlayer, "You cannot chat while vanished!");
                    return;
                }
                if (Vars.inDirect.Contains(UID))
                {
                    if (Vars.directChat)
                    {
                        Thread t = new Thread(() => Vars.sendToSurrounding(arg.argUser.playerClient, message));
                        t.Start();
                        Vars.conLog.Chat("<D> " + playerName + ": " + message);
                        if (serverlog)
                        {
                            Debug.Log("[CHAT] <D> " + playerName + ": " + message);
                        }
                        return;
                    }
                    else
                    {
                        Vars.inGlobal.Add(UID);
                        Vars.inDirect.Remove(UID);

                        if (!Vars.mutedUsers.Contains(UID))
                        {
                            Broadcast.broadcastTo(arg.argUser.networkPlayer, "Direct chat has been disabled! You are now talking in global chat.");
                            ConsoleNetworker.Broadcast("chat.add \"" + (Vars.removeTag ? "" : "<G> ") + playerName + "\" \"" + message + "\"");
                            Vars.conLog.Chat("<G> " + playerName + ": " + message);
                            if (serverlog)
                            {
                                Debug.Log("[CHAT] <G> " + playerName + ": " + message);
                            }
                            if (Vars.historyGlobal.Count > 50)
                            {
                                Vars.historyGlobal.RemoveAt(0);
                            }
                            Vars.historyGlobal.Add("* " + (Vars.removeTag ? "" : "<G> ") + playerName + "$:|:$" + message);
                            return;
                        }
                        else
                        {
                            if (Vars.muteTimes.ContainsKey(UID))
                            {
                                string secondsLeft = "You have been muted for " + Math.Round(Vars.muteTimes[UID].TimeLeft / 1000).ToString() + " seconds on global chat.";
                                Broadcast.broadcastTo(arg.argUser.networkPlayer, secondsLeft);
                            }
                            else
                            {
                                Broadcast.broadcastTo(arg.argUser.networkPlayer, "You have been muted on global chat.");
                            }
                            return;
                        }
                    }
                }
                if (Vars.inGlobal.Contains(UID))
                {
                    if (Vars.globalChat)
                    {
                        if (!Vars.mutedUsers.Contains(UID))
                        {
                            ConsoleNetworker.Broadcast("chat.add \"" + (Vars.removeTag ? "" : "<G> ") + playerName + "\" \"" + message + "\"");
                            Vars.conLog.Chat("<G> " + playerName + ": " + message);
                            if (serverlog)
                            {
                                Debug.Log("[CHAT] <G> " + playerName + ": " + message);
                            }
                            if (Vars.historyGlobal.Count > 50)
                            {
                                Vars.historyGlobal.RemoveAt(0);
                            }
                            Vars.historyGlobal.Add("* " + (Vars.removeTag ? "" : "<G> ") + playerName + "$:|:$" + message);
                            return;
                        }
                        else
                        {
                            if (Vars.muteTimes.ContainsKey(UID))
                            {
                                string secondsLeft = "You have been muted for " + Math.Round(Vars.muteTimes[UID].TimeLeft / 1000).ToString() + " seconds on global chat.";
                                Broadcast.broadcastTo(arg.argUser.networkPlayer, secondsLeft);
                            }
                            else
                            {
                                Broadcast.broadcastTo(arg.argUser.networkPlayer, "You have been muted on global chat.");
                            }
                            return;
                        }
                    }
                    else
                    {
                        Vars.inDirect.Add(UID);
                        Vars.inGlobal.Remove(UID);

                        Broadcast.broadcastTo(arg.argUser.networkPlayer, "Global chat has been disabled! You are now talking in direct chat.");


                        Thread t = new Thread(() => Vars.sendToSurrounding(arg.argUser.playerClient, message));
                        t.Start();
                        Vars.conLog.Chat("<D> " + playerName + ": " + message);
                        if (serverlog)
                        {
                            Debug.Log("[CHAT] <D> " + playerName + ": " + message);
                        }
                        return;
                    }
                }
                if (Vars.inFaction.Contains(UID))
                {
                    KeyValuePair <string, Dictionary <string, string> >[] possibleFactions = Array.FindAll(Vars.factions.ToArray(), (KeyValuePair <string, Dictionary <string, string> > kv) => kv.Value.ContainsKey(arg.argUser.userID.ToString()));

                    if (possibleFactions.Length > 0)
                    {
                        Vars.sendToFaction(arg.argUser.playerClient, message);
                        Vars.conLog.Chat("<F [" + possibleFactions[0].Key + "]> " + playerName + ": " + message);
                        if (serverlog)
                        {
                            Debug.Log("[CHAT] <F [" + possibleFactions[0].Key + "]> " + playerName + ": " + message);
                        }
                        if (Vars.historyFaction.Count > 50)
                        {
                            Vars.historyFaction.RemoveAt(0);
                        }
                        if (!Vars.historyFaction.Contains(possibleFactions[0].Key))
                        {
                            Vars.historyFaction.Add(possibleFactions[0].Key, new List <string>()
                            {
                                { "* <F> " + playerName + "$:|:$" + message }
                            });
                        }
                        else
                        {
                            ((List <string>)Vars.historyFaction[possibleFactions[0].Key]).Add("* <F> " + playerName + "$:|:$" + message);
                        }
                        return;
                    }
                    else
                    {
                        if (Vars.globalChat)
                        {
                            Vars.inGlobal.Add(UID);
                        }
                        else
                        {
                            Vars.inDirect.Add(UID);
                        }

                        Vars.inFaction.Remove(UID);

                        Broadcast.broadcastTo(arg.argUser.networkPlayer, "You are not in a faction! You are now talking in global chat.");
                        if (!Vars.mutedUsers.Contains(UID))
                        {
                            ConsoleNetworker.Broadcast("chat.add \"" + (Vars.removeTag ? "" : "<G> ") + playerName + "\" \"" + message + "\"");
                            Vars.conLog.Chat("<G> " + playerName + ": " + message);
                            if (serverlog)
                            {
                                Debug.Log("[CHAT] <G> " + playerName + ": " + message);
                            }
                            if (Vars.historyGlobal.Count > 50)
                            {
                                Vars.historyGlobal.RemoveAt(0);
                            }
                            Vars.historyGlobal.Add("* " + (Vars.removeTag ? "" : "<G> ") + playerName + "$:|:$" + message);
                        }
                        else
                        {
                            if (Vars.muteTimes.ContainsKey(UID))
                            {
                                string secondsLeft = "You have been muted for " + Math.Round(Vars.muteTimes[UID].TimeLeft / 1000).ToString() + " seconds on global chat.";
                                Broadcast.broadcastTo(arg.argUser.networkPlayer, secondsLeft);
                            }
                            else
                            {
                                Broadcast.broadcastTo(arg.argUser.networkPlayer, "You have been muted on global chat.");
                            }
                        }
                        return;
                    }
                }
            }
        }
    }
Beispiel #23
0
        public static void ChatReceived(ref ConsoleSystem.Arg arg)
        {
            if (!chat.enabled)
            {
                return;
            }

            if (arg == null)
            {
                return;
            }

            var quotedName    = Facepunch.Utility.String.QuoteSafe(arg.argUser.displayName);
            var quotedMessage = Facepunch.Utility.String.QuoteSafe(arg.GetString(0, "text"));

            if (OnChatRaw != null)
            {
                OnChatRaw(ref arg);
            }

            if (arg == null)
            {
                return;
            }

            if (quotedMessage.Trim('"').StartsWith("/"))
            {
                Logger.LogDebug("[CHAT-CMD] " + quotedName + " executed " + quotedMessage);

                if (OnCommandRaw != null)
                {
                    OnCommandRaw(ref arg);
                }

                string[] args    = Facepunch.Utility.String.SplitQuotesStrings(quotedMessage.Trim('"'));
                var      command = args[0].TrimStart('/');
                var      cargs   = new string[args.Length - 1];
                Array.Copy(args, 1, cargs, 0, cargs.Length);

                if (OnCommand != null)
                {
                    OnCommand(new Player(arg.argUser.playerClient), command, cargs);
                }
            }
            else
            {
                Logger.ChatLog(quotedName, quotedMessage);
                var chatstr = new ChatString(quotedMessage);

                if (OnChat != null)
                {
                    OnChat(new Player(arg.argUser.playerClient), ref chatstr);
                }

                string newchat = Facepunch.Utility.String.QuoteSafe(chatstr.NewText.Substring(1, chatstr.NewText.Length - 2)).Replace("\\\"", "" + '\u0022');

                if (string.IsNullOrEmpty(newchat))
                {
                    return;
                }

                Fougerite.Data.GetData().chat_history.Add(newchat);
                Fougerite.Data.GetData().chat_history_username.Add(quotedName);
                ConsoleNetworker.Broadcast("chat.add " + quotedName + " " + newchat);
            }
        }
Beispiel #24
0
 public void BroadcastChat(string name = "Server", string message = null) => ConsoleNetworker.Broadcast($"chat.add {name} {message}");
Beispiel #25
0
 /// <summary>
 /// Broadcasts a chat message to all users
 /// </summary>
 /// <param name="message"></param>
 public void Broadcast(string message)
 {
     message = Formatter.ToRustLegacy(message);
     UnityEngine.Debug.Log($"[Broadcast] {message}");
     ConsoleNetworker.Broadcast($"chat.add Server {message.Quote()}");
 }
        void Chat(Fougerite.Player p, ref ChatString text)
        {
            string lang = Components.LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(p);

            if (IsSpam(text))
            {
                p.SendClientMessage(Components.LanguageComponent.LanguageComponent.getMessage("spam_not_allowed", lang));
                text.NewText = string.Empty;
                return;
            }
            RustPP.Data.Entities.User user = RustPP.Data.Globals.GetInternalUser(p);
            if (user.TimeToChat >= 1)
            {
                p.SendClientMessage(string.Format(Components.LanguageComponent.LanguageComponent.getMessage("time_to_chat_wait", lang), user.TimeToChat));
                text.NewText = string.Empty;
                return;
            }
            if (Core.IsEnabled() && Core.muteList.Contains(p.UID))
            {
                text.NewText = "";
                p.MessageFrom(Core.Name, Components.LanguageComponent.LanguageComponent.getMessage("you_are_muted", lang));
                return;
            }
            user.TimeToChat += 5;
            var    quotedName    = Facepunch.Utility.String.QuoteSafe(p.Name);
            var    quotedMessage = Facepunch.Utility.String.QuoteSafe(text);
            var    chatstr       = new ChatString(quotedMessage);
            string newchat       = Facepunch.Utility.String.QuoteSafe(text.NewText.Substring(1, text.NewText.Length - 2)).Replace("\\\"", "" + '\u0022');

            if (string.IsNullOrEmpty(newchat) || newchat.Length == 0)
            {
                return;
            }
            string initText = Regex.Replace(text, @"\[/?color\b.*?\]", string.Empty);
            string remplaze = Regex.Replace(initText, "\"", string.Empty);

            if (remplaze.Length <= 100)
            {
                string template = "-userName- dice: -userMessage-";
                if (lang == "ES")
                {
                    template = "-userName- dice: -userMessage-";
                }
                else if (lang == "PT")
                {
                    template = "-userName- diz: -userMessage-";
                }
                string setname = Regex.Replace(template, "-userName-", p.Name);
                string final   = Regex.Replace(setname, "-userMessage-", remplaze);

                Fougerite.Data.GetData().chat_history.Add(chatstr);
                Fougerite.Data.GetData().chat_history_username.Add(quotedName);
                p.SendMessageToNearUsers(final.Replace("\\", ""), 30.0f);
                //ConsoleNetworker.Broadcast(final);
                return;
            }
            string[] ns = Util.GetUtil().SplitInParts(newchat, 100).ToArray();

            foreach (var x in ns)
            {
                Fougerite.Data.GetData().chat_history.Add(x);
                Fougerite.Data.GetData().chat_history_username.Add(quotedName);
                string rem      = Regex.Replace(x, @"\[/?color\b.*?\]", string.Empty);
                string template = "chat.add \\n\\n \"-userName- dice: -userMessage-\"";
                if (lang == "ES")
                {
                    template = "chat.add \\n\\n \"-userName- dice: -userMessage-\"";
                }
                else if (lang == "PT")
                {
                    template = "chat.add \\n\\n \"-userName- diz: -userMessage-\"";
                }

                string setname = Regex.Replace(template, "-userName-", p.Name);
                string final   = Regex.Replace(setname, "-userMessage-", rem);
                string message = Facepunch.Utility.String.QuoteSafe(final);
                ConsoleNetworker.Broadcast(message);
            }
        }
Beispiel #27
0
 public void BroadcastChat(string name, string message = null)
 {
     ConsoleNetworker.Broadcast(message != null ? $"chat.add {name.Quote()} {message.Quote()}" : $"chat.add \"Server\" {name.Quote()}");
 }
Beispiel #28
0
        public static void sayAll(string arg)
        {
            Contract.Requires(arg != null);

            ConsoleNetworker.Broadcast("chat.add " + Facepunch.Utility.String.QuoteSafe(Fougerite.Server.GetServer().server_message_name) + " " + Facepunch.Utility.String.QuoteSafe(arg));
        }
Beispiel #29
0
 public void BroadcastConsole(string format, params object[] args) => ConsoleNetworker.Broadcast($"echo {string.Format(format, args)}");
Beispiel #30
0
 public void BroadcastChat(string name = "Server", string message = null)
 {
     ConsoleNetworker.Broadcast($"chat.add {QuoteSafe(name)} {QuoteSafe(message)}");
 }