public void SetBuyIn(PlayerMobile pm, int amount) { Item i = CheckForGoldSources(pm, amount); if (i is Gold) { i.Amount -= amount; Handeling.BuyIn += amount; } else { BankCheck check = (BankCheck)i; check.Worth -= amount; Handeling.BuyIn += amount; } if (i.Amount <= 0) { i.Delete(); return; } if (i is BankCheck) { BankCheck check = (BankCheck)i; if (check.Worth > 0) { if (check.Worth < 5000) { if (check.Parent is BankBox) { BankBox box = (BankBox)check.Parent; Gold g = new Gold(check.Worth); box.DropItem(g); check.Delete(); } if (check.Parent is Backpack) { Backpack pack = (Backpack)check.Parent; Gold g = new Gold(check.Worth); pack.DropItem(g); check.Delete(); } } } else { check.Delete(); } } pm.SendMessage("The funds have been gathered."); }
public static bool Withdraw(Mobile from, int amount, bool message = false) { // If for whatever reason the TOL checks fail, we should still try old methods for withdrawing currency. if (AccountGold.Enabled && from.Account != null && from.Account.WithdrawGold(amount)) { if (message) { from.SendLocalizedMessage(1155856, amount.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("en-US"))); // ~1_AMOUNT~ gold has been removed from your bank box. } return(true); } Item[] gold, checks; int balance = GetBalance(from, out gold, out checks); if (balance < amount) { return(false); } for (int i = 0; amount > 0 && i < gold.Length; ++i) { if (gold[i].Amount <= amount) { amount -= gold[i].Amount; gold[i].Delete(); } else { gold[i].Amount -= amount; amount = 0; } } for (int i = 0; amount > 0 && i < checks.Length; ++i) { BankCheck check = (BankCheck)checks[i]; if (check.Worth <= amount) { amount -= check.Worth; check.Delete(); } else { check.Worth -= amount; amount = 0; } } if (message) { from.SendLocalizedMessage(1155856, amount.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("en-US"))); // ~1_AMOUNT~ gold has been removed from your bank box. } return(true); }
public static void CashCheck(Mobile from, BankCheck check) { BankBox box = from.BankBox; if (box != null) { int deposited = 0; int toAdd = check.Worth; check.Delete(); Gold gold; while (toAdd > 60000) { gold = new Gold(60000); if (box.TryDropItem(from, gold, false)) { toAdd -= 60000; deposited += 60000; } else { gold.Delete(); from.AddToBackpack(new BankCheck(toAdd)); toAdd = 0; break; } } if (toAdd > 0) { gold = new Gold(toAdd); if (box.TryDropItem(from, gold, false)) { deposited += toAdd; } else { gold.Delete(); from.AddToBackpack(new BankCheck(toAdd)); } } } }
public static bool Withdraw(Mobile from, int amount) { Item[] gold, checks; int balance = GetBalance(from, out gold, out checks); if (balance < amount) { return(false); } for (int i = 0; amount > 0 && i < gold.Length; ++i) { if (gold[i].Amount <= amount) { amount -= gold[i].Amount; gold[i].Delete(); } else { gold[i].Amount -= amount; amount = 0; } } for (int i = 0; amount > 0 && i < checks.Length; ++i) { BankCheck check = (BankCheck)checks[i]; if (check.Worth <= amount) { amount -= check.Worth; check.Delete(); } else { check.Worth -= amount; amount = 0; // cash this check - don't leave tiny checks in the users bank if (check.Worth < 5000) { CashCheck(from, check); } } } return(true); }
public static bool Withdraw(Mobile from, int amount) { Item[] gold, checks; int balance = GetBalance(from, out gold, out checks); if (balance < amount && Arya.Savings.SavingsAccount.BalanceGold(from) < amount - balance) { return(false); } for (int i = 0; amount > 0 && i < gold.Length; ++i) { if (gold[i].Amount <= amount) { amount -= gold[i].Amount; gold[i].Delete(); } else { gold[i].Amount -= amount; amount = 0; } } for (int i = 0; amount > 0 && i < checks.Length; ++i) { BankCheck check = (BankCheck)checks[i]; if (check.Worth <= amount) { amount -= check.Worth; check.Delete(); } else { check.Worth -= amount; amount = 0; } } if (amount > 0) { Arya.Savings.SavingsAccount.WithdrawGold(from, amount); } return(true); }
private bool TryPayFunds(Mobile from, StorageEntry entry) { int amount = entry.Funds; if (amount > 0) { while (amount > 60000) { BankCheck check = new BankCheck(60000); if (from.Backpack == null || !from.Backpack.TryDropItem(from, check, false)) { check.Delete(); return(false); } else { amount -= 60000; } } BankCheck check2 = new BankCheck(amount); if (from.Backpack == null || !from.Backpack.TryDropItem(from, check2, false)) { check2.Delete(); return(false); } else { entry.Funds -= amount; } } return(true); }
public override void OnResponse(GameClient sender, RelayInfo info) { PlayerMobile pm = sender.Mobile as PlayerMobile; if (pm == null) { return; } if (m_Collection is BritainLibraryCollection) { BritainLibraryCollection col = m_Collection as BritainLibraryCollection; if (col.Representative != null && pm.GetDistanceToSqrt(col.Representative.Location) > 10) { return; } } else if (pm.GetDistanceToSqrt(m_Collection.Location) > 10) { return; } if (info.ButtonID == 1) { pm.SendGump(new CollectionRewardGump(m_Collection, m_From)); } else if (info.ButtonID >= 300) { int i = info.ButtonID - 300; if (i < 0 || i >= m_Collection.Donations.Length || pm.Backpack == null) { return; } if (m_Collection is BritainLibraryCollection && !pm.FriendOfTheLibrary) { pm.SendLocalizedMessage(1074273); // You must speak with Librarian Verity before you can donate to this collection. pm.SendGump(new CollectionDonateGump(m_Collection, m_From)); return; } DonationEntry entry = m_Collection.Donations[i]; if (entry.Type == typeof(BankCheck)) { List <BankCheck> checks = pm.Backpack.FindItemsByType <BankCheck>(); if (checks.Count == 0) { // You do not have enough of that item to make a donation! pm.SendLocalizedMessage(1073167); } else { int balance = 0; for (int j = 0; j < checks.Count; j++) { BankCheck check = checks[j]; balance += check.Worth; check.Delete(); } int award = (int)(balance * entry.Award); m_Collection.Award(pm, award); } pm.SendGump(new CollectionDonateGump(m_Collection, m_From)); } else { Item item = FindItemByType(pm.Backpack, entry.Type); if (item == null) { // You do not have enough of that item to make a donation! pm.SendLocalizedMessage(1073167); pm.SendGump(new CollectionDonateGump(m_Collection, m_From)); } else if (item.Stackable) { pm.Prompt = new AmountPrompt(m_Collection, i); } else { pm.SendLocalizedMessage(1073389); // Please target the item you wish to donate. pm.Target = new DonationTarget(m_Collection, i); } } } }
public override void OnResponse(NetState sender, RelayInfo info) { PlayerMobile from = (PlayerMobile)sender.Mobile; Handeling.AddTimer.Stop(); switch (info.ButtonID) { case 0: { Handeling.Caller.SendMessage(String.Format("{0} has declined the duel.", from.Name)); Handeling.Caller.SendGump(new FieldSetup_ParticipantSetup(Handeling, TeamID)); break; } case 1: { if (Handeling.BuyIn > 0) { if (!HasGold(from, Handeling.BuyIn)) { from.SendMessage("You do not have enough money to buy into this duel."); from.SendGump(new FieldSetup_AddParticipant(Handeling, TeamID, Index)); return; } else { Item i = CheckForGoldSources(from, Handeling.BuyIn); if (i is Gold) { i.Amount -= Handeling.BuyIn; } else { BankCheck check = (BankCheck)i; check.Worth -= Handeling.BuyIn; } if (i.Amount <= 0) { i.Delete(); return; } if (i is BankCheck) { BankCheck check = (BankCheck)i; if (check.Worth > 0) { if (check.Worth < 5000) { if (check.Parent is BankBox) { BankBox box = (BankBox)check.Parent; Gold g = new Gold(check.Worth); box.DropItem(g); check.Delete(); } if (check.Parent is Backpack) { Backpack pack = (Backpack)check.Parent; Gold g = new Gold(check.Worth); pack.DropItem(g); check.Delete(); } } } else { check.Delete(); } } from.SendMessage("The buy in funds for the duel have been paid."); } } Handeling.Caller.SendMessage(String.Format("{0} has accepted the duel.", from.Name)); Handeling.Teams[TeamID].Players[Index] = from; Handeling.Teams[TeamID].Accepted.Add((PlayerMobile)from, false); Handeling.Caller.SendGump(new FieldSetup_ParticipantSetup(Handeling, TeamID)); break; } case 2: { Handeling.Caller.SendMessage(String.Format("{0} has declined the duel.", from.Name)); Handeling.Caller.SendGump(new FieldSetup_ParticipantSetup(Handeling, TeamID)); break; } } }
public override void OnResponse(Mobile from, string text) { if (!from.InRange(this.m_Location, 2) || !(from is PlayerMobile)) { return; } from.SendGump(new ComunityCollectionGump((PlayerMobile)from, this.m_Collection, this.m_Location)); int amount = Utility.ToInt32(text); if (amount <= 0) { from.SendLocalizedMessage(1073181); // That is not a valid donation quantity. return; } Item[] items = from.Backpack != null?from.Backpack.FindItemsByType(this.m_Selected.Type, true) : null; if (items != null) { // count items int count = 0; for (int i = 0; i < items.Length; i++) { if (items[i] is BankCheck && !items[i].Deleted) { count += ((BankCheck)items[i]).Worth; } else if (this.m_Selected.Validate((PlayerMobile)from, items[i]) && !items[i].Deleted) { count += items[i].Amount; } } // check if (amount > count) { from.SendLocalizedMessage(1073182); // You do not have enough to make a donation of that magnitude! return; } else if (amount * this.m_Selected.Points < 1) { from.SendLocalizedMessage(1073167); // You do not have enough of that item to make a donation! return; } // donate int deleted = 0; for (int i = 0; i < items.Length && deleted < amount; i++) { if (items[i] is BankCheck && !items[i].Deleted) { BankCheck check = (BankCheck)items[i]; if (check.Worth + deleted > amount) { check.Worth -= amount - deleted; deleted += amount - deleted; } else { deleted += check.Worth; check.Delete(); } } else if (this.m_Selected.Validate((PlayerMobile)from, items[i]) && items[i].Stackable && items[i].Amount + deleted > amount && !items[i].Deleted) { items[i].Amount -= amount - deleted; deleted += amount - deleted; } else if (this.m_Selected.Validate((PlayerMobile)from, items[i]) && !items[i].Deleted) { deleted += items[i].Amount; items[i].Delete(); } } this.m_Collection.Donate((PlayerMobile)from, this.m_Selected, amount); } else { from.SendLocalizedMessage(1073182); // You do not have enough to make a donation of that magnitude! } }
public override void OnSpeech(SpeechEventArgs e) { if (!e.Handled && e.Mobile.InRange(this.Location, 12)) { for (int i = 0; i < e.Keywords.Length; ++i) { int keyword = e.Keywords[i]; switch (keyword) { case 0x0000: // *withdraw* { e.Handled = true; string[] split = e.Speech.Split(' '); if (split.Length >= 2) { int amount; Container pack = e.Mobile.Backpack; if (!int.TryParse(split[1], out amount)) { break; } if ((!Core.ML && amount > 5000) || (Core.ML && amount > 60000)) { this.Say(500381); // Thou canst not withdraw so much at one time! } else if (pack == null || pack.Deleted || !(pack.TotalWeight < pack.MaxWeight) || !(pack.TotalItems < pack.MaxItems)) { this.Say(1048147); // Your backpack can't hold anything else. } else if (amount > 0) { BankBox box = e.Mobile.FindBankNoCreate(); if (box == null || !box.ConsumeTotal(typeof(Gold), amount)) { this.Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! } else { pack.DropItem(new Gold(amount)); Server.Gumps.WealthBar.RefreshWealthBar(e.Mobile); this.Say(1010005); // Thou hast withdrawn gold from thy account. } } } break; } case 0x0001: // *balance* { e.Handled = true; BankBox box = e.Mobile.FindBankNoCreate(); if (box != null) { this.Say(1042759, box.TotalGold.ToString()); // Thy current bank balance is ~1_AMOUNT~ gold. } else { this.Say(1042759, "0"); // Thy current bank balance is ~1_AMOUNT~ gold. } break; } case 0x0002: // *bank* { e.Handled = true; BankBox box = e.Mobile.BankBox; if (box != null) { box.GumpID = BaseContainer.BankGump(e.Mobile, box); box.Open(); } break; } case 0x0003: // *check* { e.Handled = true; string[] split = e.Speech.Split(' '); if (split.Length >= 2) { int amount; if (!int.TryParse(split[1], out amount)) { break; } if (amount < 5000) { this.Say(1010006); // We cannot create checks for such a paltry amount of gold! } else if (amount > 1000000) { this.Say(1010007); // Our policies prevent us from creating checks worth that much! } else { BankCheck check = new BankCheck(amount); BankBox box = e.Mobile.BankBox; if (!box.TryDropItem(e.Mobile, check, false)) { this.Say(500386); // There's not enough room in your bankbox for the check! check.Delete(); } else if (!box.ConsumeTotal(typeof(Gold), amount)) { this.Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! check.Delete(); } else { this.Say(1042673, AffixType.Append, amount.ToString(), ""); // Into your bank box I have placed a check in the amount of: } Server.Gumps.WealthBar.RefreshWealthBar(e.Mobile); } } break; } } } } base.OnSpeech(e); }
public override void OnSpeech(SpeechEventArgs e) { Mobile m = e.Mobile; if (XmlScript.HasTrigger(this, TriggerName.onSpeech) && UberScriptTriggers.Trigger(this, e.Mobile, TriggerName.onSpeech, null, e.Speech)) { return; } if (!e.Handled && m.InRange(Location, 12)) { string speech = e.Speech.Trim().ToLower(); if (e.HasKeyword(0x00)) // *withdraw* { e.Handled = true; if (!CheckVendorAccess(m)) { Say(500389); // I will not do business with a criminal! } else { string[] split = e.Speech.Split(' '); if (split.Length >= 2) { int amount; Container pack = m.Backpack; if (Int32.TryParse(split[1], out amount)) { if (amount > 60000) { Say(500381); // Thou canst not withdraw so much at one time! } else if (amount > 0) { BankBox box = m.FindBankNoCreate(); if (box == null || !WithdrawCredit(m, TypeOfCurrency, amount)) { Say("Ah, art thou trying to fool me? Thou hast not so much {0}!", TypeOfCurrency.Name); } else { Item currency = TypeOfCurrency.CreateInstanceSafe <Item>(); currency.Stackable = true; currency.Amount = amount; if (pack != null && !pack.Deleted && pack.TryDropItem(m, currency, false)) { Say("Thou hast withdrawn {0} from thy account.", TypeOfCurrency.Name); //Say(1010005); // Thou hast withdrawn gold from thy account. } else { currency.Delete(); box.Credit += (ulong)amount; Say(1048147); // Your backpack can't hold anything else. } } } } } } } else if (e.HasKeyword(0x01)) // *balance* { e.Handled = true; if (!CheckVendorAccess(m)) { Say(500389); // I will not do business with a criminal! } else { BankBox box = m.FindBankNoCreate(); if (box != null) { Say("Thy current bank balance is {0:#,0} {1}.", (ulong)GetBalance(m, TypeOfCurrency) + box.Credit, TypeOfCurrency.Name); } else { Say("Thy current bank balance is 0 {0}.", TypeOfCurrency.Name); } } } else if (e.HasKeyword(0x02)) // *bank* { e.Handled = true; if (!CheckVendorAccess(m)) { Say(500378); // Thou art a criminal and cannot access thy bank box. } else { m.BankBox.Open(); } } else if (e.HasKeyword(0x03)) // *check* { e.Handled = true; if (!CheckVendorAccess(m)) { Say(500389); // I will not do business with a criminal! } else { string[] split = e.Speech.Split(' '); if (split.Length >= 2) { int amount; if (int.TryParse(split[1], out amount)) { if (amount < 5000) { Say("We cannot create checks for such a paltry amount of {0}!", TypeOfCurrency.Name); //Say(1010006); // We cannot create checks for such a paltry amount of gold! } else if (amount > 1000000) { Say(1010007); // Our policies prevent us from creating checks worth that much! } else { var check = new BankCheck(amount); BankBox box = m.BankBox; if (!box.TryDropItem(m, check, false)) { Say(500386); // There's not enough room in your bankbox for the check! check.Delete(); } else if (!WithdrawCredit(m, TypeOfCurrency, amount)) { Say("Ah, art thou trying to fool me? Thou hast not so much {0}!", TypeOfCurrency.Name); //Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! check.Delete(); } else { // Into your bank box I have placed a check in the amount of: Say(1042673, AffixType.Append, Utility.MoneyFormat(amount, m), ""); } } } } } } else if (speech.IndexOf("deposit", StringComparison.Ordinal) > -1 || speech.IndexOf("credit", StringComparison.Ordinal) > -1) { e.Handled = true; if (!CheckVendorAccess(m)) { Say(500389); // I will not do business with a criminal! } else { BankBox box = m.FindBankNoCreate(); if (box == null || box.Items.Count == 0) { Say("Ah, art thou trying to fool me? Thou hast nothing to deposit!"); } else { Item[] currency = box.FindItemsByType(TypeOfCurrency, true).ToArray(); BankCheck[] checks = box.FindItemsByType <BankCheck>(true).ToArray(); foreach (Item c in currency) { ulong amount = Math.Min(box.Credit + (ulong)c.Amount, BankBox.MaxCredit); c.Consume((int)(amount - box.Credit)); box.Credit = amount; } foreach (BankCheck c in checks) { ulong amount = Math.Min(box.Credit + (ulong)c.Worth, BankBox.MaxCredit); c.ConsumeWorth((int)(amount - box.Credit)); box.Credit = amount; } Say( box.Credit == BankBox.MaxCredit ? "You have reached the maximum limit. We do not have the facilities to deposit more {0} and bank checks." : "I have deposited all of the {0} and bank checks from your bank box.", TypeOfCurrency.Name); Say("You currently have {0:#,0} {1} stored in credit.", box.Credit, TypeOfCurrency.Name); } } } } base.OnSpeech(e); }
public override void OnResponse(NetState state, RelayInfo info) { if (info.ButtonID == 1 && !m_House.Deleted) { if (m_House.IsOwner(m_Mobile)) { if (m_House.MovingCrate != null || m_House.InternalizedVendors.Count > 0) { return; } if (!Guild.NewGuildSystem && m_House.FindGuildstone() != null) { m_Mobile.SendLocalizedMessage(501389); // You cannot redeed a house with a guildstone inside. return; } /*else if ( m_House.PlayerVendors.Count > 0 ) * { * m_Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving. * return; * }*/ if (m_House.HasRentedVendors && m_House.VendorInventories.Count > 0) { m_Mobile.SendLocalizedMessage( 1062679); // You cannot do that that while you still have contract vendors or unclaimed contract vendor inventory in your house. return; } if (m_House.HasRentedVendors) { m_Mobile.SendLocalizedMessage( 1062680); // You cannot do that that while you still have contract vendors in your house. return; } if (m_House.VendorInventories.Count > 0) { m_Mobile.SendLocalizedMessage( 1062681); // You cannot do that that while you still have unclaimed contract vendor inventory in your house. return; } if (m_Mobile.AccessLevel >= AccessLevel.GameMaster) { m_Mobile.SendMessage("You do not get a refund for your house as you are not a player"); m_House.RemoveKeys(m_Mobile); m_House.Delete(); } else { Item toGive = null; if (m_House.IsAosRules) { if (m_House.Price > 0) { toGive = new BankCheck(m_House.Price); } else { toGive = m_House.GetDeed(); } } else { toGive = m_House.GetDeed(); if (toGive == null && m_House.Price > 0) { toGive = new BankCheck(m_House.Price); } } BankCheck check = toGive as BankCheck; if (AccountGold.Enabled && check != null) { int worth = check.Worth; if (m_Mobile.Account?.DepositGold(worth) == true) { check.Delete(); m_Mobile.SendLocalizedMessage(1060397, worth.ToString("#,0")); // ~1_AMOUNT~ gold has been deposited into your bank box. m_House.RemoveKeys(m_Mobile); m_House.Delete(); return; } } if (toGive != null) { BankBox box = m_Mobile.BankBox; if (box.TryDropItem(m_Mobile, toGive, false)) { if (check != null) { m_Mobile.SendLocalizedMessage(1060397, check.Worth.ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box. } m_House.RemoveKeys(m_Mobile); m_House.Delete(); } else { toGive.Delete(); m_Mobile.SendLocalizedMessage(500390); // Your bank box is full. } } else { m_Mobile.SendMessage("Unable to refund house."); } } } else { m_Mobile.SendLocalizedMessage(501320); // Only the house owner may do this. } } }
public override void OnSpeech(SpeechEventArgs e) { if (!e.Handled && e.Mobile.InRange(this.Location, 12)) { for (int i = 0; i < e.Keywords.Length; ++i) { int keyword = e.Keywords[i]; switch (keyword) { case 0x0000: // *withdraw* { e.Handled = true; if (e.Mobile.Criminal) { this.Say(500389); // I will not do business with a criminal! break; } string[] split = e.Speech.Split(' '); if (split.Length >= 2) { int amount; try { amount = Convert.ToInt32(split[1]); } catch { break; } if (amount > 5000) { this.Say(500381); // Thou canst not withdraw so much at one time! } else if (amount > 0) { BankBox box = e.Mobile.BankBox; if (box == null || !box.ConsumeTotal(typeof(Gold), amount)) { this.Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! } else { e.Mobile.AddToBackpack(new Gold(amount)); this.Say(1010005); // Thou hast withdrawn gold from thy account. } } } break; } case 0x0001: // *balance* { e.Handled = true; if (e.Mobile.Criminal) { this.Say(500389); // I will not do business with a criminal! break; } BankBox box = e.Mobile.BankBox; if (box != null) { this.Say(1042759, box.TotalGold.ToString()); // Thy current bank balance is ~1_AMOUNT~ gold. } break; } case 0x0002: // *bank* { e.Handled = true; if (e.Mobile.Criminal) { this.Say(500378); // Thou art a criminal and cannot access thy bank box. break; } if (e.Mobile.Player == true) { if (e.Mobile is PlayerMobile) { PlayerMobile pm = e.Mobile as PlayerMobile; if (DateTime.Now - pm.LastStoleAt < TimeSpan.FromMinutes(2)) { this.Say(500378); // Thou art a criminal and cannot access thy bank box. break; } //check that we're not actively involved in a fight: bool bBreak = false; for (int a = 0; a < pm.Aggressed.Count; a++) { AggressorInfo info = (AggressorInfo)pm.Aggressed[a]; if (!info.Expired) { if (info.Attacker == pm && info.Defender is PlayerMobile) { this.Say("You seem to be busy to bank, come back when you're not fighting."); bBreak = true; break; } } } if (bBreak) { break; } } } BankBox box = e.Mobile.BankBox; if (box != null) { box.Open(); } break; } case 0x0003: // *check* { e.Handled = true; if (e.Mobile.Criminal) { this.Say(500389); // I will not do business with a criminal! break; } string[] split = e.Speech.Split(' '); if (split.Length >= 2) { int amount; try { amount = Convert.ToInt32(split[1]); } catch { break; } if (amount < 5000) { this.Say(1010006); // We cannot create checks for such a paltry amount of gold! } else if (amount > 1000000) { this.Say(1010007); // Our policies prevent us from creating checks worth that much! } else { BankCheck check = new BankCheck(amount); BankBox box = e.Mobile.BankBox; if (box == null || !box.TryDropItem(e.Mobile, check, false)) { this.Say(500386); // There's not enough room in your bankbox for the check! check.Delete(); } else if (!box.ConsumeTotal(typeof(Gold), amount)) { this.Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! check.Delete(); } else { this.Say(1042673, AffixType.Append, amount.ToString(), ""); // Into your bank box I have placed a check in the amount of: } } } break; } } } } base.OnSpeech(e); }
public override void OnSpeech(SpeechEventArgs e) { if (!e.Handled && e.Mobile.InRange(Location, 12)) { for (var i = 0; i < e.Keywords.Length; ++i) { var keyword = e.Keywords[i]; switch (keyword) { case 0x0000: // *withdraw* { e.Handled = true; if (e.Mobile.Criminal) { Say(500389); // I will not do business with a criminal! break; } var split = e.Speech.Split(' '); if (split.Length >= 2) { var pack = e.Mobile.Backpack; if (!int.TryParse(split[1], out var amount)) { break; } if (!Core.ML && amount > 5000 || Core.ML && amount > 60000) { Say(500381); // Thou canst not withdraw so much at one time! } else if (pack?.Deleted != false || !(pack.TotalWeight < pack.MaxWeight) || !(pack.TotalItems < pack.MaxItems)) { Say(1048147); // Your backpack can't hold anything else. } else if (amount > 0) { var box = e.Mobile.FindBankNoCreate(); if (box == null || !Withdraw(e.Mobile, amount)) { Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! } else { pack.DropItem(new Gold(amount)); Say(1010005); // Thou hast withdrawn gold from thy account. } } } break; } case 0x0001: // *balance* { e.Handled = true; if (e.Mobile.Criminal) { Say(500389); // I will not do business with a criminal! break; } if (AccountGold.Enabled && e.Mobile.Account != null) { Say( 1155855, $"{e.Mobile.Account.TotalPlat:#,0}\t{e.Mobile.Account.TotalGold:#,0}" ); // Thy current bank balance is ~1_AMOUNT~ platinum and ~2_AMOUNT~ gold. } else { Say( 1042759, GetBalance(e.Mobile).ToString("#,0") ); // Thy current bank balance is ~1_AMOUNT~ gold. } break; } case 0x0002: // *bank* { e.Handled = true; if (e.Mobile.Criminal) { Say(500378); // Thou art a criminal and cannot access thy bank box. break; } e.Mobile.BankBox.Open(); break; } case 0x0003: // *check* { e.Handled = true; if (AccountGold.Enabled) { break; } if (e.Mobile.Criminal) { Say(500389); // I will not do business with a criminal! break; } var split = e.Speech.Split(' '); if (split.Length >= 2) { if (!int.TryParse(split[1], out var amount)) { break; } if (amount < 5000) { Say(1010006); // We cannot create checks for such a paltry amount of gold! } else if (amount > 1000000) { Say(1010007); // Our policies prevent us from creating checks worth that much! } else { var check = new BankCheck(amount); var box = e.Mobile.BankBox; if (!box.TryDropItem(e.Mobile, check, false)) { Say(500386); // There's not enough room in your bankbox for the check! check.Delete(); } else if (!box.ConsumeTotal(typeof(Gold), amount)) { Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! check.Delete(); } else { Say( 1042673, AffixType.Append, amount.ToString(), "" ); // Into your bank box I have placed a check in the amount of: } } } break; } } } } base.OnSpeech(e); }
public override void OnSpeech(SpeechEventArgs e) { if (!e.Handled && e.Mobile.InRange(this.Location, 8)) { for (int i = 0; i < e.Keywords.Length; ++i) { int keyword = e.Keywords[i]; switch (keyword) { case 0x0000: // *withdraw* { e.Handled = true; if (e.Mobile.Criminal) { this.Say(500389); // I will not do business with a criminal! break; } string[] split = e.Speech.Split(' '); if (split.Length >= 2) { int amount; try { amount = Convert.ToInt32(split[1]); } catch { break; } if (amount > 5000) { this.Say(500381); // Thou canst not withdraw so much at one time! } else if (amount > 0) { BankBox box = e.Mobile.BankBox; if (box == null || !box.ConsumeTotal(typeof(Gold), amount)) { this.Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! } else { e.Mobile.AddToBackpack(new Gold(amount)); this.Say(1010005); // Thou hast withdrawn gold from thy account. } } } break; } case 0x0001: // *balance* { e.Handled = true; if (e.Mobile.Criminal) { this.Say(500389); // I will not do business with a criminal! break; } BankBox box = e.Mobile.BankBox; if (box != null) { this.Say(1042759, box.TotalGold.ToString()); // Thy current bank balance is ~1_AMOUNT~ gold. } break; } case 0x0002: // *bank* { e.Handled = true; if (e.Mobile.Criminal) { this.Say(500378); // Thou art a criminal and cannot access thy bank box. break; } BankBox box = e.Mobile.BankBox; if (box != null) { box.Open(); } break; } case 0x0003: // *check* { e.Handled = true; if (e.Mobile.Criminal) { this.Say(500389); // I will not do business with a criminal! break; } string[] split = e.Speech.Split(' '); if (split.Length >= 2) { int amount; try { amount = Convert.ToInt32(split[1]); } catch { break; } if (amount < 5000) { this.Say(1010006); // We cannot create checks for such a paltry amount of gold! } else if (amount > 1000000) { this.Say(1010007); // Our policies prevent us from creating checks worth that much! } else { BankCheck check = new BankCheck(amount); BankBox box = e.Mobile.BankBox; if (box == null || !box.TryDropItem(e.Mobile, check, false)) { this.Say(500386); // There's not enough room in your bankbox for the check! check.Delete(); } else if (!box.ConsumeTotal(typeof(Gold), amount)) { this.Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! check.Delete(); } else { this.Say(1042673, AffixType.Append, amount.ToString(), ""); // Into your bank box I have placed a check in the amount of: } } } break; } } } } base.OnSpeech(e); }
public static void HandleSpeech(Mobile vendor, SpeechEventArgs e) { if (!e.Handled && e.Mobile.InRange(vendor, 12)) { foreach (var keyword in e.Keywords) { switch (keyword) { case 0x0000: // *withdraw* { e.Handled = true; if (e.Mobile.Criminal) { // I will not do business with a criminal! vendor.Say(500389); break; } var split = e.Speech.Split(' '); if (split.Length >= 2) { int amount; var pack = e.Mobile.Backpack; if (!int.TryParse(split[1], out amount)) { break; } if ((!Core.ML && amount > 5000) || (Core.ML && amount > 60000)) { // Thou canst not withdraw so much at one time! vendor.Say(500381); } else if (pack == null || pack.Deleted || !(pack.TotalWeight < pack.MaxWeight) || !(pack.TotalItems < pack.MaxItems)) { // Your backpack can't hold anything else. vendor.Say(1048147); } else if (amount > 0) { var box = e.Mobile.Player ? e.Mobile.BankBox : e.Mobile.FindBankNoCreate(); if (box == null || !Withdraw(e.Mobile, amount)) { // Ah, art thou trying to fool me? Thou hast not so much gold! vendor.Say(500384); } else { pack.DropItem(new Gold(amount)); // Thou hast withdrawn gold from thy account. vendor.Say(1010005); } } } } break; case 0x0001: // *balance* { e.Handled = true; if (e.Mobile.Criminal) { // I will not do business with a criminal! vendor.Say(500389); break; } if (AccountGold.Enabled && e.Mobile.Account is Account) { vendor.Say(1155855, String.Format("{0:#,0}\t{1:#,0}", e.Mobile.Account.TotalPlat, e.Mobile.Account.TotalGold), 0x3BC); vendor.Say(1155848, String.Format("{0:#,0}", ((Account)e.Mobile.Account).GetSecureAccountAmount(e.Mobile)), 0x3BC); } else { // Thy current bank balance is ~1_AMOUNT~ gold. vendor.Say(1042759, GetBalance(e.Mobile).ToString("#,0")); } } break; case 0x0002: // *bank* { e.Handled = true; if (e.Mobile.Criminal) { // Thou art a criminal and cannot access thy bank box. vendor.Say(500378); break; } e.Mobile.BankBox.Open(); } break; case 0x0003: // *check* { e.Handled = true; if (e.Mobile.Criminal) { // I will not do business with a criminal! vendor.Say(500389); break; } if (AccountGold.Enabled && e.Mobile.Account != null) { vendor.Say("We no longer offer a checking service."); break; } var split = e.Speech.Split(' '); if (split.Length >= 2) { int amount; if (!int.TryParse(split[1], out amount)) { break; } if (amount < 5000) { // We cannot create checks for such a paltry amount of gold! vendor.Say(1010006); } else if (amount > 1000000) { // Our policies prevent us from creating checks worth that much! vendor.Say(1010007); } else { var check = new BankCheck(amount); var box = e.Mobile.BankBox; if (!box.TryDropItem(e.Mobile, check, false)) { // There's not enough room in your bankbox for the check! vendor.Say(500386); check.Delete(); } else if (!box.ConsumeTotal(typeof(Gold), amount)) { // Ah, art thou trying to fool me? Thou hast not so much gold! vendor.Say(500384); check.Delete(); } else { // Into your bank box I have placed a check in the amount of: vendor.Say(1042673, AffixType.Append, amount.ToString("#,0"), ""); } } } } break; } } } }
public override void OnSpeech(SpeechEventArgs e) { if (!e.Handled && e.Mobile.InRange(Location, 12)) { for (int i = 0; i < e.Keywords.Length; ++i) { int keyword = e.Keywords[i]; switch (keyword) { case 0x0000: // *withdraw* { e.Handled = true; if (e.Mobile.IsInEvent) { e.Mobile.SendAsciiMessage("You can't do this while in an event."); break; } string[] split = e.Speech.Split(' '); if (split.Length >= 2) { int amount; Container pack = e.Mobile.Backpack; if (!int.TryParse(split[1], out amount)) { break; } if ((!Core.ML && amount > 5000) || (Core.ML && amount > 60000)) { Say(500381); // Thou canst not withdraw so much at one time! } else if (pack == null || pack.Deleted || !(pack.TotalWeight < pack.MaxWeight) || !(pack.TotalItems < pack.MaxItems)) { this.Say(1048147); // Your backpack can't hold anything else. } else if (amount > 0) { BankBox box = e.Mobile.FindBankNoCreate(); if (box == null || !box.ConsumeTotal(typeof(Gold), amount)) { Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! } else { pack.DropItem(new Gold(amount)); Say(1010005); // Thou hast withdrawn gold from thy account. } } } break; } case 0x0001: // *balance* { e.Handled = true; if (e.Mobile.Criminal) { Say(500389); // I will not do business with a criminal! break; } BankBox box = e.Mobile.FindBankNoCreate(); if (box != null) { Say(1042759, GetBalance(e.Mobile).ToString()); // Thy current bank balance is ~1_AMOUNT~ gold. } else { Say(1042759, "0"); // Thy current bank balance is ~1_AMOUNT~ gold. } break; } case 0x0002: // *bank* { e.Handled = true; //Maka //if ( e.Mobile.Criminal ) //{ // this.Say( 500378 ); // Thou art a criminal and cannot access thy bank box. // break; //} if (e.Mobile.IsInEvent) { e.Mobile.SendAsciiMessage("You can't do this while in an event."); break; } BankBox box = e.Mobile.BankBox; e.Mobile.BankBox.Open(); break; } case 0x0003: // *check* { e.Handled = true; if (e.Mobile.IsInEvent) { e.Mobile.SendAsciiMessage("You can't do this while in an event."); break; } string[] split = e.Speech.Split(' '); if (split.Length >= 2) { int amount; if (!int.TryParse(split[1], out amount)) { break; } if (amount < 5000) { Say(1010006); // We cannot create checks for such a paltry amount of gold! } else if (amount > 1000000) { Say(1010007); // Our policies prevent us from creating checks worth that much! } else { BankCheck check = new BankCheck(amount); (check).LootType = LootType.Regular; BankBox box = e.Mobile.BankBox; if (!box.TryDropItem(e.Mobile, check, false)) { Say(500386); // There's not enough room in your bankbox for the check! check.Delete(); } else if (!box.ConsumeTotal(typeof(Gold), amount)) { Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! check.Delete(); } else { Say("Into your bank box I have placed a check in the amount of: " + amount); //Say( 1042673, AffixType.Append, amount.ToString(), "" ); // Into your bank box I have placed a check in the amount of: } } } break; } } } } base.OnSpeech(e); }