using System;
using Server;
using Server.Mobiles;
using Server.Targeting;
using Server.Commands;
using Server.Network;
using Server.Items;
using VitaNex.Targets;
namespace Server.Commands
{
public class StaffMsg
{
public static void Initialize()
{
CommandSystem.Register("say1", AccessLevel.GameMaster, new CommandEventHandler(StaffMsg_OnCommand));
CommandSystem.Register("s1", AccessLevel.GameMaster, new CommandEventHandler(StaffMsg_OnCommand));
}
[Usage("say1 [message]")]
[Description("Send a private message to a player at an item location")]
private static void StaffMsg_OnCommand(CommandEventArgs e)
{
String msg = "";
if (e.Length >= 1)
msg = e.ArgString;
e.Mobile.Target = new MobileTarget( e.Mobile, msg);
}
}
public class MobileTarget : Target
{
public Mobile Owner { get; private set; }
public Mobile mTarget { get; private set; }
public String mymsg { get; private set; }
public MobileTarget( Mobile owner, String msg)
: base(-1, false, TargetFlags.None)
{
Owner = owner;
mymsg = msg;
}
protected override void OnTarget(Mobile Owner, object targeted)
{
//base.OnTarget(Owner, targeted);
if (targeted is Mobile)
{
mTarget = (Mobile)targeted;
Owner.Target = new ItemTarget(mTarget, mymsg);
}
}
}
public class ItemTarget : Target
{
public Mobile mTarg { get; private set; }
public String mymsg { get; private set; }
public Item mItem { get; private set; }
public ItemTarget( Mobile mTarget, String msg)
: base(-1, true, TargetFlags.None)
{
mymsg = msg;
mTarg = mTarget;
}
protected override void OnTarget(Mobile from, object targeted)
{
IPoint3D p = targeted as IPoint3D;
PointSay pSay = new PointSay();
pSay.Name = "";
if (p == null)
return;
Map map = from.Map;
if (map == null)
return;
pSay.MoveToWorld(new Point3D(p), map);
pSay.Z = pSay.Z + 4;
if (targeted is Mobile)//target is Mobile
{
Mobile m_target = (Mobile)targeted;
if (m_target != null)
{
pSay.LabelTo(mTarg, mymsg);
}
}
if (targeted is Item) //target is regular Item
{
Item m_target = (Item)targeted;
if (m_target != null)
{
pSay.LabelTo(mTarg, mymsg);
}
}
if (targeted is StaticTarget)//target is Static item
{
StaticTarget m_target = (StaticTarget)targeted;
if (m_target != null)
{
pSay.LabelTo(mTarg, mymsg);
}
}
if (targeted is LandTarget)//target is land (static tiles)
{
LandTarget m_target = (LandTarget)targeted;
if (m_target != null)
{
pSay.LabelTo(mTarg, mymsg);
}
}
UseDelaySystem.AddContext(from, DelayContextType.Point, TimeSpan.FromSeconds(5));
}
}
#region Pointing Say Spot
public class PointSay : Item
{
public PointSay()
: base(0x0001)//this item doesn't draw any art in game.
{
Movable = false;
Timer.DelayCall(TimeSpan.FromSeconds(4.0), new TimerCallback(Delete));
}
public override bool DisplayWeight { get { return false; } }//removing weight label
public PointSay(Serial serial) : base(serial) { }
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
#endregion
}