1. Wulf

    Wulf Community Admin

    If you'd like to use colors in your plugins for making messages stand out in the server console, you can use the below code snippet and change the color to your liking. Just try not to go overboard by adding a rainbow of text. ;)
    Code:
    global.ServerConsole.PrintColoured(System.ConsoleColor.Yellow, "This is a yellow message, good for debug messages")
    Available colors:
    • Black, Blue, Cyan, DarkBlue, DarkCyan, DarkGray, DarkGreen, DarkMagenta, DarkRed, DarkYellow, Gray, Green, Magenta, Red, White, Yellow
    Source: https://msdn.microsoft.com/en-us/library/system.consolecolor(v=vs.110).aspx

    You could also use the old method, which limits you to white, yellow, and red, though the messages would go to the appropriate log file based on which one you use.

    White (normal):
    Code:
    UnityEngine.Debug.Log.methodarray[0]:Invoke(nil, util.TableToArray({ "Hello world!" }))
    Yellow (debug):
    Code:
    UnityEngine.Debug.LogWarning.methodarray[0]:Invoke(nil, util.TableToArray({ "Hello world!" }))
    Red (error):
    Code:
    UnityEngine.Debug.LogError.methodarray[0]:Invoke(nil, util.TableToArray({ "Hello world!" }))
     
  2. Where I can put it? :)
     
  3. that's only for plugin devs ;)
     
  4. Oh maan... Maybe you want to create plugin "Colors" to use colors in msg?:)
     
  5. There are some problems... You can not use a lot of colors , it just erases all messages in the chat (WebGL restrictions as I understand).
     
  6. Does not work? Doesnt give out an error but also doesnt work...
    Code:
    global.ServerConsole.PrintColoured(System.ConsoleColor.Green, "[Supply Signal]: Loaded!")
     
  7. Wulf

    Wulf Community Admin

    I haven't checked or tried it in months, so I'm not sure. You can dig into the Assembly-CSharp.dll and see what it looks like.
     
  8. This is what I found.
    Screenshot_9.png
     
  9. Wulf

    Wulf Community Admin

    So it looks to be the same.
     
  10. Am I doing something wrong?
     
  11. You might be, I just copy-pasted what you had in a test plugin and it's working as you posted it, are you sure it's in a position in the function that it's being called?
     
  12. it should be, I just replaced the print command which were at that position with exactly that
     
  13. Code:
    void printyellow(string msg)
            {
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine( msg);
                
                
                
            }
    Works Currently very well. For debugging , great.
     
  14. Wulf

    Wulf Community Admin

    Oxide provides methods for these already: LogWarning, LogError, PrintWarning, etc. This thread you posted in is from 2015 for Oxide 1.