Example #1
0
        public override void OnResponse(NetState from, RelayInfo info)
        {
            if (m_SpecialBeardDye.Deleted)
            {
                return;
            }

            Mobile m = from.Mobile;

            int[] switches = info.Switches;

            if (!m_SpecialBeardDye.IsChildOf(m.Backpack))
            {
                m.SendAsciiMessage("You must have the object in your backpack to use it.");
                return;
            }

            if (info.ButtonID != 0 && switches.Length > 0)
            {
                Item beard = m.Beard;

                if (beard == null)
                {
                    m.SendAsciiMessage("You have no beard to dye and cannot use this.");
                }
                else
                {
                    // To prevent this from being exploited, the hue is abstracted into an internal list

                    int entryIndex = switches[0] / 100;
                    int hueOffset  = switches[0] % 100;

                    if (entryIndex >= 0 && entryIndex < m_Entries.Length)
                    {
                        SpecialBeardDyeEntry e = m_Entries[entryIndex];

                        if (hueOffset >= 0 && hueOffset < e.HueCount)
                        {
                            int hue = e.HueStart + hueOffset;

                            if (beard != null)
                            {
                                beard.Hue = hue;
                            }

                            m.SendAsciiMessage("You dye your beard.");
                            m_SpecialBeardDye.Delete();
                            m.PlaySound(0x4E);
                        }
                    }
                }
            }
            else
            {
                m.SendAsciiMessage("You decide not to dye your beard.");
            }
        }
Example #2
0
        public override void OnResponse(NetState from, RelayInfo info)
        {
            if (m_SpecialBeardDye.Deleted)
            {
                return;
            }

            Mobile m = from.Mobile;

            int[] switches = info.Switches;

            if (!m_SpecialBeardDye.IsChildOf(m.Backpack))
            {
                m.SendLocalizedMessage(1042010);                   //You must have the objectin your backpack to use it.
                return;
            }

            if (info.ButtonID != 0 && switches.Length > 0)
            {
                if (m.FacialHairItemID == 0)
                {
                    m.SendLocalizedMessage(502623);                             // You have no hair to dye and cannot use this
                }
                else
                {
                    // To prevent this from being exploited, the hue is abstracted into an internal list

                    int entryIndex = switches[0] / 100;
                    int hueOffset  = switches[0] % 100;

                    if (entryIndex >= 0 && entryIndex < m_Entries.Length)
                    {
                        SpecialBeardDyeEntry e = m_Entries[entryIndex];

                        if (hueOffset >= 0 && hueOffset < e.HueCount)
                        {
                            int hue = e.HueStart + hueOffset;

                            m.FacialHairHue = hue;

                            m.SendLocalizedMessage(501199);                                // You dye your hair
                            m_SpecialBeardDye.Delete();
                            m.PlaySound(0x4E);
                        }
                    }
                }
            }
            else
            {
                m.SendLocalizedMessage(501200);                   // You decide not to dye your hair
            }
        }