Chucl

Member
ServUO Version
Publish Unknown
Ultima Expansion
None
C#:
   Line.Add(string.Format("[{0}]<basefont color=white{1}>{2}<basefont color=white> "
            ,System.DateTime.UtcNow.ToString("HH:mm:ss]"+"  "+"[d/M/y"),
             (Config.AutoColoredNames ? (item.Name.GetHashCode()>>8).ToString() : "FF8033"),
            Utility.FixHtml(" test,"+" "+item.Name +",test.")));

so the date and everything else appears white,

Utility.FixHtml(" test,"+" "+item.Name +",test."))); <--- i would like to add a color to that part of the code, thanks
 
Last edited:
The FixHtml method exists to take html tags and turn them into non-functioning html (to prevent players from engraving items with html).

The color argument for the basefont tag takes named system colors (red, blue, green, white, etc) as valid arguments as well as the standard hex notation #RRGGBB.

To avoid confusion, it's easier to use interpolated strings... here is a helper method that makes resetting the color back to white optional, and also fixes transparency issues;
C#:
        public static string SetColor(int color32, string str, bool reset)
        {
            var r = Math.Max(0x08, (color32 >> 16) & 0xFF);
            var g = Math.Max(0x08, (color32 >> 08) & 0xFF);
            var b = Math.Max(0x08, (color32 >> 00) & 0xFF);

            color32 = (r << 16) | (g << 08) | (b << 00);

            if (reset)
              return $"<BASEFONT COLOR=#{color32:X6}>{str}<BASEFONT COLOR=#FFFFFF>";

            return $"<BASEFONT COLOR=#{color32:X6}>{str}";
        }

Usage:
C#:
var red = SetColor(0xFF0000, item.Name, true);
var green = SetColor(0x00FF00, item.Name, true);
var blue = SetColor(0x0000FF, item.Name, true);
C#:
var red = SetColor(System.Drawing.Color.Red.ToArgb(), item.Name, true);
var green = SetColor(System.Drawing.Color.Green.ToArgb(), item.Name, true);
var blue = SetColor(System.Drawing.Color.Blue.ToArgb(), item.Name, true);
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back