Is there a reason why you have this picture in every line?
http://aaaservices.homeip.net/UO/COEG.png
http://aaaservices.homeip.net/UO/COEG.png
if ( item is Container )
{
foreach ( Item subItem in item.Items )
{
op.Write( "<tr><td>");
op.WriteLine(subItem.Name);
op.Write("</td></tr>" );
}
}
using System;
using System.IO;
using System.Text;
using Server;
using Server.Network;
using Server.Guilds;
//
using Server.Items;
using Server.Mobiles;
using Server.Accounting;
//
namespace Server.Misc
{
public class StatusPage : Timer
{
public static bool Enabled = true;
public static void Initialize()
{
if ( Enabled )
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()
{
// World.Broadcast( 0x35, true, "STARTING STATUS" );
if ( !Directory.Exists( "web" ) )
Directory.CreateDirectory( "web" );
using ( StreamWriter op = new StreamWriter( "web/status.html" ) )
{
op.WriteLine( "<html>" );
op.WriteLine( " <head>" );
op.WriteLine( " <title>DragonKnights UO Server Status</title>");
op.WriteLine( " </head>" );
op.WriteLine( " <body bgcolor=\"black\">" );
op.WriteLine( "<img src= http://aaaservices.homeip.net/UO/DragonKnights%20-%20logo.jpg <br> " );
op.WriteLine( " <h3><font color =\"gold\">UltimaOnline Server Status</font></h3>" );
op.WriteLine( "<b><font color =\"gold\">Current Server Version # :</font></b><font color=\"green\"> 7.0.12.0</font><br>");
op.WriteLine( "<b><font color =\"gold\">Status Page Last Updated:</font></b><font color=\"green\"> "+DateTime.Now.ToString() + "</font><br>");
op.WriteLine( "<b><font color =\"gold\">Total World Items:</font></b><font color=\"green\"> "+World.Items.Count.ToString()+"</font><br>");
op.WriteLine( "<b><font color =\"gold\">Total World Mobiles:</font></b><font color=\"green\"> " + World.Mobiles.Count.ToString() + "</font><br>");
op.WriteLine( "<b><font color =\"gold\">Total Online:</font></b><font color=\"green\"> " + NetState.Instances.Count.ToString() + "</font><br>");
op.WriteLine( "<br>" );
// op.WriteLine( "<br>" );
// op.WriteLine( "<b><font color =\"gold\">END OF TOP - START OF ONLINE CLIENT TABLE</font></b><br>" );
#region online client table
op.WriteLine( "<font color=\"green\"> <table width=\"100%\">" );
op.WriteLine( " <tr></font>" );
op.WriteLine( " <td bgcolor=\"white\"><font color =\"black\"><b><img src= http://aaaservices.homeip.net/UO/OLW.png align=\"absmiddle\"> ONLINE PLAYERS:</b></font></td>" );
op.WriteLine( " </tr>" );
op.WriteLine( " </table>" );
op.WriteLine( "<font color=\"green\"> <table width=\"100%\">" );
op.WriteLine( " <tr></font>" );
op.WriteLine( " <td bgcolor=\"white\"><font color=\"black\"><img src= http://aaaservices.homeip.net/UO/OLW.png align=\"absmiddle\"> Name</font></td><td bgcolor=\"white\"><font color=\"black\">Location</font></td><td bgcolor=\"white\"><font color=\"black\">Kills</font></td><td bgcolor=\"white\"><font color=\"black\">Karma / Fame</font></td>" );
op.WriteLine( " </tr>" );
if (NetState.Instances.Count > 0)
{
#region list online players
foreach ( NetState state in NetState.Instances )
{
Mobile m = state.Mobile;
if ( m != null )
{
Guild g = m.Guild as Guild;
op.Write( " <tr><td><img src= http://aaaservices.homeip.net/UO/OLB.png align=\"absmiddle\"> " );
switch (m.AccessLevel)
{
case AccessLevel.Player:
op.Write( "<font color = FFFFFF><b>Player</b> - " );
break;
case AccessLevel.Counselor:
op.Write( "<font color = 008000><b>Counselor</b> - " );
break;
case AccessLevel.GameMaster:
op.Write( "<font color = FF0000><b>GameMaster</b> - " );
break;
case AccessLevel.Seer:
op.Write( "<font color = FF0000><b>Seer</b> - " );
break;
case AccessLevel.Administrator:
op.Write( "<font color = FF0000><b>Administrator</b> - " );
break;
case AccessLevel.Developer:
op.Write( "<font color = FF0000><b>Developer</b> - " );
break;
case AccessLevel.Owner:
op.Write( "<font color = 0000FF><b>Owner</b> - " );
break;
}
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><font color = 008000>" );
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><font color = FF0000>" );
op.Write( m.Kills );
op.Write( "</td><td><font color = 800080>" );
op.Write( m.Karma );
op.Write( " / " );
op.Write( m.Fame );
op.WriteLine( "</td></tr>" );
}
}
#endregion list online players
}
else
{
op.WriteLine( "<td><b><font color =\"red\">Nobody but us chickens! =P</font></b></td></tr>" );
}
// op.WriteLine( " <tr></tr>" );//added /tr
op.WriteLine( " </table>" );
#endregion online client table
#region player vendors table
// op.WriteLine( "<br>" );
op.WriteLine( "<br>" );
op.WriteLine( "<font color=\"green\"> <table width=\"100%\">" );
op.WriteLine( " <tr></font>" );
op.WriteLine( " <td bgcolor=\"white\"><font color =\"black\"><b><img src= http://aaaservices.homeip.net/UO/COEW.png align=\"absmiddle\"> PLAYER VENDOR SHOPS:</b></font></td>" );
op.WriteLine( " </tr>" );
op.WriteLine( " </table>" );
op.WriteLine( "<font color=\"green\"> <table width=\"100%\">" );
op.WriteLine( " <tr></font>" );
op.WriteLine( " <td bgcolor=\"white\"><font color=\"black\"><img src= http://aaaservices.homeip.net/UO/COEW.png align=\"absmiddle\"> Owners Name</font></td><td bgcolor=\"white\"><font color=\"black\">Shops Name</font></td><td bgcolor=\"white\"><font color=\"black\">Vendors Name</font></td><td bgcolor=\"white\"><font color=\"black\">Location</font></td>" );
op.WriteLine( " </tr>" );
foreach ( Mobile mob in World.Mobiles.Values )
{
if ( mob is PlayerVendor )
{
PlayerVendor pv = mob as PlayerVendor;
op.Write( " <tr><td bgcolor=\"red\"><font color = \"black\"><img src= http://aaaservices.homeip.net/UO/COER.png align=\"absmiddle\"> " );
op.WriteLine( pv.Owner.Name );
op.Write( "</td><td bgcolor=\"red\"><font color = \"black\">" );
op.WriteLine( pv.ShopName );
op.Write( "</td><td bgcolor=\"red\"><font color = \"black\">" );
op.WriteLine( pv.Name );
op.Write( "</td><td bgcolor=\"red\"><font color = \"black\">" );
// op.WriteLine( pv.Map );
// op.WriteLine( pv.Backpack );
// op.WriteLine( pv.AccessLevel );
op.WriteLine( pv.Map + " - " + pv.Location );
op.Write( "</td></tr>" );
// op.WriteLine( pv.X );
// op.WriteLine( pv.Y );
// op.WriteLine( pv.Z );
// op.WriteLine( pv.RawName );
// op.WriteLine( "---------------");
// op.WriteLine( "</td></tr>" );
op.WriteLine( "<tr><td bgcolor=\"yellow\"><font color=\"black\"><img src= http://aaaservices.homeip.net/UO/COEY.png align=\"absmiddle\">Amount</td><td bgcolor=\"yellow\"><font color=\"black\">Item</td><td bgcolor=\"yellow\"><font color=\"black\">Price for the Amount<t/d><td bgcolor=\"yellow\"><font color=\"black\">Description</td></tr>" );
foreach (Item item in pv.GetItems())
{
VendorItem vi = pv.GetVendorItem(item);
if ( item is Container )
{
foreach ( Item subItem in item.Items )
{
string siname = subItem.Name;
if (string.IsNullOrEmpty(siname))
{
siname = subItem.GetType().ToString();
if (siname.LastIndexOf('.') >= 0)
siname = siname.Substring(siname.LastIndexOf('.') + 1);
}
if ( siname.Length > 25 )
siname = siname.Substring(0, 25);
string sides = (string.IsNullOrEmpty(vi.Description) ? " " : vi.Description);
op.Write( "<tr><td bgcolor=\"orange\"><font color = \"black\">");
op.WriteLine(subItem.Amount);
op.Write("</td>" );
op.Write( "<td bgcolor=\"orange\"><font color = \"black\">");
op.WriteLine(siname);
op.Write("</td>" );
op.Write( "<td bgcolor=\"orange\"><font color = \"black\">");
op.WriteLine(vi.Price.ToString() );// SHOWS -1 instead of the price
op.Write("</td>" );
op.Write( "<td bgcolor=\"orange\"><font color = \"black\">");
op.WriteLine(sides);// NOT SHOWING DESCRIPTION
op.Write("</td></tr>" );
}
}
// if ( item is Container && item.Items.Count >0)
// {
// items = new ItemInfo[ item.Items.Count ];
//
// for ( int i = 0; i < items.Length; i++ )
// {
// items[ i ] = new ItemInfo( item.Items[ i ] as Item );
// }
// }
// else
// {
// items = new ItemInfo[ 1 ];
// items[ 0 ] = new ItemInfo( item );
// }
// SELF TRYING
// if ( item is Container && ( (Container)item ).Items.Count != 0 )
// {
// if ( ( (Container)item ).Items != null && ( (Container)item ).Items.IsForSale )
// {
// string ownername = (pv.Name != pv.Owner.Name ? pv.Owner.Name : " ");
// string name = ( (Container)item ).Items.Name;
//
// if (string.IsNullOrEmpty(name))
// {
// name = item.GetType().ToString();
// if (name.LastIndexOf('.') >= 0)
// name = name.Substring(name.LastIndexOf('.') + 1);
// }
//
// if ( name.Length > 25 )
// name = name.Substring(0, 25);
//
// string des = (string.IsNullOrEmpty(vi.Description) ? " " : vi.Description);
//
// op.WriteLine( "<tr><td bgcolor=\"green\"><font color = \"black\"><img src= http://aaaservices.homeip.net/UO/COEG.png align=\"absmiddle\"> {0} </td> <td bgcolor=\"green\"><font color = \"black\"> {1,-25} </td> <td bgcolor=\"green\"><font color = \"black\"> {2,7} </td> <td bgcolor=\"green\"><font color = \"black\"> {3} </td></tr>", item.Amount, name, vi.Price.ToString(), des );//Added </tr
//
//
// }
// }
if ( vi != null && vi.IsForSale )
{
if (pv.Owner == null || pv.Owner.Name == "1k5g6se84f895s854f884s6a") //If name same as this it will not show items in list.
continue;
string ownername = (pv.Name != pv.Owner.Name ? pv.Owner.Name : " ");
string name = item.Name;
if (string.IsNullOrEmpty(name))
{
name = item.GetType().ToString();
if (name.LastIndexOf('.') >= 0)
name = name.Substring(name.LastIndexOf('.') + 1);
}
if ( name.Length > 25 )
name = name.Substring(0, 25);
string des = (string.IsNullOrEmpty(vi.Description) ? " " : vi.Description);
op.WriteLine( "<tr><td bgcolor=\"green\"><font color = \"black\"><img src= http://aaaservices.homeip.net/UO/COEG.png align=\"absmiddle\"> {0} </td> <td bgcolor=\"green\"><font color = \"black\"> {1,-25} </td> <td bgcolor=\"green\"><font color = \"black\"> {2,7} </td> <td bgcolor=\"green\"><font color = \"black\"> {3} </td></tr>", item.Amount, name, vi.Price.ToString(), des );//Added </tr
}
}
}
}
//I ADDED END
// op.WriteLine( " <tr></tr>" );
op.WriteLine( " </table>" );
#endregion player vendors table
// op.WriteLine( "<b><font color =\"gold\">END OF LINE</font></b><br>" );
op.WriteLine( " </body>" );
op.WriteLine( "</html>" );
// Console.WriteLine( "WEBSTATUS UPDATE COMPLETE");
}
}
}
}
using System;
using System.IO;
using System.Text;
using Server;
using Server.Network;
using Server.Guilds;
//
using Server.Items;
using Server.Mobiles;
using Server.Accounting;
//
namespace Server.Misc
{
public class StatusPage : Timer
{
public static bool Enabled = true;
public static void Initialize()
{
if ( Enabled )
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>" );
#region player vendors table
op.WriteLine( "PLAYER VENDORS:<br>" );
op.WriteLine( "***************************************************************************************<br>" );
foreach ( Mobile mob in World.Mobiles.Values )
{
if ( mob is PlayerVendor )
{
PlayerVendor pv = mob as PlayerVendor;
op.WriteLine( "Owners Name , Shops Name, Vendors Name, Location <br>" );
op.WriteLine( pv.Owner.Name + "," + pv.ShopName + "," + pv.Name + "," + pv.Map + " - " + pv.Location + "<br>" );
op.WriteLine("Amount,Item,Price for the Amount,Description<br>");
foreach (Item item in pv.GetItems())
{
VendorItem vi = pv.GetVendorItem(item);
if (vi != null && vi.IsForSale)
{
if (pv.Owner == null || pv.Owner.Name == "1k5g6se84f895s854f884s6a") //If name same as this it will not show items in list.
continue;
string ownername = (pv.Name != pv.Owner.Name ? pv.Owner.Name : " ");
string name = item.Name;
if (string.IsNullOrEmpty(name))
{
name = item.GetType().ToString();
if (name.LastIndexOf('.') >= 0)
name = name.Substring(name.LastIndexOf('.') + 1);
}
if (name.Length > 25)
name = name.Substring(0, 25);
string des = (string.IsNullOrEmpty(vi.Description) ? " " : vi.Description);
op.WriteLine( "{0} {1,-25} {2,7} {3} <br>", item.Amount, name, vi.Price.ToString(), des );
}
}
op.WriteLine( "---------------------------------------------------------------------------------------<br>" );
}
if(mob is PlayerVendor == null)
op.WriteLine( "There are no player vendors in the world at the moment.<br>" );
}
op.WriteLine( "***************************************************************************************<br>" );
#endregion player vendors table
op.WriteLine( " </body>" );
op.WriteLine( "</html>" );
}
}
}
}
Are you using visual C# express?
If so than what you need to do is highlight the entire section inside the "foreach" you just added, right click on it and select: "refactor -> extract method".
If you don't than you need to create a method that does exactly the same thing and call it yourself.
In that method you need to do the check if the item is a container again and if so you call the method again.
This is called "recursion", you can google it up.
using System;
class Program
{
static void RecuriveFunction(int x)
{
if (x > 10) //Condition to stop recursion
return; //Exit out of function
else
{
Console.WriteLine(x);
RecuriveFunction(x + 1); //Call myself
}
}
static void Main()
{
RecuriveFunction(1);
Console.Read();
}
}
GetVendorItemsDisplay( op, pv, item);
... bla bla ...
op.WriteLine("Amount,Item,Price for the Amount,Description<br>");
foreach (Item item in pv.GetItems())
{
GetVendorItemsDisplay( op, pv, item);
}
op.WriteLine( "---------------------------------------------------------------------------------------<br>" );
... bla bla ...
Errors:
+ Misc/ws-last working on - Copy.cs:
CS1519: Line 168: Invalid token '(' in class, struct, or interface member de
claration
CS1519: Line 169: Invalid token '(' in class, struct, or interface member de
claration
using System;
using System.IO;
using System.Text;
using Server;
using Server.Network;
using Server.Guilds;
//
using Server.Items;
using Server.Mobiles;
using Server.Accounting;
//
namespace Server.Misc
{
public class StatusPage : Timer
{
public static bool Enabled = true;
public static void Initialize()
{
if ( Enabled )
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>" );
#region player vendors table
// op.WriteLine( "PLAYER VENDORS:<br>" );
// op.WriteLine( "***************************************************************************************<br>" );
//
// foreach ( Mobile mob in World.Mobiles.Values )
// {
// if ( mob is PlayerVendor )
// {
// PlayerVendor pv = mob as PlayerVendor;
// op.WriteLine( "Owners Name , Shops Name, Vendors Name, Location <br>" );
// op.WriteLine( pv.Owner.Name + "," + pv.ShopName + "," + pv.Name + "," + pv.Map + " - " + pv.Location + "<br>" );
//
//
// op.WriteLine("Amount,Item,Price for the Amount,Description<br>");
//
// foreach (Item item in pv.GetItems())
// {
// VendorItem vi = pv.GetVendorItem(item);
// if (vi != null && vi.IsForSale)
// {
// if (pv.Owner == null || pv.Owner.Name == "1k5g6se84f895s854f884s6a") //If name same as this it will not show items in list.
// continue;
// string ownername = (pv.Name != pv.Owner.Name ? pv.Owner.Name : " ");
// string name = item.Name;
// if (string.IsNullOrEmpty(name))
// {
// name = item.GetType().ToString();
// if (name.LastIndexOf('.') >= 0)
// name = name.Substring(name.LastIndexOf('.') + 1);
// }
// if (name.Length > 25)
// name = name.Substring(0, 25);
//
// string des = (string.IsNullOrEmpty(vi.Description) ? " " : vi.Description);
// op.WriteLine( "{0} {1,-25} {2,7} {3} <br>", item.Amount, name, vi.Price.ToString(), des );
// }
// }
// op.WriteLine( "---------------------------------------------------------------------------------------<br>" );
//
// }
// if(mob is PlayerVendor == null)
// op.WriteLine( "There are no player vendors in the world at the moment.<br>" );
// }
// op.WriteLine( "***************************************************************************************<br>" );
#endregion player vendors table
}
}
private void GetVendorItemsDisplay(StreamWriter op, PlayerVendor pv, Item item)
{
foreach ( Mobile mob in World.Mobiles.Values )
{
if ( mob is PlayerVendor )
{
PlayerVendor pv = mob as PlayerVendor;
op.WriteLine( "Owners Name , Shops Name, Vendors Name, Location <br>" );
op.WriteLine( pv.Owner.Name + "," + pv.ShopName + "," + pv.Name + "," + pv.Map + " - " + pv.Location + "<br>" );
op.WriteLine("Amount,Item,Price for the Amount,Description<br>");
foreach (Item item in pv.GetItems())
{
VendorItem vi = pv.GetVendorItem(item);
if (vi != null && vi.IsForSale)
{
if (pv.Owner == null || pv.Owner.Name == "1k5g6se84f895s854f884s6a") //If name same as this it will not show items in list.
continue;
string ownername = (pv.Name != pv.Owner.Name ? pv.Owner.Name : " ");
string name = item.Name;
if (string.IsNullOrEmpty(name))
{
name = item.GetType().ToString();
if (name.LastIndexOf('.') >= 0)
name = name.Substring(name.LastIndexOf('.') + 1);
}
if (name.Length > 25)
name = name.Substring(0, 25);
string des = (string.IsNullOrEmpty(vi.Description) ? " " : vi.Description);
op.WriteLine( "{0} {1,-25} {2,7} {3} <br>", item.Amount, name, vi.Price.ToString(), des );
{
GetVendorItemsDisplay( op, pv, item);
}
}
}
op.WriteLine( "---------------------------------------------------------------------------------------<br>" );
}
if(mob is PlayerVendor == null)
op.WriteLine( "There are no player vendors in the world at the moment.<br>" );
{
GetVendorItemsDisplay( op, pv, item);
}
}
}
op.WriteLine( " </body>" );
op.WriteLine( "</html>" );
}
}
private void method
{
private void method2
{
}
}
You copied the code in the other foreach loop.4. Copy all the code inside the foreach loop that runs on the pv.GetItems() list into the new method, this is your actual code.
Errors:
+ Misc/ws-last working on - Copy.cs:
CS0136: Line 125: A local variable named 'pv' cannot be declared in this sco
pe because it would give a different meaning to 'pv', which is already used in a
'parent or current' scope to denote something else
using System;
using System.IO;
using System.Text;
using Server;
using Server.Network;
using Server.Guilds;
//
using Server.Items;
using Server.Mobiles;
using Server.Accounting;
//
namespace Server.Misc
{
public class StatusPage : Timer
{
public static bool Enabled = true;
public static void Initialize()
{
if ( Enabled )
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>" );
#region player vendors table
// op.WriteLine( "PLAYER VENDORS:<br>" );
// op.WriteLine( "***************************************************************************************<br>" );
//
// foreach ( Mobile mob in World.Mobiles.Values )
// {
// if ( mob is PlayerVendor )
// {
// PlayerVendor pv = mob as PlayerVendor;
// op.WriteLine( "Owners Name , Shops Name, Vendors Name, Location <br>" );
// op.WriteLine( pv.Owner.Name + "," + pv.ShopName + "," + pv.Name + "," + pv.Map + " - " + pv.Location + "<br>" );
//
//
// op.WriteLine("Amount,Item,Price for the Amount,Description<br>");
//
// foreach (Item item in pv.GetItems())
// {
// VendorItem vi = pv.GetVendorItem(item);
// if (vi != null && vi.IsForSale)
// {
// if (pv.Owner == null || pv.Owner.Name == "1k5g6se84f895s854f884s6a") //If name same as this it will not show items in list.
// continue;
// string ownername = (pv.Name != pv.Owner.Name ? pv.Owner.Name : " ");
// string name = item.Name;
// if (string.IsNullOrEmpty(name))
// {
// name = item.GetType().ToString();
// if (name.LastIndexOf('.') >= 0)
// name = name.Substring(name.LastIndexOf('.') + 1);
// }
// if (name.Length > 25)
// name = name.Substring(0, 25);
//
// string des = (string.IsNullOrEmpty(vi.Description) ? " " : vi.Description);
// op.WriteLine( "{0} {1,-25} {2,7} {3} <br>", item.Amount, name, vi.Price.ToString(), des );
// }
// }
// op.WriteLine( "---------------------------------------------------------------------------------------<br>" );
//
// }
// if(mob is PlayerVendor == null)
// op.WriteLine( "There are no player vendors in the world at the moment.<br>" );
// }
// op.WriteLine( "***************************************************************************************<br>" );
#endregion player vendors table
}
}
private void GetVendorItemsDisplay(StreamWriter op, PlayerVendor pv, Item item)
{
foreach ( Mobile mob in World.Mobiles.Values )
{
if ( mob is PlayerVendor )
{
PlayerVendor pv = mob as PlayerVendor;
op.WriteLine( "Owners Name , Shops Name, Vendors Name, Location <br>" );
op.WriteLine( pv.Owner.Name + "," + pv.ShopName + "," + pv.Name + "," + pv.Map + " - " + pv.Location + "<br>" );
op.WriteLine("Amount,Item,Price for the Amount,Description<br>");
op.WriteLine( "---------------------------------------------------------------------------------------<br>" );
}
if(mob is PlayerVendor == null)
op.WriteLine( "There are no player vendors in the world at the moment.<br>" );
GetVendorItemsDisplay( op, pv, item);
op.WriteLine( " </body>" );
op.WriteLine( "</html>" );
}
}
}
}
Copy only what is INSIDE the foreach loot that RUNS ON pv.GetITems().4. Copy all the code inside the foreach loop that runs on the pv.GetItems() list into the new method, this is your actual code.
5. Write inside the foreach loop the following line
Code:
GetVendorItemsDisplay( op, pv, item);
so it'll look like this:
Code:
... bla bla ...
op.WriteLine("Amount,Item,Price for the Amount,Description<br>");
foreach (Item item in pv.GetItems())
{
GetVendorItemsDisplay( op, pv, item);
}
op.WriteLine( "---------------------------------------------------------------------------------------<br>" );
... bla bla ...
using System;
using System.IO;
using System.Text;
using Server;
using Server.Network;
using Server.Guilds;
//
using Server.Items;
using Server.Mobiles;
using Server.Accounting;
//
namespace Server.Misc
{
public class StatusPage : Timer
{
public static bool Enabled = true;
public static void Initialize()
{
if ( Enabled )
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>" );
#region player vendors table
op.WriteLine( "PLAYER VENDORS:<br>" );
op.WriteLine( "***************************************************************************************<br>" );
foreach ( Mobile mob in World.Mobiles.Values )
{
if ( mob is PlayerVendor )
{
PlayerVendor pv = mob as PlayerVendor;
op.WriteLine( "Owners Name , Shops Name, Vendors Name, Location <br>" );
op.WriteLine( pv.Owner.Name + "," + pv.ShopName + "," + pv.Name + "," + pv.Map + " - " + pv.Location + "<br>" );
op.WriteLine("Amount,Item,Price for the Amount,Description<br>");
foreach (Item item in pv.GetItems())
{
VendorItem vi = pv.GetVendorItem(item);
if (vi != null && vi.IsForSale)
{
if (pv.Owner == null || pv.Owner.Name == "1k5g6se84f895s854f884s6a") //If name same as this it will not show items in list.
continue;
string ownername = (pv.Name != pv.Owner.Name ? pv.Owner.Name : " ");
string name = item.Name;
if (string.IsNullOrEmpty(name))
{
name = item.GetType().ToString();
if (name.LastIndexOf('.') >= 0)
name = name.Substring(name.LastIndexOf('.') + 1);
}
if (name.Length > 25)
name = name.Substring(0, 25);
string des = (string.IsNullOrEmpty(vi.Description) ? " " : vi.Description);
op.WriteLine( "{0} {1,-25} {2,7} {3} <br>", item.Amount, name, vi.Price.ToString(), des );
}
GetVendorItemsDisplay( op, pv, item);//HERE????
}
op.WriteLine( "---------------------------------------------------------------------------------------<br>" );
}
if(mob is PlayerVendor == null)
op.WriteLine( "There are no player vendors in the world at the moment.<br>" );
}
op.WriteLine( "***************************************************************************************<br>" );
#endregion player vendors table
op.WriteLine( " </body>" );
op.WriteLine( "</html>" );
}
}
private void GetVendorItemsDisplay(StreamWriter op, PlayerVendor pv, Item item)
{
VendorItem vi = pv.GetVendorItem(item);
if (vi != null && vi.IsForSale)
{
if (pv.Owner == null || pv.Owner.Name == "1k5g6se84f895s854f884s6a") //If name same as this it will not show items in list.
continue;
string ownername = (pv.Name != pv.Owner.Name ? pv.Owner.Name : " ");
string name = item.Name;
if (string.IsNullOrEmpty(name))
{
name = item.GetType().ToString();
if (name.LastIndexOf('.') >= 0)
name = name.Substring(name.LastIndexOf('.') + 1);
}
if (name.Length > 25)
name = name.Substring(0, 25);
string des = (string.IsNullOrEmpty(vi.Description) ? " " : vi.Description);
op.WriteLine( "{0} {1,-25} {2,7} {3} <br>", item.Amount, name, vi.Price.ToString(), des );
}
}
}
}