CODE |
using System; using System.Text; using Server; using Server.Items; using Server.Network; using System.Collections; using System.Reflection; using Server.Targeting; using Server.Mobiles; using Server.Multis; using Server.Engines.XmlSpawner2; using Server.Gumps; namespace Server.Scripts.Commands { public class GenericCommand { public static void Initialize() { Server.Commands.Register( "g", AccessLevel.GameMaster, new CommandEventHandler( GenericCommand_OnCommand ) ); } public class GenericTarget : Target { public GenericTarget() : base(30, true, TargetFlags.None) { CheckLOS = false; } protected override void OnTarget( Mobile from, object targeted ) { if(from == null || targeted == null) return; if(targeted is Mobile) { Mobile m = (Mobile)targeted; m.Say("hello there"); } } } [Usage( "g" )] public static void GenericCommand_OnCommand( CommandEventArgs e ) { e.Mobile.Target = new GenericTarget(); } } } |
CODE |
using System; using Server; using Server.Mobiles; using Server.Targeting; namespace Server.Scripts.Commands { public class HaltPlayer { public static void Initialize() { Register(); } public static void Register() { Server.Commands.Register( "HaltPlayer", AccessLevel.GameMaster, new CommandEventHandler( HaltPlayer_OnCommand ) ); Server.Commands.Register( "HP", AccessLevel.GameMaster, new CommandEventHandler( HaltPlayer_OnCommand ) ); } [Usage( "HaltPlayer" )] [Aliases( "HP" )] [Description( "Freezes player in their path, while squelching. Or returns the player to normal." )] private static void HaltPlayer_OnCommand( CommandEventArgs e ) { e.Mobile.SendMessage( "Target the player to freeze and squelch." ); e.Mobile.Target = new FreezeAndSquelchTarget(); } public class FreezeAndSquelchTarget : Target { public FreezeAndSquelchTarget() : base( -1, true, TargetFlags.None ) { } protected override void OnTarget( Mobile staff, object player ) { if( !(player is PlayerMobile) ) { staff.SendMessage( "That is not a player." ); return; } PlayerMobile pm = (Mobile)player as PlayerMobile; if( !pm.Player ) { staff.SendMessage( "You can only use this on a player." ); return; } else { if( !pm.Frozen || !pm.Squelched ) { pm.Frozen = true; pm.Squelched = true; pm.SendMessage( "Staff member {0} has stopped you, you may not speak.", staff.Name ); } else { pm.Frozen = false; pm.Squelched = false; pm.SendMessage( "You have been released by {0}, you may now return to your gameplay.", staff.Name ); } } } } } } |
QUOTE (darkwinters @ Jan 30 2006, 08:25 PM) |
i am not good at the commands.i want to make a command that use by staffs to target a player.the targeted player will be squelched and frozen.if the staff reuse this command and retarget the same player it is going to be unsquelch and frozen will be false.how can i do that?if you show me the start then ill understand the commands issue.. |