public override void Open(Mobile from) { if (Locked && from.AccessLevel < AccessLevel.GameMaster && LockingPerson.Account != from.Account) { SecretChestArray l = null; for (var index = 0; index < list.Count; index++) { var x = list[index]; if (x.Mobile == from) { l = x; break; } } if (l == null) { l = new SecretChestArray { Mobile = from, TrialsNumber = 3 }; list.Add(l); } if (l.Permission) { from.SendLocalizedMessage(1151600); // You remember the key number of this chest, so you can open this now. DisplayTo(from); return; } if (l.TrialsNumber == 0 && l.Expire < DateTime.UtcNow) { l.TrialsNumber = 3; } if (l.TrialsNumber > 0) { from.SendLocalizedMessage(501747); // It appears to be locked. from.SendLocalizedMessage(1151527); // Enter the key number to open. from.SendLocalizedMessage(1152346, string.Format("{0}", l.TrialsNumber)); // Number of tries left: ~1_times~ from.SendGump(new SecretChestGump(this, false)); } else { from.SendLocalizedMessage(1151599); // You cannot access the chest now, having exhausted your number of attempts. } } else { DisplayTo(from); } }
public bool CheckPermission(Mobile from) { SecretChestArray p = null; for (var index = 0; index < list.Count; index++) { var x = list[index]; if (x.Mobile == from) { p = x; break; } } return(LockingPerson.Account == from.Account || p != null && p.Permission); }
public bool CheckPermission(Mobile from) { SecretChestArray p = list.FirstOrDefault(x => x.Mobile == from); return(LockingPerson.Account == from.Account || p != null && p.Permission); }
public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; if (Chest == null) { return; } switch (info.ButtonID) { case 0: { from.SendLocalizedMessage(1042021); // Cancelled. break; } case 1: { SecretChestArray l = Chest.list.FirstOrDefault(x => x.Mobile == from); if (l == null) { return; } if (Chest.SecretKey.SequenceEqual(TempSecretKey)) { from.SendLocalizedMessage(1151589); // You succeed at entering the correct key number; you may open the chest now. l.Permission = true; Chest.DisplayTo(from); } else { l.TrialsNumber--; if (l.TrialsNumber > 0) { from.SendLocalizedMessage(1151590); // The number which you have entered is wrong. You still can't open this chest... from.SendLocalizedMessage(1152346, string.Format("{0}", l.TrialsNumber)); // Number of tries left: ~1_times~ Timer.DelayCall(TimeSpan.FromSeconds(0.2), () => from.SendGump(new SecretChestGump(Chest, TempSecretKey, SetEdit))); } else { l.Expire = DateTime.UtcNow + TimeSpan.FromDays(1); from.SendLocalizedMessage(1151611); // You have exhausted your unlock attempts for this chest; you must wait 24 hours to try again. } } break; } case 2: { for (int i = 0; i < Chest.SecretKey.Length; ++i) { Chest.SecretKey[i] = TempSecretKey[i]; } Chest.Locked = true; Chest.LockingPerson = from; Chest.list.Clear(); from.SendLocalizedMessage(1151528); // The key numbers have been set; this chest is now locked. break; } default: { int index = info.ButtonID - 10; if (info.ButtonID % 2 == 0) { index /= 2; if (TempSecretKey[index] == 9) { TempSecretKey[index] = 0; } else { TempSecretKey[index]++; } } else { index = (index - 1) / 2; if (TempSecretKey[index] == 0) { TempSecretKey[index] = 9; } else { TempSecretKey[index]--; } } Timer.DelayCall(TimeSpan.FromSeconds(0.2), () => from.SendGump(new SecretChestGump(Chest, TempSecretKey, SetEdit))); break; } } }