All pastes #257800 Raw Edit

Stuff

public cpp v1 · immutable
#257800 ·published 2006-11-25 19:59 UTC
rendered paste body
using System;using System.IO;using System.Timers;using System.Diagnostics;using Server;using HelperTools;namespace Server.XMLScripts{public class XMLStatusWriter : Timer{/// <summary>/// timer interval(Milliseconds) 1000ms = 1 second/// </summary>private static double _time = 200000;private string path = Path.GetFullPath("C:/Apache2/htdocs/WoWServer/");private string honorpath = Path.GetFullPath("C:/Apache2/htdocs/WoWServer/");public XMLStatusWriter() : base( XMLStatusWriter._time ){base.Elapsed += new ElapsedEventHandler(OnTick);base.Start();}private void OnTick(object sender, ElapsedEventArgs e){Stats();}public void Stats(){using (StreamWriter writer1 = GetWriter(path, "status.xml")){writer1.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");writer1.WriteLine("<players>");foreach ( Character c in World.allConnectedChars ){writer1.WriteLine("<player>");writer1.WriteLine("<name>" + c.Name + "</name>");writer1.WriteLine("<race>" + c.Race.ToString() + "</race>");writer1.WriteLine("<gender>" + c.Gender + "</gender>");writer1.WriteLine("<class>" + c.Classe + "</class>");writer1.WriteLine("<level>" + c.Level + "</level>");writer1.WriteLine("<zone>" + c.ZoneId.ToString() + "</zone>");writer1.WriteLine("<map>" + c.MapId + "</map>");//writer1.WriteLine("<ping>" + c.Ping + "</ping>");writer1.WriteLine("</player>");}writer1.Write("</players>");}using (StreamWriter writer1 = GetWriter(path, "sstatus.xml")){writer1.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");writer1.WriteLine("<status>");writer1.WriteLine("<servername>" + World.ServerName + "</servername>");writer1.WriteLine("<serverip>" + World.ServerIP + "</serverip>");writer1.WriteLine("<serverver>" + World.Version + "</serverver>");writer1.WriteLine("<serveruptime>" + World.startingTime + "</serveruptime>");writer1.WriteLine("<plonline>" + World.allConnectedChars.Count.ToString() + "</plonline>");writer1.WriteLine("<spawnedmobs>" + World.allMobiles.Count.ToString() + "</spawnedmobs>");writer1.WriteLine("<spawnedobj>" +  World.allGameObjects.Count.ToString() + "</spawnedobj>");writer1.WriteLine("<regaccounts>" + World.allAccounts.Count.ToString() + "</regaccounts>");writer1.WriteLine("</status>");}using (StreamWriter writer1 = GetWriter(path, "honor.xml")){writer1.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");writer1.WriteLine("<players>");  foreach ( Character c in World.allConnectedChars )      {      writer1.WriteLine("<player>");      writer1.WriteLine("<name>" + c.Name + "</name>");      writer1.WriteLine("<race>" + c.Race.ToString() + "</race>");      writer1.WriteLine("<honorToday>" + c.Honor.HonorToday + "</honorToday>");      writer1.WriteLine("<honarableToday>" + c.Honor.HonorableKillsToday + "</honarableToday>");      writer1.WriteLine("<dishonarableToday>" + c.Honor.DishonorableKillsToday + "</dishonarableToday>");      writer1.WriteLine("<honarableYesterday>" + c.Honor.HonorableKillsYesterday + "</honarableYesterday>");      writer1.WriteLine("<honorYesterday>" + c.Honor.HonorYesterday + "</honorYesterday>");      writer1.WriteLine("<honarableThisWeek>" + c.Honor.HonorableKillsThisWeek + "</honarableThisWeek>");      writer1.WriteLine("<honorThisWeek>" + c.Honor.HonorThisWeek + "</honorThisWeek>");      writer1.WriteLine("<hkillsLastWeek>" + c.Honor.HonorableKillsLastWeek + "</hkillsLastWeek>");      writer1.WriteLine("<honorLastWeek>" + c.Honor.HonorLastWeek + "</honorLastWeek>");      writer1.WriteLine("<standing>" + c.Honor.Standing + "</standing>");      writer1.WriteLine("<hkillsLifeTime>" + c.Honor.HonorableKillsLifeTime + "</hkillsLifeTime>");      writer1.WriteLine("<dishkillsLifeTime>" + c.Honor.DishonorableKillsLifeTime + "</dishkillsLifeTime>");      writer1.WriteLine("<progress>" + c.Honor.ProgressHonorBar + "</progress>");      writer1.WriteLine("<rank>" + c.Honor.Rank + "</rank>");      writer1.WriteLine("<higherstRank>" + c.Honor.HigherstRank + "</higherstRank>");      writer1.WriteLine("</player>");      }writer1.WriteLine("</players>");}Console.WriteLine("-==[<status.xml UPDATED>]==--");Console.WriteLine("-->>> [honor.xml UPDATED] <<<--");foreach ( Character c in World.allConnectedChars )         {            c.SendMessage( "[" + TextColor.Set( TextColors.Red, "status.xml UPDATED" ) + "] " );            c.SendMessage( "-->" + TextColor.Set( TextColors.Red, "honor.xml UPDATED" ) + "<" );         } }private StreamWriter GetWriter(string root, string name){return new StreamWriter(root + name);}}}XMLWriter.csCode:using System;using System.Threading;using Server;namespace Server.XMLScripts{/// <summary>/// Starts timed XML writers/// </summary>public class XMLWriters : IInitialize{#region Static Declarationspublic static XMLStatusWriter statuswriter;#endregion#region Initializepublic static void Initialize(){AutoResetEvent asyncOpIsDone = new AutoResetEvent(false);ThreadPool.QueueUserWorkItem(new WaitCallback(StartXMLWriters), asyncOpIsDone);}#endregionprivate static void StartXMLWriters(object state){if( statuswriter == null){statuswriter = new XMLStatusWriter();statuswriter.Stats();} }}}