All pastes #117851 Raw Edit

Ban krrrios client

public text v1 · immutable
·published 2006-08-06 02:56 UTC
rendered paste body
using System;
using Server.Network;

namespace Server.Misc
{
	public class BlockedClients
	{
		public static void Initialize()
		{
			// Register our event handler
			EventSink.Login += new LoginEventHandler( EventSink_Login );
		}

		private static void EventSink_Login( LoginEventArgs args )
		{
			Mobile from = args.Mobile;
			NetState ns = from.NetState;

			if(ns == null)
				return;

			new VersionTimer(ns).Start();
		}

		private class VersionTimer : Timer
		{
			private NetState m_State;
			public VersionTimer(NetState state) : base(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1))
			{
				m_State = state;
			}

			protected override void OnTick()
			{
				if(m_State == null || m_State.Version != null)
					Stop();

				if(m_State.Version != null && m_State.Version.SourceString == "4.0.8b")
				{
					int kickTime = 10;

					m_State.Mobile.Frozen = true;

					m_State.Mobile.SendMessage("Krrios client is not allowed on RealmUO.");
					m_State.Mobile.Say("Krrios client is not allowed on RealmUO.");

					m_State.Mobile.SendMessage("If you are not using Krrios client, please update.");
					m_State.Mobile.Say("If you are not using Krrios client, please update.");

					m_State.Mobile.SendMessage("You will be disconnected in 5 seconds.");
					m_State.Mobile.Say("You will be disconnected in {0} seconds.", kickTime.ToString());

					Timer.DelayCall(TimeSpan.FromSeconds(kickTime), new TimerStateCallback(Kick), m_State);
				}
			}

			private void Kick(object state)
			{
				if(state != null && state is NetState)
					((NetState)state).Dispose();
			}
		}
	}
}