Ravenal
Knight
Issue with TimeClock, Can someone Help?
Okay I have one issue.... It seems like my F.C. and R.C. (AM PM) things...
Okay Before Midnight it is RC *going to Midnight* PM
After Midnight it goes to FC *from midnight to Noon* AM
But what happens is it hits 1am and it converts back to RC again, when it should stay at AM...
Another problem is the Dates... Same issue with the 1am issue...
it adds it 1 day then when it goes 1am it goes back to the old day... WHY IN THE HELL DOES IT DO THIS?
Okay I have one issue.... It seems like my F.C. and R.C. (AM PM) things...
Okay Before Midnight it is RC *going to Midnight* PM
After Midnight it goes to FC *from midnight to Noon* AM
But what happens is it hits 1am and it converts back to RC again, when it should stay at AM...
Another problem is the Dates... Same issue with the 1am issue...
it adds it 1 day then when it goes 1am it goes back to the old day... WHY IN THE HELL DOES IT DO THIS?
PHP:
/////////////////////////////////////////////////////////
// Scripted by BKW of Awaken Lands, Future Online Game //
// URL: [url]www.awakenlands.com[/url] //
// © 2004, By Fanatsy World Entertainment //
/////////////////////////////////////////////////////////
/**********PLEASE DO NOT REMOVE THIS HEADER*************/
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Items;
using Server.Mobiles;
using Server.Misc;
namespace Server.Gumps
{
public class TimeClock : Gump
{
private Mobile m_From;
private static ClockTimer m_MyTimer;
public Mobile From{ get{ return m_From; } set{ m_From = value; } }
public static void Initialize()
{
Server.Commands.Register( "TimeInfo", AccessLevel.Player, new CommandEventHandler( Time_OnCommand ) );
EventSink.Login += new LoginEventHandler( EventSink_Login );
}
[Usage( "Time" )]
[Description( "Manages the Time of the World." )]
public static void Time_OnCommand( CommandEventArgs e )
{
e.Mobile.SendMessage( "This is the Time Help: B.T. = Barbais Time, I.U. = Internal Universal Time, F.C. = Frowning Crustin *Midnight to Noon*, R.C = Rising Crustin *Noon to Midnight" );
}
private static void EventSink_Login( LoginEventArgs args )
{
Mobile from = args.Mobile;
args.Mobile.SendGump( new TimeClock( args.Mobile ) );
m_MyTimer = new ClockTimer(args.Mobile);
m_MyTimer.Start();
}
public static void WorldTime( Mobile from, out string worldTime, out string clockTime )
{
int hours, minutes;
int day = 41; // Default Day;
int month = 10; // Default Month;
int year = 22600; // You can change the year to whatever you want
Server.Items.Clock.GetTime(from.Map, from.Location.X, from.Location.Y, out hours, out minutes);
if ( month <= 11 && month >= 11 )
{
day = 1;
month = 1;
year -= 1;
}
else if ( day <= 42 && day >= 42 )
{
month += 1;
day = 1;
}
else if ( hours <= 0 && hours >= 0 )
{
day += 1;
}
worldTime = String.Format( "{0}/{1}/{2} B.T.", month, day, year );
//worldTime = String.Format( "Disabled" );
hours %= 12;
if ( hours == 0 )
{
hours = 12;
}
clockTime = String.Format( "{0}:{1} {2}", hours, minutes, hours >= 12 ? "R.C." : "F.C." );
//clockTime = String.Format( "Disabled" );
}
public TimeClock(Mobile from) : base( 10, 10 )
{
from.CloseGump( typeof( TimeClock ) );
string worldTime;
string clockTime;
Server.Gumps.TimeClock.WorldTime(from, out worldTime, out clockTime );
m_From = from;
Closable = false;
Disposable = false;
Dragable = false;
Resizable = false;
AddPage( 0 );
AddBackground( 345, 20, 288, 40, 0x53 );
AddHtml( 475, 30, 160, 20, String.Format( "<basefont color=#FFFFFF>Date: {0}</basefont>", worldTime ), false, false );
AddHtml( 360, 30, 110, 20, String.Format( "<basefont color=#FFFFFF>Time: {0}</basefont>", clockTime ), false, false );
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
}
public class ClockTimer : Timer
{
private Mobile from;
public ClockTimer( Mobile m ) : base( TimeSpan.FromSeconds( 6 ), TimeSpan.FromSeconds( 6 ) )
{
from = m;
}
protected override void OnTick()
{
from.SendGump( new TimeClock( from ) );
}
}
}
}