Exemple #1
0
            public override void OnResponse(NetState sender, RelayInfo info)
            {
                Mobile from = sender.Mobile;

                if (!Token.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used.
                    return;
                }

                if (info.ButtonID == 1)
                {
                    int[] switches = info.Switches;

                    if (switches.Length > 0)
                    {
                        int index = switches[0];

                        ChangeHairstyleEntry entry = _Entries[index - 41400];

                        if (entry.Type == StyleType.Hair)
                        {
                            from.HairItemID = entry.ItemID;
                        }
                        else
                        {
                            from.FacialHairItemID = entry.ItemID;
                        }

                        from.SendLocalizedMessage(1158661); // You have successfully changed your hairstyle.

                        Token.Delete();
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1013009); // You decide not to change your hairstyle.
                }
            }
            public override void OnResponse(NetState sender, RelayInfo info)
            {
                if (m_FacialHair && (m_From.Female || m_From.Body.IsFemale))
                {
                    return;
                }

                if (m_From.Race == Race.Elf)
                {
                    m_From.SendMessage("This isn't implemented for elves yet.  Sorry!");
                    return;
                }

                if (info.ButtonID == 1)
                {
                    int[] switches = info.Switches;

                    if (switches.Length > 0)
                    {
                        int index = switches[0];

                        if (index >= 0 && index < m_Entries.Length)
                        {
                            ChangeHairstyleEntry entry = m_Entries[index];

                            var playerMobile = m_From as PlayerMobile;
                            if (playerMobile != null)
                            {
                                playerMobile.SetHairMods(-1, -1);
                            }

                            int hairID       = m_From.HairItemID;
                            int facialHairID = m_From.FacialHairItemID;

                            if (entry.ItemID == 0)
                            {
                                if (m_FacialHair ? (facialHairID == 0) : (hairID == 0))
                                {
                                    return;
                                }

                                if (Banker.Withdraw(m_From, m_Price))
                                {
                                    if (m_FacialHair)
                                    {
                                        m_From.FacialHairItemID = 0;

                                        if (m_Price > 0)
                                        {
                                            m_From.SendLocalizedMessage(1060398, m_Price.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                                        }
                                    }
                                    else
                                    {
                                        m_From.HairItemID = 0;

                                        if (m_Price > 0)
                                        {
                                            m_From.SendLocalizedMessage(1060398, m_Price.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                                        }
                                    }
                                }
                                else
                                {
                                    m_From.SendLocalizedMessage(1042293); // You cannot afford my services for that style.
                                }
                            }
                            else
                            {
                                if (m_FacialHair)
                                {
                                    if (facialHairID > 0 && facialHairID == entry.ItemID)
                                    {
                                        return;
                                    }
                                }
                                else
                                {
                                    if (hairID > 0 && hairID == entry.ItemID)
                                    {
                                        return;
                                    }
                                }

                                if (Banker.Withdraw(m_From, m_Price))
                                {
                                    if (m_FacialHair)
                                    {
                                        m_From.FacialHairItemID = entry.ItemID;

                                        if (m_Price > 0)
                                        {
                                            m_From.SendLocalizedMessage(1060398, m_Price.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                                        }
                                    }
                                    else
                                    {
                                        m_From.HairItemID = entry.ItemID;

                                        if (m_Price > 0)
                                        {
                                            m_From.SendLocalizedMessage(1060398, m_Price.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                                        }
                                    }
                                }
                                else
                                {
                                    m_From.SendLocalizedMessage(1042293); // You cannot afford my services for that style.
                                }
                            }
                        }
                    }
                    else
                    {
                        m_From.SendLocalizedMessage(1013009); // You decide not to change your hairstyle.
                    }
                }
                else
                {
                    m_From.SendLocalizedMessage(1013009); // You decide not to change your hairstyle.
                }
            }