Code:
string msg = String.Format (  "{0} Gave you permission to hunt the head of  {1} .",
                        m_Entry.Owner.Name, m_Entry.Wanted.Name );

How to add ascii color to a message like that one?


Sorry for the noobish question
 
The easiest way is to use font tags in your string: <font color="red">text here</font>
Then, when you send the string to the user, you would have to send it as HTML.
 
Code:
string msg = String.Format ( <font color="WHITE" > "{0} Gave you permission to hunt the head of {1} ."</font> ,
                        m_Entry.Owner.Name, m_Entry.Wanted.Name );

Like this? it gives me errors, im doing it wrong, obviously:



Errors:
+ Custom/Adds/System/BountyBoard/EditBountyGump.c
CS1525: Line 176: Invalid expression term '<'
CS1026: Line 176: ) expected
CS1525: Line 176: Invalid expression term '/'
CS1002: Line 176: ; expected
CS1525: Line 176: Invalid expression term ','
CS1002: Line 176: ; expected
CS1002: Line 177: ; expected
CS1525: Line 177: Invalid expression term ','
CS1002: Line 177: ; expected
CS1002: Line 177: ; expected
CS1525: Line 177: Invalid expression term ')'
 
Code:
string msg = String.Format ( <font color="WHITE" > "{0} Gave you permission to hunt the head of {1} ."</font> ,
                        m_Entry.Owner.Name, m_Entry.Wanted.Name );

Like this? it gives me errors, im doing it wrong, obviously:



Errors:
+ Custom/Adds/System/BountyBoard/EditBountyGump.c
CS1525: Line 176: Invalid expression term '<'
CS1026: Line 176: ) expected
CS1525: Line 176: Invalid expression term '/'
CS1002: Line 176: ; expected
CS1525: Line 176: Invalid expression term ','
CS1002: Line 176: ; expected
CS1002: Line 177: ; expected
CS1525: Line 177: Invalid expression term ','
CS1002: Line 177: ; expected
CS1002: Line 177: ; expected
CS1525: Line 177: Invalid expression term ')'


Like this:

Code:
string msg = String.Format ( "<font color='WHITE'>{0} Gave you permission to hunt the head of {1} .</font>" ,
                        m_Entry.Owner.Name, m_Entry.Wanted.Name );
 
Is not working, i mean, the server compiles and all that, but the message has no color.

stringmsg.png

It is the same message, just translated it
 
Last edited:
Try using the hex numbers for the hue, not the name.
Code:
string msg = String.Format ( "<basefont color='ff0000'>{0} Gave you permission to hunt the head of {1} .</basefont>" ,
    m_Entry.Owner.Name, m_Entry.Wanted.Name );
 
On what are you trying to display the message? On the bottom left of the screen?
If that is so, you can simply use:
m.SendMessage(33, String.Format("stuff {0}", "bla"))

The basefont color is more for, say, changing the color of a hover menu item or the name of an item after clicking on it (pre-AOS style).
 
On what are you trying to display the message? On the bottom left of the screen?

.

Yes

Okey thank you, will try that
[doublepost=1475100641][/doublepost]
Code:
public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
        {
            int index = info.ButtonID;

            switch ( index )
            {
                case 0: // EXIT
                {
                    break;
                }
                case 1: // Previous page
                {
                    if ( m_Page > 0 )
                        m_From.SendGump( new EditBountyGump( m_From, m_Entry, m_Page - 1, m_Requested, m_Accepted ) );

                    break;
                }
                case 2: // Next page
                {
                    if ( ( GetIndexForPage( m_Page + 1 ) < m_Requested.Count ) ||
                        ( GetIndexForPage( m_Page + 1 ) < m_Accepted.Count ) )
                        m_From.SendGump( new EditBountyGump( m_From, m_Entry, m_Page + 1, m_Requested, m_Accepted ) );

                    break;
                }
                default:
                {
                    index -= 3;

                    int type = index % 1;
                    index /= 1;

                    if ( index < 0 || index >= m_Requested.Count )
                        break;

                    Mobile request = (Mobile) m_Requested[index];

                    m_Entry.Requested.Remove( request );
                    m_Entry.Accepted.Add( request );

            
                 
                    m.SendMessage(33, String.Format("{0} Gave you permission to hunt the head of  {1} ..", m_Entry.Owner.Name, m_Entry.Wanted.Name));
                    //string msg = String.Format (  "{0} Gave you permission to hunt the head of  {1} ..",
                    //    m_Entry.Owner.Name, m_Entry.Wanted.Name );

                    if( NetState.Instances.Contains( request.NetState ) )
                        request.SendMessage( msg );
                    else
                    {
                        (request as PlayerMobile).ShowBountyUpdate = true;
                        (request as PlayerMobile).BountyUpdateList.Add( msg );
                    }

                    m_From.SendGump( new EditBountyGump( m_From, m_Entry ) );

                    break;
                }
            }
        }


im getting errors:


Errors:
+ Custom/Adds/System/BountyBoard/EditBountyGump.cs:
CS0103: Line 177: The name 'm' does not exist in the current context
CS0103: Line 182: The name 'msg' does not exist in the current context
CS0103: Line 186: The name 'msg' does not exist in the current context


-----edit---------------------------------

changed it to m_From.SendMessage, still getting the msg errors:

CS0103: Line 182: The name 'msg' does not exist in the current context
CS0103: Line 186: The name 'msg' does not exist in the current context

.---------------------------------------------

Whole code:


Code:
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;

namespace Server.BountySystem
{
    public class EditBountyGump : Gump
    {
        private static int HtmlColor = 0xFFFFFF;
        private Mobile m_From;
        private BountyBoardEntry m_Entry;
        private int m_Page;

        private ArrayList m_Requested;
        private ArrayList m_Accepted;

        public EditBountyGump( Mobile from, BountyBoardEntry entry ) : this( from, entry, 0, null, null )
        {
        }
        public int GetIndexForPage( int page )
        {
            int index = 0;

            while ( page-- > 0 )
                index += 5;

            return index;
        }

        public string Color( string text, int color )
        {
            return String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text );
        }

        public EditBountyGump( Mobile from, BountyBoardEntry entry, int page, ArrayList requestList,
            ArrayList acceptList ) : base( 50, 50 )
        {
            if(entry == null)
                return;

            m_From = from;
            m_Entry = entry;
            m_Page = page;

            if ( requestList == null )
            {
                requestList = new ArrayList( entry.Requested.Count );

                for ( int i = 0; i < entry.Requested.Count; ++i )
                {
                    Mobile request = (Mobile) entry.Requested[i];
                    requestList.Add( request );
                }
            }

            m_Requested = requestList;

            if ( acceptList == null )
            {
                acceptList = new ArrayList( entry.Accepted.Count );

                for ( int i = 0; i < entry.Accepted.Count; ++i )
                {
                    Mobile accept = (Mobile) entry.Accepted[i];
                    acceptList.Add( accept );
                }
            }

            m_Accepted = acceptList;

            int index = GetIndexForPage( page );
            int count = 5;
            int tableIndex = 0;

            Closable=true;
            Disposable=true;
            Dragable=true;
            Resizable=false;

            AddPage(0);
            AddBackground(0, 0, 440, 324, 9200);
            AddHtml(160, 5, 200, 32, Color( "Editar", HtmlColor ), false, false );
            AddHtml(10, 32, 200, 32, Color( "Buscado", HtmlColor ), false, false );
            AddHtml(175, 32, 200, 32, Color( "Precio", HtmlColor ), false, false );
            AddHtml(260, 32, 200, 32, Color( "Caducidad", HtmlColor ), false, false );
            AddImageTiled( 10, 50, 400, 2, 2624 );

            AddHtml(10, 96, 200, 32, Color( "Solicitados", HtmlColor ), false, false );
            AddHtml(230, 96, 200, 32, Color( "Aprovados", HtmlColor ), false, false );
            AddImageTiled( 10, 115, 400, 2, 2624 );

            AddHtmlLocalized( 370, 290, 200, 32, 1011441, HtmlColor, false, false ); // exit
            AddButton(340, 290, 4017, 4018, 0, GumpButtonType.Reply, 0); // exit

            AddHtml( 10, 64, 200, 32, Color( m_Entry.Wanted.Name, HtmlColor ), false, false );
            AddHtml( 175, 64, 200, 32, Color( m_Entry.Price.ToString(), HtmlColor ), false, false );
            AddHtml( 260, 64, 200, 32, Color( m_Entry.ExpireTime.ToString(), HtmlColor ), false, false );

            if ( page > 0 )
            {
                AddHtmlLocalized( 60, 290, 150, 20, 1011067, HtmlColor, false, false ); // Previous page
                AddButton(30, 290, 4014, 4016, 1, GumpButtonType.Reply, 0);
            }

            if ( ( GetIndexForPage( page + 1 ) < m_Requested.Count ) ||
                ( GetIndexForPage( page + 1 ) < m_Accepted.Count ) )
            {
                AddHtmlLocalized( 230, 290, 150, 20, 1011066, HtmlColor, false, false ); // Next page
                AddButton(200, 290, 4005, 4007, 2, GumpButtonType.Reply, 0);
            }

            tableIndex = 0;

            for ( int i = index; i < (index + count) && i >= 0 && i < m_Requested.Count; ++i )
            {
                Mobile request = (Mobile) m_Requested[i];
                int y = 128 + (tableIndex++ * 32);
                AddButton(10, y, 2117, 2118, 3 + (i * 1), GumpButtonType.Reply, 0);
                AddHtml( 40, y, 200, 32, Color( request.Name, HtmlColor ), false, false );
            }

            tableIndex = 0;

            for ( int i = index; i < (index + count) && i >= 0 && i < m_Accepted.Count; ++i )
            {
                Mobile accept = (Mobile) m_Accepted[i];
                int y = 128 + (tableIndex++ * 32);
                AddHtml( 230, y, 200, 32, Color( accept.Name, HtmlColor ), false, false );
            }
        }

        public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
        {
            int index = info.ButtonID;

            switch ( index )
            {
                case 0: // EXIT
                {
                    break;
                }
                case 1: // Previous page
                {
                    if ( m_Page > 0 )
                        m_From.SendGump( new EditBountyGump( m_From, m_Entry, m_Page - 1, m_Requested, m_Accepted ) );

                    break;
                }
                case 2: // Next page
                {
                    if ( ( GetIndexForPage( m_Page + 1 ) < m_Requested.Count ) ||
                        ( GetIndexForPage( m_Page + 1 ) < m_Accepted.Count ) )
                        m_From.SendGump( new EditBountyGump( m_From, m_Entry, m_Page + 1, m_Requested, m_Accepted ) );

                    break;
                }
                default:
                {
                    index -= 3;

                    int type = index % 1;
                    index /= 1;

                    if ( index < 0 || index >= m_Requested.Count )
                        break;

                    Mobile request = (Mobile) m_Requested[index];

                    m_Entry.Requested.Remove( request );
                    m_Entry.Accepted.Add( request );

             
    
       
                    m.SendMessage(33, String.Format("{0} Gave you permission to hunt the head of  {1} ..", m_Entry.Owner.Name, m_Entry.Wanted.Name));
                    //string msg = String.Format (  "{0} Gave you permission to hunt the head of  {1} ..",
                    //    m_Entry.Owner.Name, m_Entry.Wanted.Name );

                    if( NetState.Instances.Contains( request.NetState ) )
                        request.SendMessage( msg );
                    else
                    {
                        (request as PlayerMobile).ShowBountyUpdate = true;
                        (request as PlayerMobile).BountyUpdateList.Add( msg );
                    }

                    m_From.SendGump( new EditBountyGump( m_From, m_Entry ) );

                    break;
                }
            }
        }
    }
}
 
Last edited:
Back