コード例 #1
0
            public override void OnResponse(NetState state, RelayInfo info)
            {
                if (m_Tool == null || m_Tool.Deleted || m_Target == null || m_Target.Deleted)
                {
                    return;
                }

                Mobile from = state.Mobile;

                if (info.ButtonID == 1)
                {
                    TextRelay relay = info.GetTextEntry(15);

                    IEngravable item = (IEngravable)m_Target;

                    if (relay != null)
                    {
                        if (relay.Text == null || relay.Text.Equals(""))
                        {
                            if (item.EngravedText != null)
                            {
                                item.EngravedText = null;
                                from.SendLocalizedMessage(m_Tool.RemoveMessage);
                            }
                            else
                            {
                                from.SendLocalizedMessage(m_Tool.ObjectWasNotMessage);
                            }
                        }
                        else
                        {
                            string text;

                            if (relay.Text.Length > 40)
                            {
                                text = relay.Text.Substring(0, 40);
                            }
                            else
                            {
                                text = relay.Text;
                            }

                            item.EngravedText = text;

                            from.SendLocalizedMessage(m_Tool.SuccessMessage);

                            m_Tool.UsesRemaining--;

                            if (m_Tool.UsesRemaining < 1)
                            {
                                if (m_Tool.DeletedItem)
                                {
                                    m_Tool.Delete();
                                    from.SendLocalizedMessage(1044038); // You have worn out your tool!
                                }
                            }
                        }
                    }
                }
            }
コード例 #2
0
            public override void OnResponse(Server.Network.NetState state, RelayInfo info)
            {
                if (m_Tool == null || m_Tool.Deleted || m_Target == null || m_Target.Deleted)
                {
                    return;
                }

                if (info.ButtonID == (int)Buttons.Okay)
                {
                    TextRelay relay = info.GetTextEntry((int)Buttons.Text);

                    if (relay != null)
                    {
                        if (relay.Text == null || relay.Text.Equals(""))
                        {
                            ((IEngravable)m_Target).EngravedText = null;
                            state.Mobile.SendLocalizedMessage(1072362);                               // You remove the engraving from the object.
                        }
                        else
                        {
                            if (relay.Text.Length > 40)
                            {
                                ((IEngravable)m_Target).EngravedText = relay.Text.Substring(0, 40);
                            }
                            else
                            {
                                ((IEngravable)m_Target).EngravedText = relay.Text;
                            }

                            state.Mobile.SendLocalizedMessage(1072361);                               // You engraved the object.
                            m_Target.InvalidateProperties();
                            m_Tool.UsesRemaining -= 1;
                            m_Tool.InvalidateProperties();

                            if (m_Tool.UsesRemaining < 1)
                            {
                                m_Tool.Delete();
                                state.Mobile.SendLocalizedMessage(1044038);                                   // You have worn out your tool!
                            }
                        }
                    }
                }
            }