Full Version : making a command
xmlspawner >>Scripting Support >>making a command
<< Prev | Next >>
darkwinters- 01-30-2006
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..
Sunshine- 01-30-2006
I know you can say [set cantwalk true and they can not move..or you can use the commands on pb to do all sorts of things if you do not know the commands off the top of your head
darkwinters- 01-30-2006
but i want to make a custom command that makes frozen and squelch combo and with second use uncombo
ArteGordon- 01-30-2006
here is a generic framework for a command involving targeting

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

you can substitute for
m.Say("hello there");
whatever you want done to the targeted mob.
if you want to toggle the Squelched and Frozen properties, just put something like
m.Frozen = !m.Frozen;
m.Squelched = !m.Squelched;
Dian- 01-31-2006
I was bored.. and figured I wouldnt get attaked for granting a request
I briefly tested this out.. so copy this and abuse the crap out of it for any bugs, and let me know if there are any.
HaltPlayer.cs

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

A suggestion was made to make an area efect too.. maybe that will be tomorrows addition
ArteGordon- 01-31-2006
thanks for the contribution
Odee- 02-05-2006

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..

Simply do a [set squelched true and [set cantwalk true. Also, if you want to page squelch them, say [set pagingsquelched true
Dian- 02-05-2006
yes, but why go through all that typing when you could make a command script like above. a simple [HP and your done.
In these situations of needing to stop a troublesome player, most the time you dont have the time to type.