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!

XML Outputs, or something simmilar

Alaskan

Wanderer
XML Outputs, or something simmilar

Hi,

I think it would be cool if things like the number of players online, number of accounts, highest fame, faction ratings( stuff that the server would already know ) could be outputted to a web page. Like every save, an XML doc could be made that had some info that was chosen by the admins.

I am very sorry if this has already been implemented, but I didnt see it in the docs.

Thanks
-Alask
 

Kamron

Knight
You can use the already made XML commands or the built in XML commands for C# to achieve this. Look at Scripts\Misc\WebStatus.cs to see how the retreive the information.
 

KnightD

Sorceror
An XML Example

Here is an XML example for ya:
[code:1]
using System;
using System.IO;
using System.Text;
using System.Collections;
using System.Xml;

using Server;
using Server.Network;
using Server.Guilds;

namespace Server.Web
{
public class PlayerList : Timer
{
public static void Initialize()
{
new PlayerList().Start();
}

public PlayerList() : base( TimeSpan.FromSeconds( 5.0 ), TimeSpan.FromSeconds( 60.0 ) )
{
Priority = TimerPriority.FiveSeconds;
}

protected override void OnTick()
{
if ( !Directory.Exists( "Saves/Web" ) )
Directory.CreateDirectory( "Saves/Web" );

using ( StreamWriter op = new StreamWriter( "Saves/Web/Players.xml" ) )
{
XmlTextWriter xml = new XmlTextWriter( op );

xml.Formatting = Formatting.Indented;
xml.IndentChar = '\t';
xml.Indentation = 1;

xml.WriteStartDocument( true );

xml.WriteStartElement( "WebData" );
xml.WriteAttributeString( "Created", DateTime.Now.ToString() );
xml.WriteAttributeString( "Updated", (DateTime.Now + this.Interval).ToString() );

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

if ( m != null )
{
xml.WriteStartElement( "Mobile" );
xml.WriteAttributeString( "Name", m.Name );
xml.WriteAttributeString( "Access", m.AccessLevel.ToString());
xml.WriteAttributeString( "Kills", m.Kills.ToString());
xml.WriteAttributeString( "Karma", m.Karma.ToString());
xml.WriteAttributeString( "Fame", m.Fame.ToString());


Guild g = m.Guild;
if ( g != null )
{
xml.WriteStartElement( "Guild" );
xml.WriteAttributeString( "Key", g.Id.ToString() );
xml.WriteAttributeString( "GuildName", g.Name.Trim() );
xml.WriteAttributeString( "GuildTitle", m.GuildTitle );
xml.WriteAttributeString( "Abbreviation", g.Abbreviation );
xml.WriteEndElement();
}

xml.WriteStartElement( "Location" );
xml.WriteAttributeString( "Map", m.Map.ToString());
xml.WriteAttributeString( "X", m.X.ToString());
xml.WriteAttributeString( "Y", m.Y.ToString());
xml.WriteAttributeString( "Z", m.Z.ToString());
xml.WriteEndElement();

xml.WriteEndElement();
}
}

xml.Close();

}
}
}
}[/code:1]
 
Top