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!

[Where Command problem

TheRedJackal

Sorceror
[Where Command problem

Hello, I have a problem with [where command, if I set [where command to use player, when the server restart the command return to set Counselor Use

What i can change to fix?
 
how are you setting it to player?

please show the script you modified for it, and your changes

because if in the script is says >= accesslevel.player then players should be included
 

TheRedJackal

Sorceror
Lord_Greywolf;766275 said:
how are you setting it to player?

please show the script you modified for it, and your changes

because if in the script is says >= accesslevel.player then players should be included

I change level in game with [commands, I have not found script for [where command :(
 

TheRedJackal

Sorceror
I have find in commands but I have not found relative to [ where commad :(

This is my commands script:

Code:
using System;
using System.Collections;
using System.IO;
using Server;
using Server.Scripts.Commands;

namespace Knives.Utils
{
	public class Commands
	{
		public static void Initialize()
		{
			Server.Commands.Register( "Commands", AccessLevel.Administrator, new CommandEventHandler( OnCommands ) );
			EventSink.Login += new LoginEventHandler( OnLogin );
		}

		private static void OnCommands( CommandEventArgs e )
		{
			CommandsGump.SendTo( e.Mobile );
		}

		private static Hashtable s_Defaults = new Hashtable();
		private static ArrayList s_InitInfo = new ArrayList();
		private static bool s_Inited;

		public static bool HasMod( string command )
		{
			return s_Defaults[command] != null && Server.Commands.Entries[command] != null;
		}

		public static void RestoreCommand( string command )
		{try{

			if ( !HasMod( command ) )
			{
				s_Defaults.Remove( command );
				Server.Commands.Entries.Remove( command );
				return;
			}

			DefaultInfo info = (DefaultInfo)s_Defaults[command];
			CommandEntry entry = new CommandEntry( info.OldCommand, ((CommandEntry)Server.Commands.Entries[command]).Handler, info.OldAccess );
			Server.Commands.Entries.Remove( command );

			if ( HasMod( info.OldCommand ) )
				RestoreCommand( info.OldCommand );

			Server.Commands.Entries[info.OldCommand] = entry;

			s_Defaults.Remove( command );

			foreach( BaseCommandImplementor imp in BaseCommandImplementor.Implementors )
				foreach( string str in new ArrayList( imp.Commands.Keys ) )
					if ( str == command )
					{
						imp.Commands[info.OldCommand] = imp.Commands[str];
						((BaseCommand)imp.Commands[str]).AccessLevel = info.OldAccess;

						if ( str != info.OldCommand )
							imp.Commands.Remove( str );
					}

		}catch{ Errors.Report( "Commands-> RestoreDefault" ); } }

		public static void ApplyCommand( string old, string txt )
		{try{

			if ( Server.Commands.Entries[txt] != null
			|| Server.Commands.Entries[old] == null )
				return;

			if ( HasMod( old ) )
			{
				((DefaultInfo)s_Defaults[old]).NewCommand = txt;
				s_Defaults[txt] = s_Defaults[old];
				s_Defaults.Remove( old );
			}
			else
			{
				DefaultInfo info = new DefaultInfo();
				info.OldCommand = old;
				info.NewCommand = txt;
				info.NewAccess = ((CommandEntry)Server.Commands.Entries[old]).AccessLevel;
				info.OldAccess = info.NewAccess;
				s_Defaults[txt] = info;
			}

			Server.Commands.Entries[txt] = Server.Commands.Entries[old];
			Server.Commands.Entries.Remove( old );

			foreach( BaseCommandImplementor imp in BaseCommandImplementor.Implementors )
				foreach( string str in new ArrayList( imp.Commands.Keys ) )
					if ( str == old )
					{
						imp.Commands[txt] = imp.Commands[str];
						imp.Commands.Remove( str );
					}

		}catch{ Errors.Report( "Commands-> ApplyCommand" ); } }

		public static void Access( string command, int num )
		{try{

			if ( Server.Commands.Entries[command] == null )
				return;

			DefaultInfo info = new DefaultInfo();

			if ( !HasMod( command ) )
			{
				info = new DefaultInfo();
				info.OldCommand = command;
				info.NewCommand = command;
				info.NewAccess = ((CommandEntry)Server.Commands.Entries[command]).AccessLevel+num;
				info.OldAccess = ((CommandEntry)Server.Commands.Entries[command]).AccessLevel;
				s_Defaults[command] = info;
			}
			else
			{
				info = (DefaultInfo)s_Defaults[command];
				info.NewAccess = info.NewAccess+num;
			}

			CommandEntry entry = new CommandEntry( command, ((CommandEntry)Server.Commands.Entries[command]).Handler, info.NewAccess );
			Server.Commands.Entries[command] = entry;

			foreach( BaseCommandImplementor imp in BaseCommandImplementor.Implementors )
				foreach( string str in new ArrayList( imp.Commands.Keys ) )
					if ( str == command )
						((BaseCommand)imp.Commands[str]).AccessLevel = info.NewAccess;

		}catch{ Errors.Report( "Commands-> Access-> Int" ); } }

		public static void Access( string command, AccessLevel level )
		{try{

			if ( Server.Commands.Entries[command] == null )
				return;

			DefaultInfo info = new DefaultInfo();

			if ( !HasMod( command ) )
			{
				info = new DefaultInfo();
				info.OldCommand = command;
				info.NewCommand = command;
				info.NewAccess = level;
				info.OldAccess = ((CommandEntry)Server.Commands.Entries[command]).AccessLevel;
				s_Defaults[command] = info;
			}
			else
			{
				info = (DefaultInfo)s_Defaults[command];
				info.NewAccess = level;
			}

			CommandEntry entry = new CommandEntry( command, ((CommandEntry)Server.Commands.Entries[command]).Handler, info.NewAccess );
			Server.Commands.Entries[command] = entry;

			foreach( BaseCommandImplementor imp in BaseCommandImplementor.Implementors )
				foreach( string str in new ArrayList( imp.Commands.Keys ) )
					if ( str == command )
						((BaseCommand)imp.Commands[str]).AccessLevel = info.NewAccess;

		}catch{ Errors.Report( "Commands-> Access-> AccessLevel" ); } }

		public static void Configure()
		{
			EventSink.WorldLoad += new WorldLoadEventHandler( OnLoad );
			EventSink.WorldSave += new WorldSaveEventHandler( OnSave );
		}

		private static void OnSave( WorldSaveEventArgs e )
		{try{

			if ( !Directory.Exists( "Saves/Commands/" ) )
				Directory.CreateDirectory( "Saves/Commands/" );

			GenericWriter writer = new BinaryFileWriter( Path.Combine( "Saves/Commands/", "Commands.bin" ), true );

			writer.Write( 0 ); // version

			ArrayList list = new ArrayList( s_Defaults.Values );

			writer.Write( list.Count );

			foreach( DefaultInfo info in list )
			{
				writer.Write( info.NewCommand );
				writer.Write( info.OldCommand );
				writer.Write( (int)info.NewAccess );
			}

			writer.Close();

		}catch{ Errors.Report( "Commands-> OnSave" ); } }

		private static void OnLoad()
		{try{

			if ( !File.Exists( Path.Combine( "Saves/Commands/", "Commands.bin" ) ) )
				return;

			using ( FileStream bin = new FileStream( Path.Combine( "Saves/Commands/", "Commands.bin" ), FileMode.Open, FileAccess.Read, FileShare.Read ) )
			{
				GenericReader reader = new BinaryFileReader( new BinaryReader( bin ) );

				int version = reader.ReadInt();

				int count = reader.ReadInt();

				object[] obj;
				for( int i = 0; i < count; ++i )
				{
					obj = new object[3];
					obj[0] = reader.ReadString();
					obj[1] = reader.ReadString();
					obj[2] = reader.ReadInt();
					s_InitInfo.Add( obj );
				}
			}
		}catch{ Errors.Report( "Commands-> OnLoad" ); } }

		private static void OnLogin( LoginEventArgs e )
		{
			if ( s_Inited )
				return;

			s_Inited = true;

			foreach( object[] obj in s_InitInfo )
			{
				ApplyCommand( obj[1].ToString(), obj[0].ToString() );
				Access( obj[0].ToString(), (AccessLevel)obj[2] );
			}
		}

		private class DefaultInfo
		{
			private string c_NewCommand;
			private string c_OldCommand;
			private AccessLevel c_NewAccess;
			private AccessLevel c_OldAccess;

			public string NewCommand{ get{ return c_NewCommand; } set{ c_NewCommand = value; } }
			public string OldCommand{ get{ return c_OldCommand; } set{ c_OldCommand = value; } }
			public AccessLevel NewAccess{ get{ return c_NewAccess; } set{ c_NewAccess = value; } }
			public AccessLevel OldAccess{ get{ return c_OldAccess; } set{ c_OldAccess = value; } }

			public DefaultInfo()
			{
			}
		}
	}
}


Or This, in Scripts\Commands\Abstracted\Commands

Code:
using System;
using System.Net;
using System.Net.Sockets;
using System.Collections;
using Server;
using Server.Items;
using Server.Gumps;
using Server.Spells;
using Server.Multis;
using Server.Mobiles;
using Server.Network;
using Server.Accounting;

namespace Server.Scripts.Commands
{
	public class TargetCommands
	{
		public static void Initialize()
		{
			Register( new KillCommand( true ) );
			Register( new KillCommand( false ) );
			Register( new HideCommand( true ) );
			Register( new HideCommand( false ) );
			Register( new KickCommand( true ) );
			Register( new KickCommand( false ) );
			Register( new FirewallCommand() );
			Register( new TeleCommand() );
			Register( new SetCommand() );
			Register( new AliasedSetCommand( AccessLevel.GameMaster, "Immortal", "blessed", "true", ObjectTypes.Mobiles ) );
			Register( new AliasedSetCommand( AccessLevel.GameMaster, "Invul", "blessed", "true", ObjectTypes.Mobiles ) );
			Register( new AliasedSetCommand( AccessLevel.GameMaster, "Mortal", "blessed", "false", ObjectTypes.Mobiles ) );
			Register( new AliasedSetCommand( AccessLevel.GameMaster, "NoInvul", "blessed", "false", ObjectTypes.Mobiles ) );
			Register( new AliasedSetCommand( AccessLevel.GameMaster, "Squelch", "squelched", "true", ObjectTypes.Mobiles ) );
			Register( new AliasedSetCommand( AccessLevel.GameMaster, "Unsquelch", "squelched", "false", ObjectTypes.Mobiles ) );
			Register( new GetCommand() );
			Register( new GetTypeCommand() );
			Register( new DeleteCommand() );
			Register( new RestockCommand() );
			Register( new DismountCommand() );
			Register( new AddCommand() );
			Register( new AddToPackCommand() );
			Register( new TellCommand() );
			Register( new PrivSoundCommand() );
			Register( new IncreaseCommand() );
			Register( new OpenBrowserCommand() );
			Register( new CountCommand() );
			Register( new InterfaceCommand() );
			Register( new RefreshHouseCommand() );
			Register( new ConditionCommand() );
			Register( new Factions.FactionKickCommand( Factions.FactionKickType.Kick ) );
			Register( new Factions.FactionKickCommand( Factions.FactionKickType.Ban ) );
			Register( new Factions.FactionKickCommand( Factions.FactionKickType.Unban ) );
			Register( new BringToPackCommand() );
		}

		private static ArrayList m_AllCommands = new ArrayList();

		public static ArrayList AllCommands{ get{ return m_AllCommands; } }

		public static void Register( BaseCommand command )
		{
			m_AllCommands.Add( command );

			ArrayList impls = BaseCommandImplementor.Implementors;

			for ( int i = 0; i < impls.Count; ++i )
			{
				BaseCommandImplementor impl = (BaseCommandImplementor)impls[i];

				if ( (command.Supports & impl.SupportRequirement) != 0 )
					impl.Register( command );
			}
		}
	}

	public class ConditionCommand : BaseCommand
	{
		public ConditionCommand()
		{
			AccessLevel = AccessLevel.GameMaster;
			Supports = CommandSupport.Simple | CommandSupport.Complex | CommandSupport.Self;
			Commands = new string[]{ "Condition" };
			ObjectTypes = ObjectTypes.All;
			Usage = "Condition <condition>";
			Description = "Checks that the given condition matches a targeted object.";
			ListOptimized = true;
		}

		public override void ExecuteList( CommandEventArgs e, ArrayList list )
		{
			try
			{
				string[] args = e.Arguments;
				ObjectConditional condition = ObjectConditional.Parse( e.Mobile, ref args );

				for ( int i = 0; i < list.Count; ++i )
				{
					if ( condition.CheckCondition( list[i] ) )
						AddResponse( "True - that object matches the condition." );
					else
						AddResponse( "False - that object does not match the condition." );
				}
			}
			catch ( Exception ex )
			{
				e.Mobile.SendMessage( ex.Message );
			}
		}
	}

	public class BringToPackCommand : BaseCommand
	{
		public BringToPackCommand()
		{
			AccessLevel = AccessLevel.GameMaster;
			Supports = CommandSupport.AllItems;
			Commands = new string[]{ "BringToPack" };
			ObjectTypes = ObjectTypes.Items;
			Usage = "BringToPack";
			Description = "Brings a targeted item to your backpack.";
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			Item item = obj as Item;

			if ( item != null )
			{
				if ( e.Mobile.PlaceInBackpack( item ) )
					AddResponse( "The item has been placed in your backpack." );
				else
					AddResponse( "Your backpack could not hold the item." );
			}
		}
	}

	public class RefreshHouseCommand : BaseCommand
	{
		public RefreshHouseCommand()
		{
			AccessLevel = AccessLevel.GameMaster;
			Supports = CommandSupport.Simple;
			Commands = new string[]{ "RefreshHouse" };
			ObjectTypes = ObjectTypes.Items;
			Usage = "RefreshHouse";
			Description = "Refreshes a targeted house sign.";
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			if ( obj is HouseSign )
			{
				BaseHouse house = ((HouseSign)obj).Owner;

				if ( house == null )
				{
					LogFailure( "That sign has no house attached." );
				}
				else
				{
					house.RefreshDecay();
					AddResponse( "The house has been refreshed." );
				}
			}
			else
			{
				LogFailure( "That is not a house sign." );
			}
		}
	}

	public class CountCommand : BaseCommand
	{
		public CountCommand()
		{
			AccessLevel = AccessLevel.GameMaster;
			Supports = CommandSupport.Complex;
			Commands = new string[]{ "Count" };
			ObjectTypes = ObjectTypes.All;
			Usage = "Count";
			Description = "Counts the number of objects that a command modifier would use. Generally used with condition arguments.";
			ListOptimized = true;
		}

		public override void ExecuteList( CommandEventArgs e, ArrayList list )
		{
			if ( list.Count == 1 )
				AddResponse( "There is one matching object." );
			else
				AddResponse( String.Format( "There are {0} matching objects.", list.Count ) );
		}
	}

	public class OpenBrowserCommand : BaseCommand
	{
		public OpenBrowserCommand()
		{
			AccessLevel = AccessLevel.GameMaster;
			Supports = CommandSupport.AllMobiles;
			Commands = new string[]{ "OpenBrowser", "OB" };
			ObjectTypes = ObjectTypes.Mobiles;
			Usage = "OpenBrowser <url>";
			Description = "Opens the web browser of a targeted player to a specified url.";
		}

		public static void OpenBrowser_Callback( Mobile from, bool okay, object state )
		{
			object[] states = (object[])state;
			Mobile gm = (Mobile)states[0];
			string url = (string)states[1];

			if ( okay )
			{
				gm.SendMessage( "{0} : has opened their web browser to : {1}", from.Name, url );
				from.LaunchBrowser( url );
			}
			else
			{
				from.SendMessage( "You have chosen not to open your web browser." );
				gm.SendMessage( "{0} : has chosen not to open their web browser to : {1}", from.Name, url );
			}
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			if ( e.Length == 1 )
			{
				Mobile mob = (Mobile)obj;
				Mobile from = e.Mobile;

				if ( mob.Player )
				{
					NetState ns = mob.NetState;

					if ( ns == null )
					{
						LogFailure( "That player is not online." );
					}
					else
					{
						string url = e.GetString( 0 );

						CommandLogging.WriteLine( from, "{0} {1} requesting to open web browser of {2} to {3}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( mob ), url );
						AddResponse( "Awaiting user confirmation..." );
						mob.SendGump( new WarningGump( 1060637, 30720, String.Format( "A game master is requesting to open your web browser to the following URL:<br>{0}", url ), 0xFFC000, 320, 240, new WarningGumpCallback( OpenBrowser_Callback ), new object[]{ from, url } ) );
					}
				}
				else
				{
					LogFailure( "That is not a player." );
				}
			}
			else
			{
				LogFailure( "Format: OpenBrowser <url>" );
			}
		}
	}

	public class IncreaseCommand : BaseCommand
	{
		public IncreaseCommand()
		{
			AccessLevel = AccessLevel.Counselor;
			Supports = CommandSupport.All;
			Commands = new string[]{ "Increase", "Inc" };
			ObjectTypes = ObjectTypes.Both;
			Usage = "Increase {<propertyName> <offset> ...}";
			Description = "Increases the value of a specified property by the specified offset.";
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			if ( obj is BaseMulti )
			{
				LogFailure( "This command does not work on multis." );
			}
			else if ( e.Length >= 2 )
			{
				string result = Properties.IncreaseValue( e.Mobile, obj, e.Arguments );

				if ( result == "The property has been increased." || result == "The properties have been increased." || result == "The property has been decreased." || result == "The properties have been decreased." || result == "The properties have been changed." )
					AddResponse( result );
				else
					LogFailure( result );
			}
			else
			{
				LogFailure( "Format: Increase {<propertyName> <offset> ...}" );
			}
		}
	}

	public class PrivSoundCommand : BaseCommand
	{
		public PrivSoundCommand()
		{
			AccessLevel = AccessLevel.GameMaster;
			Supports = CommandSupport.AllMobiles;
			Commands = new string[]{ "PrivSound" };
			ObjectTypes = ObjectTypes.Mobiles;
			Usage = "PrivSound <index>";
			Description = "Plays a sound to a given target.";
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			Mobile from = e.Mobile;

			if ( e.Length == 1 )
			{
				int index = e.GetInt32( 0 );
				Mobile mob = (Mobile)obj;

				CommandLogging.WriteLine( from, "{0} {1} playing sound {2} for {3}", from.AccessLevel, CommandLogging.Format( from ), index, CommandLogging.Format( mob ) );
				mob.Send( new PlaySound( index, mob.Location ) );
			}
			else
			{
				from.SendMessage( "Format: PrivSound <index>" );
			}
		}
	}

	public class TellCommand : BaseCommand
	{
		public TellCommand()
		{
			AccessLevel = AccessLevel.Counselor;
			Supports = CommandSupport.AllMobiles;
			Commands = new string[]{ "Tell" };
			ObjectTypes = ObjectTypes.Mobiles;
			Usage = "Tell \"text\"";
			Description = "Sends a system message to a targeted player.";
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			Mobile mob = (Mobile)obj;
			Mobile from = e.Mobile;

			CommandLogging.WriteLine( from, "{0} {1} telling {2} \"{3}\"", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( mob ), e.ArgString );

			mob.SendMessage( e.ArgString );
		}
	}

	public class AddToPackCommand : BaseCommand
	{
		public AddToPackCommand()
		{
			AccessLevel = AccessLevel.GameMaster;
			Supports = CommandSupport.All;
			Commands = new string[]{ "AddToPack", "AddToCont" };
			ObjectTypes = ObjectTypes.Both;
			ListOptimized = true;
			Usage = "AddToPack <name> [params] [set {<propertyName> <value> ...}]";
			Description = "Adds an item by name to the backpack of a targeted player or npc, or a targeted container. Optional constructor parameters. Optional set property list.";
		}

		public override void ExecuteList( CommandEventArgs e, ArrayList list )
		{
			ArrayList packs = new ArrayList( list.Count );

			for ( int i = 0; i < list.Count; ++i )
			{
				object obj = list[i];
				Container cont = null;

				if ( obj is Mobile )
					cont = ((Mobile)obj).Backpack;
				else if ( obj is Container )
					cont = (Container)obj;

				if ( cont != null )
					packs.Add( cont );
				else
					LogFailure( "That is not a container." );
			}

			Add.Invoke( e.Mobile, e.Mobile.Location, e.Mobile.Location, e.Arguments, packs );
		}
	}

	public class AddCommand : BaseCommand
	{
		public AddCommand()
		{
			AccessLevel = AccessLevel.GameMaster;
			Supports = CommandSupport.Simple | CommandSupport.Self;
			Commands = new string[]{ "Add" };
			ObjectTypes = ObjectTypes.All;
			Usage = "Add [<name> [params] [set {<propertyName> <value> ...}]]";
			Description = "Adds an item or npc by name to a targeted location. Optional constructor parameters. Optional set property list. If no arguments are specified, this brings up a categorized add menu.";
		}

		public override bool ValidateArgs( BaseCommandImplementor impl, CommandEventArgs e )
		{
			if ( e.Length >= 1 )
			{
				Type t = ScriptCompiler.FindTypeByName( e.GetString( 0 ) );

				if ( t == null )
				{
					e.Mobile.SendMessage( "No type with that name was found." );

					string match = e.GetString( 0 ).Trim();

					if ( match.Length < 3 )
					{
						e.Mobile.SendMessage( "Invalid search string." );
						e.Mobile.SendGump( new Server.Gumps.AddGump( e.Mobile, match, 0, Type.EmptyTypes, false ) );
					}
					else
					{
						e.Mobile.SendGump( new Server.Gumps.AddGump( e.Mobile, match, 0, (Type[])Server.Gumps.AddGump.Match( match ).ToArray( typeof( Type ) ), true ) );
					}
				}
				else
				{
					return true;
				}
			}
			else
			{
				e.Mobile.SendGump( new Server.Gumps.CategorizedAddGump( e.Mobile ) );
			}

			return false;
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			IPoint3D p = obj as IPoint3D;

			if ( p == null )
				return;

			if ( p is Item )
				p = ((Item)p).GetWorldTop();
			else if ( p is Mobile )
				p = ((Mobile)p).Location;

			Add.Invoke( e.Mobile, new Point3D( p ), new Point3D( p ), e.Arguments );
		}
	}

	public class TeleCommand : BaseCommand
	{
		public TeleCommand()
		{
			AccessLevel = AccessLevel.Counselor;
			Supports = CommandSupport.Simple;
			Commands = new string[]{ "Teleport", "Tele" };
			ObjectTypes = ObjectTypes.All;
			Usage = "Teleport";
			Description = "Teleports your character to a targeted location.";
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			IPoint3D p = obj as IPoint3D;

			if ( p == null )
				return;

			Mobile from = e.Mobile;

			SpellHelper.GetSurfaceTop( ref p );

			CommandLogging.WriteLine( from, "{0} {1} teleporting to {2}", from.AccessLevel, CommandLogging.Format( from ), new Point3D( p ) );

			Point3D fromLoc = from.Location;
			Point3D toLoc = new Point3D( p );

			from.Location = toLoc;
			from.ProcessDelta();

			if ( !from.Hidden )
			{
				Effects.SendLocationParticles( EffectItem.Create( fromLoc, from.Map, EffectItem.DefaultDuration ), 0x3728, 10, 10, 2023 );
				Effects.SendLocationParticles( EffectItem.Create(   toLoc, from.Map, EffectItem.DefaultDuration ), 0x3728, 10, 10, 5023 );

				//from.PlaySound( 0x1FE );
			}
		}
	}

	public class DismountCommand : BaseCommand
	{
		public DismountCommand()
		{
			AccessLevel = AccessLevel.GameMaster;
			Supports = CommandSupport.AllMobiles;
			Commands = new string[]{ "Dismount" };
			ObjectTypes = ObjectTypes.Mobiles;
			Usage = "Dismount";
			Description = "Forcefully dismounts a given target.";
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			Mobile from = e.Mobile;
			Mobile mob = (Mobile)obj;

			CommandLogging.WriteLine( from, "{0} {1} dismounting {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( mob ) );

			bool takenAction = false;

			for ( int i = 0; i < mob.Items.Count; ++i )
			{
				Item item = (Item)mob.Items[i];

				if ( item is IMountItem )
				{
					IMount mount = ((IMountItem)item).Mount;

					if ( mount != null )
					{
						mount.Rider = null;
						takenAction = true;
					}

					if ( mob.Items.IndexOf( item ) == -1 )
						--i;
				}
			}

			for ( int i = 0; i < mob.Items.Count; ++i )
			{
				Item item = (Item)mob.Items[i];

				if ( item.Layer == Layer.Mount )
				{
					takenAction = true;
					item.Delete();
					--i;
				}
			}

			if ( takenAction )
				AddResponse( "They have been dismounted." );
			else
				LogFailure( "They were not mounted." );
		}
	}

	public class RestockCommand : BaseCommand
	{
		public RestockCommand()
		{
			AccessLevel = AccessLevel.GameMaster;
			Supports = CommandSupport.AllNPCs;
			Commands = new string[]{ "Restock" };
			ObjectTypes = ObjectTypes.Mobiles;
			Usage = "Restock";
			Description = "Manually restocks a targeted vendor, refreshing the quantity of every item the vendor sells to the maximum. This also invokes the maximum quantity adjustment algorithms.";
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			if ( obj is BaseVendor )
			{
				CommandLogging.WriteLine( e.Mobile, "{0} {1} restocking {2}", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), CommandLogging.Format( obj ) );

				((BaseVendor)obj).Restock();
				AddResponse( "The vendor has been restocked." );
			}
			else
			{
				AddResponse( "That is not a vendor." );
			}
		}
	}

	public class GetTypeCommand : BaseCommand
	{
		public GetTypeCommand()
		{
			AccessLevel = AccessLevel.Counselor;
			Supports = CommandSupport.All;
			Commands = new string[]{ "GetType" };
			ObjectTypes = ObjectTypes.All;
			Usage = "GetType";
			Description = "Gets the type name of a targeted object.";
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			if ( obj == null )
			{
				AddResponse( "The object is null." );
			}
			else
			{
				Type type = obj.GetType();

				if ( type.DeclaringType == null )
					AddResponse( String.Format( "The type of that object is {0}.", type.Name ) );
				else
					AddResponse( String.Format( "The type of that object is {0}.", type.FullName ) );
			}
		}
	}

	public class GetCommand : BaseCommand
	{
		public GetCommand()
		{
			AccessLevel = AccessLevel.Counselor;
			Supports = CommandSupport.All;
			Commands = new string[]{ "Get" };
			ObjectTypes = ObjectTypes.All;
			Usage = "Get <propertyName>";
			Description = "Gets one or more property values by name of a targeted object.";
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			if ( e.Length >= 1 )
			{
				for ( int i = 0; i < e.Length; ++i )
				{
					string result = Properties.GetValue( e.Mobile, obj, e.GetString( i ) );

					if ( result == "Property not found." || result == "Property is write only." || result.StartsWith( "Getting this property" ) )
						LogFailure( result );
					else
						AddResponse( result );
				}
			}
			else
			{
				LogFailure( "Format: Get <propertyName>" );
			}
		}
	}

	public class AliasedSetCommand : BaseCommand
	{
		private string m_Name;
		private string m_Value;

		public AliasedSetCommand( AccessLevel level, string command, string name, string value, ObjectTypes objects )
		{
			m_Name = name;
			m_Value = value;

			AccessLevel = level;

			if ( objects == ObjectTypes.Items )
				Supports = CommandSupport.AllItems;
			else if ( objects == ObjectTypes.Mobiles )
				Supports = CommandSupport.AllMobiles;
			else
				Supports = CommandSupport.All;

			Commands = new string[]{ command };
			ObjectTypes = objects;
			Usage = command;
			Description = String.Format( "Sets the {0} property to {1}.", name, value );
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			string result = Properties.SetValue( e.Mobile, obj, m_Name, m_Value );

			if ( result == "Property has been set." )
				AddResponse( result );
			else
				LogFailure( result );
		}
	}

	public class SetCommand : BaseCommand
	{
		public SetCommand()
		{
			AccessLevel = AccessLevel.Counselor;
			Supports = CommandSupport.All;
			Commands = new string[]{ "Set" };
			ObjectTypes = ObjectTypes.Both;
			Usage = "Set <propertyName> <value> [...]";
			Description = "Sets one or more property values by name of a targeted object.";
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			if ( e.Length >= 2 )
			{
				for ( int i = 0; (i+1) < e.Length; i += 2 )
				{
					string result = Properties.SetValue( e.Mobile, obj, e.GetString( i ), e.GetString( i+1 ) );

					if ( result == "Property has been set." )
						AddResponse( result );
					else
						LogFailure( result );
				}
			}
			else
			{
				LogFailure( "Format: Set <propertyName> <value>" );
			}
		}
	}

	public class DeleteCommand : BaseCommand
	{
		public DeleteCommand()
		{
			AccessLevel = AccessLevel.GameMaster;
			Supports = CommandSupport.AllNPCs | CommandSupport.AllItems;
			Commands = new string[]{ "Delete", "Remove" };
			ObjectTypes = ObjectTypes.Both;
			Usage = "Delete";
			Description = "Deletes a targeted item or mobile. Does not delete players.";
		}

		private void OnConfirmCallback( Mobile from, bool okay, object state )
		{
			object[] states = (object[])state;
			CommandEventArgs e = (CommandEventArgs)states[0];
			ArrayList list = (ArrayList)states[1];

			bool flushToLog = false;

			if ( okay )
			{
				AddResponse( "Delete command confirmed." );

				if ( list.Count > 20 )
					CommandLogging.Enabled = false;

				base.ExecuteList( e, list );

				if ( list.Count > 20 )
				{
					flushToLog = true;
					CommandLogging.Enabled = true;
				}
			}
			else
			{
				AddResponse( "Delete command aborted." );
			}

			Flush( from, flushToLog );
		}

		public override void ExecuteList( CommandEventArgs e, ArrayList list )
		{
			if ( list.Count > 1 )
			{
				e.Mobile.SendGump( new WarningGump( 1060637, 30720, String.Format( "You are about to delete {0} objects. This cannot be undone without a full server revert.<br><br>Continue?", list.Count ), 0xFFC000, 420, 280, new WarningGumpCallback( OnConfirmCallback ), new object[]{ e, list } ) );
				AddResponse( "Awaiting confirmation..." );
			}
			else
			{
				base.ExecuteList( e, list );
			}
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			if ( obj is Item )
			{
				CommandLogging.WriteLine( e.Mobile, "{0} {1} deleting {2}", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), CommandLogging.Format( obj ) );
				((Item)obj).Delete();
				AddResponse( "The item has been deleted." );
			}
			else if ( obj is Mobile && !((Mobile)obj).Player )
			{
				CommandLogging.WriteLine( e.Mobile, "{0} {1} deleting {2}", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), CommandLogging.Format( obj ) );
				((Mobile)obj).Delete();
				AddResponse( "The mobile has been deleted." );
			}
			else
			{
				LogFailure( "That cannot be deleted." );
			}
		}
	}

	public class KillCommand : BaseCommand
	{
		private bool m_Value;

		public KillCommand( bool value )
		{
			m_Value = value;

			AccessLevel = AccessLevel.GameMaster;
			Supports = CommandSupport.AllMobiles;
			Commands = value ? new string[]{ "Kill" } : new string[]{ "Resurrect", "Res" };
			ObjectTypes = ObjectTypes.Mobiles;

			if ( value )
			{
				Usage = "Kill";
				Description = "Kills a targeted player or npc.";
			}
			else
			{
				Usage = "Resurrect";
				Description = "Resurrects a targeted ghost.";
			}
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			Mobile mob = (Mobile)obj;
			Mobile from = e.Mobile;

			if ( m_Value )
			{
				if ( !mob.Alive )
				{
					LogFailure( "They are already dead." );
				}
				else if ( !mob.CanBeDamaged() )
				{
					LogFailure( "They cannot be harmed." );
				}
				else
				{
					CommandLogging.WriteLine( from, "{0} {1} killing {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( mob ) );
					mob.Kill();

					AddResponse( "They have been killed." );
				}
			}
			else
			{
				if ( mob.IsDeadBondedPet )
				{
					BaseCreature bc = mob as BaseCreature;

					if ( bc != null )
					{
						CommandLogging.WriteLine( from, "{0} {1} resurrecting {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( mob ) );

						bc.PlaySound( 0x214 );
						bc.FixedEffect( 0x376A, 10, 16 );

						bc.ResurrectPet();

						AddResponse( "It has been resurrected." );
					}
				}
				else if ( !mob.Alive )
				{
					CommandLogging.WriteLine( from, "{0} {1} resurrecting {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( mob ) );

					mob.PlaySound( 0x214 );
					mob.FixedEffect( 0x376A, 10, 16 );

					mob.Resurrect();

					AddResponse( "They have been resurrected." );
				}
				else
				{
					LogFailure( "They are not dead." );
				}
			}
		}
	}

	public class HideCommand : BaseCommand
	{
		private bool m_Value;

		public HideCommand( bool value )
		{
			m_Value = value;

			AccessLevel = AccessLevel.Counselor;
			Supports = CommandSupport.AllMobiles;
			Commands = new string[]{ value ? "Hide" : "Unhide" };
			ObjectTypes = ObjectTypes.Mobiles;

			if ( value )
			{
				Usage = "Hide";
				Description = "Makes a targeted mobile disappear in a puff of smoke.";
			}
			else
			{
				Usage = "Unhide";
				Description = "Makes a targeted mobile appear in a puff of smoke.";
			}
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			Mobile m = (Mobile)obj;

			CommandLogging.WriteLine( e.Mobile, "{0} {1} {2} {3}", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), m_Value ? "hiding" : "unhiding", CommandLogging.Format( m ) );

			m.FixedParticles( 0x3709, 10, 30, 5052, EffectLayer.LeftFoot );
			m.PlaySound( 0x208 );
			
			
			m.Hidden = m_Value;

			if ( m_Value )
				AddResponse( "They have been hidden." );
			else
				AddResponse( "They have been revealed." );
		}
	}

	public class FirewallCommand : BaseCommand
	{
		public FirewallCommand()
		{
			AccessLevel = AccessLevel.Administrator;
			Supports = CommandSupport.AllMobiles;
			Commands = new string[]{ "Firewall" };
			ObjectTypes = ObjectTypes.Mobiles;
			Usage = "Firewall";
			Description = "Adds a targeted player to the firewall (list of blocked IP addresses). This command does not ban or kick.";
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			Mobile from = e.Mobile;
			Mobile targ = (Mobile)obj;
			NetState state = targ.NetState;

			if ( state != null )
			{
				CommandLogging.WriteLine( from, "{0} {1} firewalling {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( targ ) );

				try
				{
					Firewall.Add( ((IPEndPoint)state.Socket.RemoteEndPoint).Address );
					AddResponse( "They have been firewalled." );
				}
				catch ( Exception ex )
				{
					LogFailure( ex.Message );
				}
			}
			else
			{
				LogFailure( "They are not online." );
			}
		}
	}

	public class KickCommand : BaseCommand
	{
		private bool m_Ban;

		public KickCommand( bool ban )
		{
			m_Ban = ban;

			AccessLevel = ( ban ? AccessLevel.Administrator : AccessLevel.GameMaster );
			Supports = CommandSupport.AllMobiles;
			Commands = new string[]{ ban ? "Ban" : "Kick" };
			ObjectTypes = ObjectTypes.Mobiles;

			if ( ban )
			{
				Usage = "Ban";
				Description = "Bans the account of a targeted player.";
			}
			else
			{
				Usage = "Kick";
				Description = "Disconnects a targeted player.";
			}
		}

		public override void Execute( CommandEventArgs e, object obj )
		{
			Mobile from = e.Mobile;
			Mobile targ = (Mobile)obj;

			if ( from.AccessLevel > targ.AccessLevel )
			{
				NetState fromState = from.NetState, targState = targ.NetState;

				if ( fromState != null && targState != null )
				{
					Account fromAccount = fromState.Account as Account;
					Account targAccount = targState.Account as Account;

					if ( fromAccount != null && targAccount != null )
					{
						CommandLogging.WriteLine( from, "{0} {1} {2} {3}", from.AccessLevel, CommandLogging.Format( from ), m_Ban ? "banning" : "kicking", CommandLogging.Format( targ ) );

						targ.Say( "I've been {0}!", m_Ban ? "banned" : "kicked" );

						AddResponse( String.Format( "They have been {0}.", m_Ban ? "banned" : "kicked" ) );

						targState.Dispose();

						if ( m_Ban )
						{
							targAccount.Banned = true;
							targAccount.SetUnspecifiedBan( from );
							from.SendGump( new BanDurationGump( targAccount ) );
						}
					}
				}
				else if ( targState == null )
				{
					LogFailure( "They are not online." );
				}
			}
			else
			{
				LogFailure( "You do not have the required access level to do this." );
			}
		}
	}
}
 

Soteric

Knight
Search the text IN files, not the file name :)
Code:
Find all ""where"", Subfolders, Find Results 1
Scripts\Commands\Batch.cs(170):				else if ( m_Condition.Length > 0 && !Utility.InsensitiveStartsWith( m_Condition, "where" ) )
Scripts\Commands\Handlers.cs(39):			Register( "Where", AccessLevel.Counselor, new CommandEventHandler( Where_OnCommand ) );
Scripts\Commands\Handlers.cs(120):			[Usage( "Where" )]
Scripts\Commands\Generic\Extensions\WhereExtension.cs(11):	public static ExtensionInfo ExtInfo = new ExtensionInfo( 20, "Where", -1, delegate() { return new WhereExtension(); } );
Scripts\Commands\Generic\Implementors\ObjectConditional.cs(82):	if ( Insensitive.Equals( args[i], "where" ) )
  Matching lines: 5    Matching files: 4    Total files searched: 2597
I hope it helps
 

TheRedJackal

Sorceror
Soteric;766380 said:
Search the text IN files, not the file name :)
Code:
Find all ""where"", Subfolders, Find Results 1
Scripts\Commands\Batch.cs(170):				else if ( m_Condition.Length > 0 && !Utility.InsensitiveStartsWith( m_Condition, "where" ) )
Scripts\Commands\Handlers.cs(39):			Register( "Where", AccessLevel.Counselor, new CommandEventHandler( Where_OnCommand ) );
Scripts\Commands\Handlers.cs(120):			[Usage( "Where" )]
Scripts\Commands\Generic\Extensions\WhereExtension.cs(11):	public static ExtensionInfo ExtInfo = new ExtensionInfo( 20, "Where", -1, delegate() { return new WhereExtension(); } );
Scripts\Commands\Generic\Implementors\ObjectConditional.cs(82):	if ( Insensitive.Equals( args[i], "where" ) )
  Matching lines: 5    Matching files: 4    Total files searched: 2597
I hope it helps

Yes Tnx :D

Tnx for your Help :)
 
Top