public override void OnResponse(NetState from, RelayInfo info) { if (m_BlackHairDye.Deleted) { return; } Mobile m = from.Mobile; int[] switches = info.Switches; if (!m_BlackHairDye.IsChildOf(m.Backpack)) { m.SendLocalizedMessage(1042010); //You must have the object in your backpack to use it. return; } if (info.ButtonID != 0 && switches.Length > 0) { if (m.HairItemID == 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) { BlackHairDyeEntry e = m_Entries[entryIndex]; if (hueOffset >= 0 && hueOffset < e.HueCount) { m_BlackHairDye.Consume(); int hue = e.HueStart + hueOffset; m.HairHue = hue; m.SendLocalizedMessage(501199); // You dye your hair m.PlaySound(0x4E); } } } } else { m.SendLocalizedMessage(501200); // You decide not to dye your hair } }
public override void OnResponse(NetState from, RelayInfo info) { if (m_BlackHairDye == null || m_BlackHairDye.Deleted) { return; } Mobile m = from.Mobile; if (m_BlackHairDye.IsChildOf(m.Backpack)) { if (info.ButtonID != 0) { if (m.HairItemID > 0) { m_BlackHairDye.Consume(); m.HairHue = 1; m.SendLocalizedMessage(501199); // You dye your hair m.PlaySound(0x4E); } else { m.SendLocalizedMessage(502623); // You have no hair to dye and cannot use this } } else { m.SendLocalizedMessage(1042010); //You must have the object in your backpack to use it. } } else { m.SendLocalizedMessage(501200); // You decide not to dye your hair } }