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!

"Age" display in script

TomC

Wanderer
"Age" display in script

This incomplete script was submitted to us by Mark. I am working on reworking the gump, but I am unable to get the player age to display correctly. I was just wanting to set it to display time in days. Currently it shows age in days:hours:mins:seconds to the 5th place on the seconds. A long number. Preferably just something that was showing age in days with "days" after the number.

Code:
using System;
using System.Collections;
using Server;
using Server.Accounting;
using Server.Mobiles;
using Server.Network;
using Server.Gumps;

namespace Server.Misc
{
	public class NewPlayers
	{
		public static void Initialize()
		{
			Commands.Register( "NewPlayers", AccessLevel.Player, new CommandEventHandler( NewPlayers_OnCommand ) );
		}

		[Usage( "NewPlayers" )]
		[Description( "Lists all online new players." )]
		public static void NewPlayers_OnCommand( CommandEventArgs e )
		{
			e.Mobile.SendGump( new NewPlayerGump() );
		}
	}
}

namespace Server.Gumps
{
	public class NewPlayerGump : Gump
	{
		private static TimeSpan m_Duration = TimeSpan.FromDays( 30 );

		public NewPlayerGump() : this( 0 )
		{
		}

		public NewPlayerGump( int page ) : base( 0, 0 )
		{
			Closable = true;
			Disposable = true;
			Dragable = true;
			Resizable = false;

			AddPage(0);

			AddBackground(30, 30, 400, 240, 9390);
			/*AddLabel(45, 35, 0, @"Name");
			AddLabel(140, 35, 0, @"Location");
			AddLabel(260, 35, 0, @"Age");
			AddImageTiled(30, 53, 400, 11, 2091);*/
			AddHtml( 60, 30, 340, 22, @"<CENTER>Character Name     Location     Age</CENTER>", false, false );

			//if ( page > 0 )
				AddButton(30, 30, 4014, 9903, (int)Buttons.Back, GumpButtonType.Reply, 0);
			
			
				AddButton(400, 30, 4005, 9909, (int)Buttons.Foward, GumpButtonType.Reply, 0);

				


			int index = 0;

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

				if ( m == null || m.AccessLevel != AccessLevel.Player )
					continue;
				
				if ( m.Account == null )
					continue;
				
				Account a = (Account)m.Account;

				TimeSpan t = DateTime.Now - a.Created;

				if ( t > m_Duration )
					continue;
				
				int y = 60 + ( index * 20 );

				string location = Region.Find( m.Location, m.Map ).Name;
				AddLabel(45, y, 0, m.Name);
				AddLabel(140, y, 0, (location == "" ? "Unknown" : location) );
				AddLabel(260, y, 0, t.ToString() );

				if ( index == 8 )
					return;
				else
					index++;
			}
		}

		public enum Buttons
		{
			Back,
			Foward,
		}
	}
}
 
Top