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!

Issue with TimeClock, Can someone Help? :)

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?

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 ) );
				}
		}
	}
}
 

ArteGordon

Wanderer
Code:
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" );

based on this code, the test

hours >= 12 ? "R.C." : "F.C." will only be true (hours == 12) between midnight and 1am (hours == 0) when you force hours to be 12.
 

ArteGordon

Wanderer
looks to me as though you are trying to do something like this
Code:
int actualhours = hours%24

hours %= 12; 

            if ( hours == 0 ) 
            { 
                hours = 12; 
            } 
             
            clockTime = String.Format( "{0}:{1} {2}", hours, minutes, actualhours >= 12 ? "R.C." : "F.C." );
 

Ravenal

Knight
Okay what about this???

PHP:
			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 );
 

Ravenal

Knight
I got this error with this....

PHP:
Scripts: Compiling C# scripts...failed (1 errors, 6 warnings)
 - Error: Scripts\Gumps\TimeClock.cs: CS0165: (line 50, column 22) Use of unassigned local variable 'hours'

PHP:
int actualhours = hours%24;

hours %= 12; 

            if ( hours == 0 ) 
            { 
                hours = 12; 
            } 
             
            clockTime = String.Format( "{0}:{1} {2}", hours, minutes, actualhours >= 12 ? "R.C." : "F.C." );
 

Ceday

Page
what are you trying to do exactly? the code is nonsense:

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 ) //this means month==11 however month is 10 since it didnt change
{
day = 1;
month = 1;
year -= 1;
}
else if ( day <= 42 && day >= 42 ) //same as day==42, and day didnt change too.
{
month += 1;
day = 1;
}
else if ( hours <= 0 && hours >= 0 ) //same as hours==0
{
day += 1;
}
worldTime = String.Format( "{0}/{1}/{2} B.T.", month, day, year );
 

Ravenal

Knight
well it could explain by looking at the code very well, I want to add 1 day to the thing... saying the next day when it hits MIdnight, and stufff....
 

ArteGordon

Wanderer
awakenlands said:
I got this error with this....

PHP:
Scripts: Compiling C# scripts...failed (1 errors, 6 warnings)
 - Error: Scripts\Gumps\TimeClock.cs: CS0165: (line 50, column 22) Use of unassigned local variable 'hours'

PHP:
int actualhours = hours%24;

hours %= 12; 

            if ( hours == 0 ) 
            { 
                hours = 12; 
            } 
             
            clockTime = String.Format( "{0}:{1} {2}", hours, minutes, actualhours >= 12 ? "R.C." : "F.C." );

its just saying that you need to define hours before you refer to it. Put
int hours=0;
somewhere up near the top.
 

Ravenal

Knight
hehe here ya go man, this is what i have, and same error....


PHP:
public static void WorldTime( Mobile from, out string worldTime, out string clockTime )
		{
			int hours, minutes;
			int actualhours = hours % 24;
			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, actualhours >= 12 ? "R.C." : "F.C." );
			//clockTime = String.Format( "Disabled" );
		}
 
awakenlands said:
hehe here ya go man, this is what i have, and same error....
That's because you haven't fixed the problem. You try to use hours before you've assigned anything to it. Change your script so that hours gets something assigned to it before you use it.
 

Ravenal

Knight
it is using something :p

PHP:
Server.Items.Clock.GetTime(from.Map, from.Location.X, from.Location.Y, out  hours, out  minutes);
 

Ravenal

Knight
so it should be this???

PHP:
public static void WorldTime( Mobile from, out string worldTime, out string clockTime )
		{
			Server.Items.Clock.GetTime(from.Map, from.Location.X, from.Location.Y, out  hours, out  minutes); 
			int hours
			int minutes;
			int actualhours = hours % 24;
			int day = 41; // Default Day;
			int month = 10; // Default Month;
			int year = 22600; // You can change the year to whatever you want
 

Ravenal

Knight
when i do that it says this... in errors

Code:
Scripts: Compiling C# scripts...failed (2 errors, 6 warnings)
 - Error: Scripts\Gumps\TimeClock.cs: CS0103: (line 49, column 80) The name 'hou
rs' does not exist in the class or namespace 'Server.Gumps.TimeClock'
 - Error: Scripts\Gumps\TimeClock.cs: CS0103: (line 49, column 92) The name 'min
utes' does not exist in the class or namespace 'Server.Gumps.TimeClock'
 

Ravenal

Knight
ok i got problem...

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 = 0;
			int minutes = 0;
			int actualhours = hours % 24;
			Server.Items.Clock.GetTime(from.Map, from.Location.X, from.Location.Y, out  hours, out  minutes); 
			int day = 41; // Default Day;
			int month = 10; // Default Month;
			int year = 22600; // You can change the year to whatever you want
			
			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, actualhours => 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 ) );
				}
		}
	}
}

The problem is this...

clockTime = String.Format( "{0}:{1} {2}", hours, minutes, actualhours => 12 ? "R.C." : "F.C." );

Now it will only show "F.C." and not R.C. at all...
 
Top