Full Version : give an item
xmlspawner >>Scripting Support >>give an item
<< Prev | Next >>
ambak- 02-19-2006
this is djan's squelch command that i found in this forum

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

is it possible to give an item when target the player?
Dian- 02-19-2006
yes, its absolutly possible.
ambak- 02-19-2006
but how?can you show me?
Dian- 02-19-2006
If you are actually wanting to add an item, by use of that script above...
You would need to add to the top of the script first off

CODE
using Server.Items

and somewhere in the target method, would be somthing like..

CODE
Apple apple = new Apple(); pm.AddToBackpack( apple );

......