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!

Message of the Day (MOTD)

Icon

Wanderer
Message of the Day (MOTD)

Summary:
Ok first off I didn't make this script and I know your not supposed to repost someone else's work but seeing how old this script really is and 99.9% sure the script is no longer on the forms and was asked for the script....


Anyways a simple message of the day program, simple make a news.txt file in your runuo\data folder, and when players log in it will have info for them, something like sphere has.


Plus by placeing a check by the gump it will no longer show up when the player logs in.

Description:


Installation:
Copy motd.cs into your scripts\custom folder
Then make/update news.txt file in your runuo\data folder

Then log in with admin and type
[motd

A gump will show up this can be use to force and update so the next time a player logs in they can see the news. also the word motd by a player will popup the gump.



Hk
 

Attachments

  • motd.cs
    9.5 KB · Views: 2,074

Sargonnas

Wanderer
Great script, only one problem. How can I stop players from opening the gump a billion times? It stacks one after another... Also be great if there was a limit on how often it can be opened.
 

Icon

Wanderer
Well as i posted before i didnt make this script just reposting it but, 1 way is to changed the motd name in the script to something the players dont know to keep them from setting off the gump and then find this line of code

Code:
AddLabel( 10 ,369, 2100, "You can view this message at any time by saying \"motd.\"" );

just remark that line out or del that line out.
And the only time that they will see it is when u force an motd update.


Hk
 

BondDLegion

Wanderer
Well... Core of this script (idea and gum) created somebody from this forum, i only add command for work with files. It's not last version of this script, so i post new version leter, then come home.
 

Ravenal

Knight
I had that version until i made my own :p

My own uses my own mobile :p

Code:
/////////////////////////////////////////////////////////
// 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.Reflection;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Items;
using Server.Mobiles;
using Server.Misc;
using Server.Accounting;

namespace Server.Motd
{
	public class Motd : Gump
	{
		private Mobile m_From;
		public Mobile From{ get{ return m_From; } set{ m_From = value; } }
		public static int RunUOBeta = 36;
		public static double ShardVersion = 1.0;
		public static string ToDo = "Showing whats currently in project";
		public static string MessageoftheDay = "<text> *Offical Message*";

		public static void Initialize()
		{
			Server.Commands.Register( "UpdateMOTD", AccessLevel.Administrator, new CommandEventHandler( Update_OnCommand ) );
			Server.Commands.Register( "MOTD", AccessLevel.Player, new CommandEventHandler( MOTD_OnCommand ) );
			EventSink.Login += new LoginEventHandler( EventSink_Login );
		}
		
		[Usage( "Message of the Day" )]
		[Description( "Shows the Message of the Day" )]
		public static void MOTD_OnCommand( CommandEventArgs e )
		{
			ALPlayerMobile from = e.Mobile as ALPlayerMobile;
			e.Mobile.SendGump( new Motd( e.Mobile ) );
		}

		[Usage( "Updates the MOTD to turn all Mobile's MOTD false to True..." )]
		[Description( "Updates the MOTD to turn all Mobile's MOTD false to True..." )]
		public static void Update_OnCommand( CommandEventArgs e )
		{
			ArrayList mobs = new ArrayList( World.Mobiles.Values );

			e.Mobile.SendMessage( "You have sent the MOTD throughout the world, and activated it through Login..." );
				foreach ( Mobile m in mobs )
				{
					if ( m.Player )
					{
					ALPlayerMobile a = m as ALPlayerMobile;
						a.MOTD = true;
						a.SendGump( new Motd( m ) );
					}
				}
		}
		
		private static void EventSink_Login( LoginEventArgs args ) 
		{ 
			ALPlayerMobile from = args.Mobile as ALPlayerMobile;
		
			if ( from.MOTD != false )
			{
				args.Mobile.SendGump( new Motd( args.Mobile ) );
			}
		}

		public Motd( Mobile from ) : base( 10, 10 )
		{
			from.CloseGump( typeof( Motd ) );

			int gumpX = 0; 
			int gumpY = 0;

			m_From = from;

			Closable = false;
			Disposable = false;
			Dragable = true;
			Resizable = false;
			AddPage( 0 );

			gumpX = 80; gumpY = 25;
			AddBackground( gumpX, gumpY, 450, 400, 0x53 );

			gumpX = 315; gumpY = 165;
			AddHtml( gumpX, gumpY, 205, 210, String.Format( "<basefont color=#FFFFFF><center>* Things to Do *</center><br><br>{0}</basefont>", ToDo ), false, true );

			gumpX = 95; gumpY = 165;
			AddHtml( gumpX, gumpY, 205, 210, String.Format( "<basefont color=#FFFFFF><center>* Message of the Day *</center><br><br>{0}<br><br>Thank you,<br>Awaken Lands Staff</basefont>", MessageoftheDay ), false, true );

			gumpX = 185; gumpY = 397;
			AddLabel( gumpX, gumpY, 40, "© 2004, by Fantasy World Entertainment" );

			gumpX = 100; gumpY = 45;
			AddImage( gumpX, gumpY, 0x28D2 );

			gumpX = 470; gumpY = 45;
			AddImage( gumpX, gumpY, 0x28D2 );

			gumpX = 220; gumpY = 45;
			AddImage( gumpX, gumpY, 0x28D4 );

			gumpX = 95; gumpY = 100;
			AddHtml( gumpX, gumpY, 420, 20, "<basefont color=#0000FF><center>Awaken Lands Shard</center></basefont>", false, false );

			gumpX = 95; gumpY = 125;
			AddHtml( gumpX, gumpY, 200, 20, String.Format( "<basefont color=#0000FF><center>Shard Beta: RunUO Beta {0}</center></basefont>", RunUOBeta), false, false );

			gumpX = 305; gumpY = 125;
			AddHtml( gumpX, gumpY, 200, 20, String.Format( "<basefont color=#0000FF><center>Shard Version: Beta {0}</center></basefont>", ShardVersion ), false, false );

			gumpX = 450; gumpY = 380;
			AddButton( gumpX, gumpY, 0xFAE, 0xFB0, 0, GumpButtonType.Reply, 0 );
			
			gumpX = 95; gumpY = 380;
			AddLabel( gumpX, gumpY, 55, "Press this to close the Message of the Day." );
		}

		public override void OnResponse( NetState state, RelayInfo info )
		{
			Mobile from = state.Mobile;
			ALPlayerMobile m = from as ALPlayerMobile;

			switch( info.ButtonID )
			{
				case 0:
						if ( m.MOTD != false )
						{
							m.MOTD = false;
							m.SendMessage( "To view the MOTD again just do \"[motd\", and for more information on those commands do \"[help\"" );
						}
						else
						{
							from.SendMessage( "You close the MOTD." );
						}
					break;
			}
		}
	}
}
 

BondDLegion

Wanderer
First of all sorry for my bad English. It's not my primary language, and not secondary. :(

Sargonnas
1) yes, you'r version cleaner, but player can't read MOTD if accidentaly close the window, exept he relogin.
2) it's old version of this script with one 'bug'. Why you think admin MOTD gump have 2 button? Look in script, first button update news.txt, second button load changed news and mark all account. But it's maked for testing updated news. First button must update news.txt AND load changed news. After that admin test now look changed text and after all click on second button.

awakenlands
1) before add your script people must have ALPlayerMobile on his server.
2) if player have 3 char on account - he see you'r MOTD 3 time, with account tag - only one.

Well it's last version of this script.
In order to show MOTD gump to new players you need make some changes in CharacterCreation.cs
Find this code:
PHP:
		private static Mobile CreateMobile( Account a )
		{
			for ( int i = 0; i < 5; ++i )
				if ( a[i] == null )
					return (a[i] = new PlayerMobile());

			return null;
		}
And change on this:
PHP:
		private static Mobile CreateMobile( Account a )
		{
			int k = 0;
			for ( int j = 0; j < 5; ++j )
				if ( a[j] != null)
					++k;
			if (k == 0)
				a.SetTag( "motd", "false" );

			for ( int i = 0; i < 5; ++i )
				if ( a[i] == null )
					return (a[i] = new PlayerMobile());

			return null;
		}
Enjoy!
 

Attachments

  • motd.zip
    1.9 KB · Views: 722

Almassey

Sorceror
thx guys i've been looking for this script for awhile, but i have 1 problem. i made the news.txt file and then i looged on and did the [motd, clicked the ADD MOTD button and UPDATE NEWS button. i restarted my player and i still get a message of "There is no new news at this time."

What am i doing wrong?
 

juani

Wanderer
the button actually adds the contesnts of motd.txt to the beginning of news.txt

so u need to create a mod.txt with new stuff,a nd then use the button to merge them.
 

Almassey

Sorceror
Alright, I created the motd.txt file and added stuff in it. I sitll get the "There is no current news" when a player logs on. Can someone post a sample motd.txt & news.txt file so I can see what I am doing wrong?
 
C

chrisjones

Guest
doesnt load for me

Icon said:
Summary:
Ok first off I didn't make this script and I know your not supposed to repost someone else's work but seeing how old this script really is and 99.9% sure the script is no longer on the forms and was asked for the script....


Anyways a simple message of the day program, simple make a news.txt file in your runuo\data folder, and when players log in it will have info for them, something like sphere has.


Plus by placeing a check by the gump it will no longer show up when the player logs in.

Description:


Installation:
Copy motd.cs into your scripts\custom folder
Then make/update news.txt file in your runuo\data folder

Then log in with admin and type
[motd

A gump will show up this can be use to force and update so the next time a player logs in they can see the news. also the word motd by a player will popup the gump.

doesnt seem to work for me ive tried to figure out .....i have txt docu,ments in data folder and still doesnt load any idea why

Hk
 

nix4

Wanderer
I also get this error when making a new character, dunno why.

Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.Misc.NEWSGump.DisplayMessage(Mobile m)
at Server.Misc.NEWSGump.MOTD_Login(LoginEventArgs args)
at Server.LoginEventHandler.Invoke(LoginEventArgs e)
at Server.Network.PacketHandlers.DoLogin(NetState state, Mobile m)
at Server.Network.PacketHandlers.CreateCharacter(NetState state, PacketReader pvSrc)
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)
 

BondDLegion

Wanderer
nix4 said:
I also get this error when making a new character, dunno why.
Change this:
Code:
                private static bool DisplayMessage( Mobile m )
                {
                        Account acct=(Account)m.Account;
                        bool motd = Convert.ToBoolean( acct.GetTag("motd") );
                        if ( !motd )
                                return false;
                        return true;
                }
on this
Code:
                private static bool DisplayMessage( Mobile m )
                {
                     if(m != null)
                     {
                        Account acct=(Account)m.Account;
                        bool motd = Convert.ToBoolean( acct.GetTag("motd") );
                        if ( !motd )
                                return false;
                        return true;
                     }
                      return false;
                }
 
Top