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 peoplePage : Timer
{
public static void Initialize()
{new peoplePage().Start();}
public peoplePage() : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(15.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/show.xml"))
{
op.WriteLine("<Players>");
foreach (NetState state in NetState.Instances)
{
Mobile m = state.Mobile;
if (m != null)
{
op.WriteLine(" <PlayerInfo>");
op.WriteLine(" <PlayerName>" + m.Name + "</PlayerName>");
op.WriteLine(" <AccessLevel>" + m.AccessLevel + "</AccessLevel>");
if (m.AccessLevel >= AccessLevel.GameMaster)
{
op.WriteLine(" <DontShow>True</DontShow>");
}
else
{
op.WriteLine(" <DontShow>False</DontShow>");
}
if (m.Hidden != false)
{
op.WriteLine(" <Hidden>True</Hidden>");
}
else
{
op.WriteLine(" <Hidden>False</Hidden>");
}
op.WriteLine(" <xCoord>" + m.X + "</xCoord>");
op.WriteLine(" <yCoord>" + m.Y + "</yCoord>");
op.WriteLine(" <zCoord>" + m.Z + "</zCoord>");
op.WriteLine(" <Facet>" + m.Map + "</Facet>");
op.WriteLine(" </PlayerInfo>");
}
}
op.WriteLine("</Players>");
}
}
}
}
Shows you how to get the information you asked for and write it to an XML file...in case you wanted to use it for online tracking or whatever. Its a good lil script that I use for my online maps. I've never put a lot of time into scripting for RunUO as i'm more interested in doing stuff on the web end, so I had Roth show me how to do this.