Imperceptus
Wanderer
Status Page AccessLevel Coloring
Webstatus.cs
Color names based on rank. nothing special
Webstatus.cs
Color names based on rank. nothing special
Code:
using System;
using System.IO;
using System.Text;
using System.Collections;
using Server;
using Server.Network;
using Server.Guilds;
namespace Server.Misc
{
public class StatusPage : Timer
{
public static void Initialize()
{
new StatusPage().Start();
}
public StatusPage() : base( TimeSpan.FromSeconds( 5.0 ), TimeSpan.FromSeconds( 60.0 ) )
{
Priority = TimerPriority.FiveSeconds;
}
private static string Encode( string input )
{
StringBuilder sb = new StringBuilder( input );
sb.Replace( "&", "&" );
sb.Replace( "<", "<" );
sb.Replace( ">", ">" );
sb.Replace( "\"", """ );
sb.Replace( "'", "'" );
return sb.ToString();
}
protected override void OnTick()
{
if ( !Directory.Exists( "web" ) )
Directory.CreateDirectory( "web" );
using ( StreamWriter op = new StreamWriter( "web/status.html" ) )
{
op.WriteLine( "<html>" );
op.WriteLine( " <head>" );
op.WriteLine( " <title>RunUO Server Status</title>");
op.WriteLine( " </head>" );
op.WriteLine( " <body bgcolor=\"white\">" );
op.WriteLine( " <h1>RunUO Server Status</h1>" );
op.WriteLine( " Online clients:<br>" );
op.WriteLine( " <table width=\"100%\">" );
op.WriteLine( " <tr>" );
op.WriteLine( " <td bgcolor=\"black\"><font color=\"white\">Name</font></td><td bgcolor=\"black\"><font color=\"white\">Location</font></td><td bgcolor=\"black\"><font color=\"white\">Kills</font></td><td bgcolor=\"black\"><font color=\"white\">Karma / Fame</font></td>" );
op.WriteLine( " </tr>" );
foreach ( NetState state in NetState.Instances )
{
Mobile m = state.Mobile;
if ( m != null )
{
Guild g = m.Guild as Guild;
op.Write( " <tr><td>" );
switch (m.AccessLevel)
{
case AccessLevel.Player:
op.Write( "<font color = 000000>" );
break;
case AccessLevel.Counselor:
op.Write( "<font color = 000000>" );
break;
case AccessLevel.GameMaster :
op.Write( "<font color = 00FF00>" );
break;
case AccessLevel.Seer :
op.Write( "<font color = 0000FF>" );
break;
case AccessLevel.Administrator :
op.Write( "<font color = FF0000>" );
break;
}
if ( g != null )
{
op.Write( Encode( m.Name ) );
// Guild info you can remove or put // infront of line and it wont show it
op.Write( " [" );
string title = m.GuildTitle;
if ( title != null )
title = title.Trim();
else
title = "";
if ( title.Length > 0 )
{
op.Write( Encode( title ) );
op.Write( ", " );
}
// Guild info you can remove or put // infront of line and it wont show it
op.Write( Encode( g.Abbreviation ) );
// Guild info you can remove or put // infront of line and it wont show it
op.Write( ']' );
}
else
{
op.Write( Encode( m.Name ) );
}
op.Write( "</font></td><td>" );
op.Write( m.X );
op.Write( ", " );
op.Write( m.Y );
op.Write( ", " );
op.Write( m.Z );
op.Write( " (" );
op.Write( m.Map );
op.Write( ")</td><td>" );
op.Write( m.Kills );
op.Write( "</td><td>" );
op.Write( m.Karma );
op.Write( " / " );
op.Write( m.Fame );
op.WriteLine( "</td></tr>" );
}
}
op.WriteLine( " <tr>" );
op.WriteLine( " </table>" );
op.WriteLine( " </body>" );
op.WriteLine( "</html>" );
}
}
}
}