QUOTE |
public override void DoSpeech(string text, int[] keywords, MessageType type, int hue) { // ARTEGORDONMOD // check for the [sa attachment and if found then redirect speech to them XmlMobile x = (XmlMobile)XmlAttach.FindAttachment(this, typeof(XmlMobile), "sa"); if (x != null) { // check the target to see if it has an sa attachment to make sure you dont start pingponging Mobile target = x.Value; if (target != null && XmlAttach.FindAttachment(target, typeof(XmlMobile), "sa") == null) { target.DoSpeech(text, keywords, type, hue); return; } } if (Guilds.Guild.NewGuildSystem && (type == MessageType.Guild || type == MessageType.Alliance)) { Guilds.Guild g = this.Guild as Guilds.Guild; if (g == null) { SendLocalizedMessage(1063142); // You are not in a guild! } else if (type == MessageType.Alliance) { |
CODE |
using System; using Server; using Server.Items; using Server.Network; using Server.Mobiles; namespace Server.Engines.XmlSpawner2 { public class XmlMobile : XmlAttachment { private Mobile m_DataValue; [CommandProperty(AccessLevel.GameMaster)] public Mobile Value { get { return m_DataValue; } set { m_DataValue = value; } } // These are the various ways in which the message attachment can be constructed. // These can be called via the [addatt interface, via scripts, via the spawner ATTACH keyword. // Other overloads could be defined to handle other types of arguments // a serial constructor is REQUIRED public XmlMobile(ASerial serial) : base(serial) { } [Attachable] public XmlMobile(string name, Mobile value) { Name = name; Value = value; } [Attachable] public XmlMobile(string name, Mobile value, double expiresin) { Name = name; Value = value; Expiration = TimeSpan.FromMinutes(expiresin); } public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)0); // version 0 writer.Write(m_DataValue); } public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); // version 0 m_DataValue = reader.ReadMobile(); } public override string OnIdentify(Mobile from) { if (from == null || from.AccessLevel == AccessLevel.Player) return null; if (Expiration > TimeSpan.Zero) { return String.Format("{2}: Value {0} expires in {1} mins", Value, Expiration.TotalMinutes, Name); } else { return String.Format("{1}: Value {0}", Value, Name); } } } } |
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; using Server.Engines.Help; using Server.Commands; using Server.Commands.Generic; using Server.Accounting; namespace Server.Scripts.Commands { public class GenericCommand { public static void Initialize() { CommandSystem.Register("sa", 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; if (from == m) { // remove the attachment if targeting self XmlMobile x = (XmlMobile)XmlAttach.FindAttachment(from, typeof(XmlMobile), "sa"); if (x != null) x.Delete(); } else { XmlAttach.AttachTo(from, new XmlMobile("sa", m)); } } } } [Usage("sa")] public static void GenericCommand_OnCommand(CommandEventArgs e) { if (e != null && e.Mobile != null) e.Mobile.Target = new GenericTarget(); } } } |