RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

webstatus&how to lıst names ın an order

slayer1ss

Sorceror
webstatus&how to lıst names ın an order

well ı thınk tıtle explaıns all thıs ıs my webstatus.cs and what ı wanna ask ıs ıf there ıs a way to lıst names ın an order lıke fırst staffs than players or ın an alphabetıc order and so ıf there ıs how??
Code:
using System;
using System.IO;
using System.Text;
using System.Net;
using System.Collections;
using System.Diagnostics;


using Server;
using Server.Network;
using Server.Guilds;
using Server.Items;
using Server.Accounting;

namespace Server.Misc
{
    public class StatusPage : Timer
    {
	public string FormatTimeSpan(TimeSpan ts)
	{
		return String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", ts.Days, ts.Hours % 24, ts.Minutes % 60, ts.Seconds % 60);
	}
	public static string FormatByteAmount(long totalBytes)
	{
	if (totalBytes > 1000000000)
		return String.Format("{0:F1} GB", (double)totalBytes / 1073741824);

	if (totalBytes > 1000000)
		return String.Format("{0:F1} MB", (double)totalBytes / 1048576);

	if (totalBytes > 1000)
		return String.Format("{0:F1} KB", (double)totalBytes / 1024);

		return String.Format("{0} Bytes", totalBytes);
	}
	public static void Initialize()
	{
		new StatusPage().Start();
	}
	public StatusPage()
            : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(10.0))
	{
		Priority = TimerPriority.FiveSeconds;
	}
	private static string Encode(string input)
	{
		StringBuilder sb = new StringBuilder(input);

		sb.Replace("&", "&");
		sb.Replace("<", "&lt;");
		sb.Replace(">", "&gt;");
		sb.Replace("\"", "&quot;");
		sb.Replace("'", "&apos;");

		return sb.ToString();
	}
	protected override void OnTick()
	{
		DateTime now = DateTime.Now;

	if (!Directory.Exists("web"))
		Directory.CreateDirectory("web");

	using (StreamWriter op = new StreamWriter("c:/Inetpub/vhosts/realmofdestiny.net/httpdocs/status.html"))
	{
		op.WriteLine("<html>");
		op.WriteLine("   <head>");
		op.WriteLine("       <br><p align=\"center\"><img align=\"center\" border=\"2\" border-color=\"FFFFFF\" src=\"http://img18.imageshack.us/img18/3092/logoa3xs.gif\" </p>");
		op.WriteLine("      <title>Renovatio Server Status</title>");
		op.WriteLine("   </head>");
		op.WriteLine("   <body bgcolor=\"black\">");
		op.WriteLine("      <h1><font color=\"steelblue\">Renovatio UO Server Status</h1>");
		op.WriteLine("       <table>");
		op.WriteLine("       <tr><td nowrap width=\"5%\"><font face=\"Verdana\" size=\"2\" color=\"maroon\"><b>Date & Time:</b> </font></td><td width=\"95%\"><font face=\"Verdana,Arial,Helvetica,sans-serif\" color=\"silver\" size=\"2\"><b>{0}</b></font></td></tr>", DateTime.Now.ToString());
		op.WriteLine("       <tr><td nowrap width=\"5%\"><font face=\"Verdana\" size=\"2\" color=\"maroon\"><b>Uptime:</b>      </font></td><td width=\"95%\"><font face=\"Verdana,Arial,Helvetica,sans-serif\" color=\"silver\" size=\"2\"><b>{0}</b></font></td></tr>", FormatTimeSpan(DateTime.Now - Clock.ServerStart));
		op.WriteLine("       <tr><td nowrap width=\"5%\"><font face=\"Verdana\" size=\"2\" color=\"maroon\"><b>Memory:</b>      </font></td><td width=\"95%\"><font face=\"Verdana,Arial,Helvetica,sans-serif\" color=\"silver\" size=\"2\"><b>{0}</b></font></td></tr>", FormatByteAmount(GC.GetTotalMemory(false)));
		op.WriteLine("       <tr><td width=\"5%\" height=\"15\"></td><td width=\"95%\" height=\"15\"></td></tr>");
		op.WriteLine("       <tr><td nowrap width=\"5%\"><font face=\"Verdana\" size=\"2\" color=\"maroon\"><b>Mobiles:</b>    </font></td><td width=\"95%\"><font face=\"Verdana,Arial,Helvetica,sans-serif\" color=\"silver\" size=\"2\"><b>{0}</b></font></td></tr>", World.Mobiles.Count.ToString());
		op.WriteLine("       <tr><td nowrap width=\"5%\"><font face=\"Verdana\" size=\"2\" color=\"maroon\"><b>Items:</b>      </font></td><td width=\"95%\"><font face=\"Verdana,Arial,Helvetica,sans-serif\" color=\"silver\" size=\"2\"><b>{0}</b></font></td></tr>", World.Items.Count.ToString());
	//op.WriteLine("       <tr><td nowrap width=\"5%\"><font face=\"Verdana\" size=\"2\" color=\"maroon\"><b>Moon Phase:</b> </font></td><td width=\"95%\"><font face=\"Verdana,Arial,Helvetica,sans-serif\" color=\"silver\" size=\"2\"><b>{0}</b></font></td></tr>", now.Hour.ToString());
		op.WriteLine("       </table>");

		op.WriteLine("       <table>");
		op.WriteLine("       <tr><td width=\"5%\" height=\"15\"></td><td width=\"95%\" height=\"15\"></td></tr>");
		op.WriteLine("       <tr><td nowrap width=\"5%\"><font face=\"Verdana\" size=\"2\" color=\"steelblue\"><b>Online clients:</b> </font></td><td width=\"95%\"><font face=\"Verdana,Arial,Helvetica,sans-serif\" color=\"goldenrod\" size=\"2\"><b>{0}</b></font></td></tr>", NetState.Instances.Count.ToString());
		op.WriteLine("       <table>");

		op.WriteLine("      <table width=\"100%\">");
		op.WriteLine("         <tr>");
		op.WriteLine("            <td bgcolor=\"maroon\"><font color=\"silver\"><b>Name</b></font></td><td bgcolor=\"maroon\"><font color=\"silver\"><b>Location</b></font></td><td bgcolor=\"maroon\"><font color=\"silver\"><b>Kills</b></font></td><td bgcolor=\"maroon\"><font color=\"silver\"><b>Karma / Fame</b></font></td>");
		op.WriteLine("         </tr>");
		op.WriteLine("         <font color=\"white\">");

		foreach (NetState state in NetState.Instances)
		{
			Mobile m = state.Mobile;

                    if (m != null)
                    {
                        Guild g = m.Guild as Guild;

                        op.Write("         <tr><td><b><font color=\"white\">");
                        
                        if (g != null)
                        {
			op.Write("<font color=\"white\">" + Encode(m.Name));
			op.Write(" [");

                            string title = m.GuildTitle;

                            if (title != null)
                                title = title.Trim();
                            else
                                title = "";

                            if (title.Length > 0)
                            {
                                op.Write(Encode(title));
                                op.Write(", ");
                            }
			op.Write(Encode(g.Abbreviation));
			op.Write(']');
                        }
                        else
                        {
			op.Write( Encode( m.Name ) );
                        }

                        op.Write("</b></td><td><font color=\"white\">");                       
                        op.Write("<b>");
		if ( m.Region != null )
		{
                        op.Write(m.Region.ToString());
		}
		else
		{
		op.Write("in Britannia");
		}
                        op.Write("</b></td><td><b><font color=\"white\">");
                        op.Write(m.Kills);
                        op.Write("</b></td><td><b><font color=\"white\">" );
                        op.Write(m.Karma);
                        op.Write(" / ");
                        op.Write(m.Fame);
                        op.WriteLine("<b></td></tr><font color=\"white\">" );
                    }
                }

                op.WriteLine("         <tr>");
                op.WriteLine("      </table>");
                op.WriteLine("   </body>");
                op.WriteLine("</html>");
            }
        }
    }
}
 

daat99

Moderator
Staff member
You'll have to loop twice, once add only staff and in the second time add the normal players.
 

A_Li_N

Knight
Code:
		private class NameComparer : IComparer
		{
			int IComparer.Compare( Object x, Object y )
			{
				if( x is Mobile && y is Mobile )
				{
					Mobile a = x as Mobile;
					Mobile b = y as Mobile;
					return( (new CaseInsensitiveComparer()).Compare( a.Name, b.Name ) );
				}
				return 0;
			}
		}
That's a comparer that you could use for ArrayList.Sort() that will alphabitize the ArrayList. I'll leave it up to you to modify your code to use an ArrayList though :)

You could probably also modify this comparer to sort the AccessLevel as well, putting higher AccessLevels first, then alphabitize the names.
 

Jeff

Lord
Download my In-Game Forum scripts(link is on my sig) and look for my DateSort class( its in ThreadEntry.cs, its a Comparer I wrote to sort things by date but also sorts stickies and announcements 1st, this removes the need to run through the loop 2 or 3 times to sort things the way you want them.
 
Top