Chat prefixes

Discussion in 'Rust Development' started by NobodyFTW, Feb 23, 2015.

  1. Hi, :)

    Both my plugins have use a prefix for the chat messages, but some users rather not have a prefix at all, and have it only to show the message. I tried to make it that in case the prefix was disabled in the config file (with false as the value) then (in the code) it would simply call the chat function without the prefix argument, but it seems that the prefix is not optional (which I guess that worked in lua, although it does not in Python). Then I tried the prefix argument to simply be an empty string, this works but there is still a : character before the message, it's not that this bothers me but it bothers the people who just want to remove prefix.

    Is it possible to make the chat prefix argument optional for both rust.BroadcastChat() and rust.SendChatMessage()?

    Thanks in advance.
     
  2. Yes, just don't supply it BroadcastChat(message) or BroadcastChat(message, null, steamID) and the same for SendChatMessage:
    SendChatMessage(player, message) or SendChatMessage(player, message, null, steamID)

    Code:
            [LibraryFunction("BroadcastChat")]
            public void BroadcastChat(string name, string message = null, string userid = "0")
            {
                if (message != null)
                {
                    ConsoleSystem.Broadcast("chat.add", userid, string.Format("<color=orange>{0}:</color> {1}", name, message), 1.0);
                }
                else
                {
                    message = name;
                    ConsoleSystem.Broadcast("chat.add", userid, message, 1.0);
                }
            }        [LibraryFunction("SendChatMessage")]
            public void SendChatMessage(BasePlayer player, string name, string message = null, string userid = "0")
            {
                if (message != null)
                {
                    player.SendConsoleCommand("chat.add", userid, string.Format("<color=orange>{0}:</color> {1}", name, message), 1.0);
                }
                else
                {
                    message = name;
                    player.SendConsoleCommand("chat.add", userid, message, 1.0);
                }
            }
    
     
  3. Oh I see,
    What I did was i.e rust.SendChatMessage(message, steamid), that's why. :)
    Thanks!