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.cs

cfaust

Wanderer
WebStatus.cs

Okay, I know that there a lot of folks that already know how to do this; this is for the others that might want to change the appearance of their webstatus.

Example: http://faustrealms.servegame.com/RUOWeb/online/status.html

I told WebStatus.cs to use another directory so that RunUO is not under my web folder, I do this with the docs too, everything goes in to folder under my web folder.

Here is the code with the changes.

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( "<", "&lt;" );
   sb.Replace( ">", "&gt;" );
   sb.Replace( "\"", "&quot;" );
   sb.Replace( "'", "&apos;" );
   return sb.ToString();
  }
  protected override void OnTick()
  {
   //Not sure if this has to be modified, just make sure that you at least manually create the directory that you point this script to
   if ( !Directory.Exists( "web" ) )
	Directory.CreateDirectory( "web" );
   //use forward slashes or else your shard may crash the first time it writes that status.html page
   using ( StreamWriter op = new StreamWriter( "c:/www/RUOWeb/online/status.html" ) )
   {
	// This is the original code that had been slightly modified
	/*op.WriteLine( "<html>" );
	op.WriteLine( "   <head>" );
	op.WriteLine( "	  <title>FaustRealms.servegame.com - Characters Currently Online</title>");
	op.WriteLine( "   </head>" );
	op.WriteLine( "   <body bgcolor=\"white\">" );
	op.WriteLine( "	  <h1>The Realms of Faust<BR>Status - RunUO 1.0.0</h1>" );
	op.WriteLine( "	  Online Characters:<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>" );*/
	
	//This is the modification for the Realms of Faust using a back ground and a graphic
	op.WriteLine( "<html>" );
	op.WriteLine( " <head>" );
	op.WriteLine( "  <title>FaustRealms.servegame.com - Characters Currently Online</title>" );
	op.WriteLine( "</head>" );
	op.WriteLine( "  <body bgcolor=\"white\" background=\"parchment.gif\">" );
	op.WriteLine( "   <h1 align=\"center\"><img border=\"0\" src=\"banner1.GIF\" width=\"519\" height=\"83\"></h1>" );
	op.WriteLine( "   <h1 align=\"center\"><font face=\"Arial Narrow\" size=\"7\">Online Characters</font></h1>" );
	op.WriteLine( "  <table width=\"100%\">" );
	op.WriteLine( "   <tr>" );
	op.WriteLine( "	<td bgcolor=\"gray\"><font color=\"white\" face=\"Arial Narrow\" size=\"2\">Name</font></td><td bgcolor=\"gray\"><font color=\"white\" face=\"Arial Narrow\" size=\"2\">Location</font></td><td bgcolor=\"gray\"><font color=\"white\" face=\"Arial Narrow\" size=\"2\">Kills</font></td><td bgcolor=\"gray\"><font color=\"white\" face=\"Arial Narrow\" size=\"2\">Karma / Fame</font></td>" );
	op.WriteLine( "   </tr>" );
	//To Do: Style Sheet
	
	foreach ( NetState state in NetState.Instances )
	{
	 Mobile m = state.Mobile;
	 if ( m != null )
	 {
	  Guild g = m.Guild as Guild;
	  op.Write( "		 <tr><td>" );
	  if ( g != null )
	  {
	   op.Write( 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( "</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>" );
   }
  }
 }
}
 

Revolution

Wanderer
its a nice subscription, but i think that if ppl want to modify webstatus.cs they should learn HTML, its simple and will be really helpful
 

cfaust

Wanderer
HTML and having RunUO write the HTML are slightly different variations, a few extra bits are needed here and there in order to actually produce the status.html file. You can't just throw HTML in to WebStatus.cs and expect it to work.

This was meant for novice users of RunUO anyway :)
 
Top