Hi, i try to change the Item Color name (only the item name color) in Pre-AOS expansion (UOR expansion)
Any idea? I search and find some code but not work.

Thanks
 
What worked for me is overriding the default behavior of the OnSingleClick and sending this:
from.Send( new UnicodeMessage( item.Serial, item.ItemID, MessageType.Label, colorhere, 3, "", "", texthere));
 
What worked for me is overriding the default behavior of the OnSingleClick and sending this:
from.Send( new UnicodeMessage( item.Serial, item.ItemID, MessageType.Label, colorhere, 3, "", "", texthere));
Is good solution but... i added Rank in the Item.cs (Common, uncommon, rare, etc..) so... every item have a rank, my idea is change the color of the name item. For example, for the weapons with attrs (vanq, accurate, etc) this label (of the attrs) show in the normal color, no of the item rank.
 
Oh, you mean you wat one of the item's word to be colored and the rest normal?
Would you mind giving some examples of what you want to achieve?
 
I
Oh, you mean you wat one of the item's word to be colored and the rest normal?
Would you mind giving some examples of what you want to achieve?

All items have ItemRank (common) and, for example, if you get a weapon vanq, this weapon convert to the ItemRank.Rare, and when the user click, the name of the weapon is in blue color.

I see... the problem is in the OnSingleClick in BaseWeapon, when the item have LabelNumber (and no Name) then... put the labelnumber and the problem is when the server send the DisplayEquipmentInfo.

Sorry for my bad english
 
BaseWeapon.cs, OnSingleClick.
Code:
if (item.Name != null)
	name = item.Name;
else if (item.DefaultName != null)
	name = item.DefaultName;
else
	name = Cliloc.Convert(item.LabelNumber, null);

Code:
from.Send( new UnicodeMessage( item.Serial, item.ItemID, MessageType.Label, colorhere, 3, "", "", name));

Here's a class that will give you the name of any item.
Code:
using System;
using System.IO;
using System.Text;
using System.Collections;
using Server.Network;

namespace Server
{
    public static class Cliloc
    {
        public static void Configure()
        {
            Load();
        }

        private static readonly string m_ClilocFile = "Cliloc.enu";
       
        private static Hashtable m_Table;
       
        public static Hashtable Table
        {
            get { return m_Table; }
        }

        private static byte[] m_Buffer = new byte[1024];

        public static void Load()
        {
            Console.Write( "Cliloc: Loading..." );
           
            m_Table = new Hashtable();

            string path = Core.FindDataFile( m_ClilocFile );

            if ( path == null )
            {
                Console.WriteLine( "Cliloc file was not found" );
                Console.WriteLine( "Make sure your Scripts/Misc/DataPath.cs is properly configured" );
                Console.WriteLine( "After pressing return an exception will be thrown and the server will terminate" );

                throw new Exception( String.Format( "Cliloc: {0} not found", path ) );
            }

            using ( BinaryReader bin = new BinaryReader( new FileStream( path, FileMode.Open, FileAccess.Read, FileShare.Read ) ) )
            {
                bin.ReadInt32();
                bin.ReadInt16();

                while ( bin.BaseStream.Length != bin.BaseStream.Position )
                {
                    int number = bin.ReadInt32();
                    bin.ReadByte();
                    int length = bin.ReadInt16();

                    if ( length > m_Buffer.Length )
                        m_Buffer = new byte[(length + 1023) & ~1023];

                    bin.Read( m_Buffer, 0, length );
                    string text = Encoding.UTF8.GetString( m_Buffer, 0, length );

                    m_Table[number] = text;
                }
            }
           
            Console.WriteLine( "done" );
        }
       
        public static string Convert( int number, string args )
        {
            string result = (string)m_Table[number];
           
            if ( result == null )
                return String.Format( "Missing Cliloc: #{0}", number );
           
            if ( args == null || args == "" )
                return result;
           
            string[] split = args.Split( '\t' );
            StringBuilder resultBuilder = new StringBuilder( result );
           
            for ( int i = 0; i < split.Length; i++ )
            {
                int pos = result.IndexOf( String.Format( "~{0}_", i + 1 ) );
               
                if ( pos != -1 )
                {
                    int endPos = result.IndexOf( '~', pos + 1 );
                    string keyword = result.Substring( pos, endPos - pos + 1 );
                   
                    resultBuilder.Replace( keyword, split[i] );
                }
            }
           
            return resultBuilder.ToString();
        }
       
        public static string Convert( int number, string args, AffixType affixType, string affix )
        {
            bool append = ( ( affixType & AffixType.Prepend ) == 0 );
           
            StringBuilder resultBuilder = new StringBuilder( Convert( number, args ) );
           
            if ( append )
                resultBuilder.Append( affix );
            else
                resultBuilder.Insert( 0, affix );
           
            return resultBuilder.ToString();
        }
       
        public static string ConvertEquipmentInfo( Item item, EquipmentInfo info )
        {
            StringBuilder resultBuilder = new StringBuilder();
           
            bool crafted = false;
           
            if ( info.Crafter != null )
            {
                resultBuilder.AppendFormat( "Crafted by {0}", info.Crafter.Name );
                crafted = true;
            }
           
            if ( info.Attributes.Length != 0 )
            {
                if ( crafted )
                    resultBuilder.Append( ' ' );
               
                resultBuilder.Append( '[' );
               
                for ( int i = 0; i < info.Attributes.Length; i++ )
                {
                    if ( i != 0 )
                        resultBuilder.Append( '/' );
                   
                    EquipInfoAttribute attr = info.Attributes[i];
                   
                    resultBuilder.Append( Cliloc.Convert( attr.Number, null ) );
                   
                    if ( attr.Charges != -1 )
                        resultBuilder.AppendFormat( ": {0}", attr.Charges );
                }
               
                resultBuilder.Append( ']' );
            }
           
            return resultBuilder.ToString();
        }
    }
}

Sorry for the indentation.
Also this is a altered version of the original, i think i removed or added some stuffs.
 
Thanks for you help! :)

The problem with this... is the DisplayEquipmentInfo (Vanq, etc) is displaying first of name. The name display after the items property display ( from.Send( new DisplayEquipmentInfo(this, eqInfo)); <- this is the last line of the OnSingleClick in weapon)

Any way to change this?
 
Oh, i guess you could look at the source in the Server directory, look at Packet.cs, the DisplayEquipmentInfo class.
Personally i don't really understand the implications of a modification at this level and i don't work with pre-aos attributes, so i would opt for a different solution, by overriding it manually in the OnSingleClick of the baseweapon/etc.
To know the vanquishing level etc. I guess you would have to look at the BaseWeapon/BaseArmor/etc. classes.
ex: the field "m_DamageLevel" in BaseWeapon, i believe you can get the right cliloc file depending of the field content, which you could add as a prefix/suffix to your name printing.

For my part i created a class that handles that specifically, but only for the name; not for the attributes themselves.
 
Back