protected override void AcceptOffer(Mobile from) { m_Contract.Offeree = null; if (!m_Contract.Map.CanFit(m_Contract.Location, 16, false, false)) { m_Landlord.SendLocalizedMessage(1062486); // A vendor cannot exist at that location. Please try again. return; } BaseHouse house = BaseHouse.FindHouseAt(m_Contract); if (house == null) { return; } int price = m_Contract.Price; int goldToGive; if (price > 0) { if (Banker.Withdraw(from, price)) { from.SendLocalizedMessage(1060398, price.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. int depositedGold = Banker.DepositUpTo(m_Landlord, price); goldToGive = price - depositedGold; if (depositedGold > 0) { m_Landlord.SendLocalizedMessage(1060397, price.ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box. } if (goldToGive > 0) { m_Landlord.SendLocalizedMessage(500390); // Your bank box is full. } } else { from.SendLocalizedMessage(1062378); // You do not have enough gold in your bank account to cover the cost of the contract. m_Landlord.SendLocalizedMessage(1062374, from.Name); // ~1_NAME~ has declined your vendor rental offer. return; } } else { goldToGive = 0; } PlayerVendor vendor = new RentedVendor(from, house, m_Contract.Duration, price, m_Contract.LandlordRenew, goldToGive); vendor.MoveToWorld(m_Contract.Location, m_Contract.Map); m_Contract.Delete(); from.SendLocalizedMessage(1062377); // You have accepted the offer and now own a vendor in this house. Rental contract options and details may be viewed on this vendor via the 'Contract Options' context menu. m_Landlord.SendLocalizedMessage(1062376, from.Name); // ~1_NAME~ has accepted your vendor rental offer. Rental contract details and options may be viewed on this vendor via the 'Contract Options' context menu. }
private static long GiveGold(PlayerMobile m, long gold) { if (gold <= 0 || m == null) { return(0); } var looted = 0L; // Autobank Gold while (gold > 0) { var deposit = Banker.DepositUpTo(m, (int)Math.Min(Int32.MaxValue, gold)); if (deposit > 0) { looted += deposit; gold -= deposit; } else { break; } } while (gold > 0) { var a = (int)Math.Min(gold, 10000); var g = new Gold(a); if (m.GiveItem(g, GiveFlags.PackBankDelete).WasReceived()) { looted += a; gold -= a; } else { break; } } if (looted > 0) { m.SendMessage(1258, "You received {0:#,0} gold.", looted); } return(looted); }
public override void OnResponse(NetState sender, RelayInfo info) { var from = sender.Mobile; if (!m_Vendor.CanInteractWith(from, true) || !m_Vendor.CanInteractWith(m_Landlord, false) || !m_Vendor.IsLandlord(m_Landlord)) { return; } if (info.ButtonID == 1) { if (Banker.Withdraw(m_Landlord, m_RefundAmount)) { m_Landlord.SendLocalizedMessage( 1060398, m_RefundAmount.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box. var depositedGold = Banker.DepositUpTo(from, m_RefundAmount); if (depositedGold > 0) { from.SendLocalizedMessage( 1060397, depositedGold.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. } m_Vendor.HoldGold += m_RefundAmount - depositedGold; m_Vendor.Destroy(false); from.SendLocalizedMessage(1071990); // Remember to claim your vendor's belongings from the house sign! } else { m_Landlord.SendLocalizedMessage(1062507); // You do not have that much money in your bank account. } } else { m_Landlord.SendLocalizedMessage(1062513); // The renter declined your offer. } }
public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; if (!this.m_Vendor.CanInteractWith(from, true) || !this.m_Vendor.CanInteractWith(this.m_Landlord, false) || !this.m_Vendor.IsLandlord(this.m_Landlord)) { return; } if (info.ButtonID == 1) { if (Banker.Withdraw(this.m_Landlord, this.m_RefundAmount)) { if (Core.AOS || !Core.bEnforceExpansionClient) { this.m_Landlord.SendLocalizedMessage(1060398, this.m_RefundAmount.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. } else { string temp = string.Format("{0} gold has been withdrawn from your bank box.", this.m_RefundAmount.ToString()); m_Landlord.SendMessage(temp); } int depositedGold = Banker.DepositUpTo(from, this.m_RefundAmount); if (depositedGold > 0) { from.SendLocalizedMessage(1060397, depositedGold.ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box. } this.m_Vendor.HoldGold += this.m_RefundAmount - depositedGold; this.m_Vendor.Destroy(false); from.SendLocalizedMessage(1071990); //Remember to claim your vendor's belongings from the house sign! } else { this.m_Landlord.SendLocalizedMessage(1062507); // You do not have that much money in your bank account. } } else { this.m_Landlord.SendLocalizedMessage(1062513); // The renter declined your offer. } }
public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; if (!m_Vendor.CanInteractWith(from, true) || !m_Vendor.CanInteractWith(m_Landlord, false) || !m_Vendor.IsLandlord(m_Landlord)) { return; } if (info.ButtonID == 1) { if (Banker.Withdraw(m_Landlord, m_Vendor.TypeOfCurrency, m_RefundAmount)) { m_Landlord.SendMessage( "{0:#,0} {1} has been withdrawn from your bank box.", m_RefundAmount, m_Vendor.TypeOfCurrency.Name); int depositedCurrency = Banker.DepositUpTo(from, m_Vendor.TypeOfCurrency, m_RefundAmount); if (depositedCurrency > 0) { from.SendMessage( "{0:#,0} {1} has been deposited into your bank box.", depositedCurrency, m_Vendor.TypeOfCurrency.Name); } m_Vendor.HoldCurrency += m_RefundAmount - depositedCurrency; m_Vendor.Destroy(true); from.SendMessage("Your vendor's belongings have been placed in your bank!"); } else { m_Landlord.SendLocalizedMessage(1062507); // You do not have that much money in your bank account. } } else { m_Landlord.SendLocalizedMessage(1062513); // The renter declined your offer. } }
public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; if (!m_Vendor.CanInteractWith(from, true) || !m_Vendor.CanInteractWith(m_Landlord, false) || !m_Vendor.IsLandlord(m_Landlord)) { return; } if (info.ButtonID == 1) { if (Banker.Withdraw(m_Landlord, m_RefundAmount)) { m_Landlord.SendLocalizedMessage(1060398, m_RefundAmount.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. int depositedGold = Banker.DepositUpTo(from, m_RefundAmount); if (depositedGold > 0) { from.SendLocalizedMessage(1060397, depositedGold.ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box. } m_Vendor.HoldGold += m_RefundAmount - depositedGold; //deposit any held gold for vendor owner to bank before destroying Banker.Deposit(from, m_Vendor.HoldGold); m_Vendor.HoldGold = 0; m_Vendor.Destroy(true); } else { m_Landlord.SendLocalizedMessage(1062507); // You do not have that much money in your bank account. } } else { m_Landlord.SendLocalizedMessage(1062513); // The renter declined your offer. } }
public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 0) { return; } var from = sender.Mobile; var sign = m_House.Sign; if (m_House.Deleted || sign?.Deleted != false || !from.CheckAlive()) { return; } if (from.Map != sign.Map || !from.InRange(sign, 5)) { from.SendLocalizedMessage(1062429); // You must be within five paces of the house sign to use this option. return; } var index = info.ButtonID - 1; if (index < 0 || index >= m_Inventories.Count) { return; } var inventory = m_Inventories[index]; if (inventory.Owner != from || !m_House.VendorInventories.Contains(inventory)) { return; } var totalItems = 0; var givenToBackpack = 0; var givenToBankBox = 0; for (var i = inventory.Items.Count - 1; i >= 0; i--) { var item = inventory.Items[i]; if (item.Deleted) { inventory.Items.RemoveAt(i); continue; } totalItems += 1 + item.TotalItems; if (from.PlaceInBackpack(item)) { inventory.Items.RemoveAt(i); givenToBackpack += 1 + item.TotalItems; } else if (from.BankBox.TryDropItem(from, item, false)) { inventory.Items.RemoveAt(i); givenToBankBox += 1 + item.TotalItems; } } from.SendLocalizedMessage( 1062436, $"{totalItems}\t{inventory.Gold}" ); // The vendor you selected had ~1_COUNT~ items in its inventory, and ~2_AMOUNT~ gold in its account. var givenGold = Banker.DepositUpTo(from, inventory.Gold); inventory.Gold -= givenGold; from.SendLocalizedMessage( 1060397, givenGold.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. from.SendLocalizedMessage( 1062437, $"{givenToBackpack}\t{givenToBankBox}" ); // ~1_COUNT~ items have been removed from the shop inventory and placed in your backpack. ~2_BANKCOUNT~ items were removed from the shop inventory and placed in your bank box. if (inventory.Gold > 0 || inventory.Items.Count > 0) { from.SendLocalizedMessage( 1062440 ); // Some of the shop inventory would not fit in your backpack or bank box. Please free up some room and try again. } else { inventory.Delete(); from.SendLocalizedMessage(1062438); // The shop is now empty of inventory and funds, so it has been deleted. } }
protected override void AcceptOffer(Mobile from) { m_Contract.Offeree = null; if (!m_Contract.Map.CanFit(m_Contract.Location, 16, false, false)) { m_Landlord.SendLocalizedMessage(1062486); // A vendor cannot exist at that location. Please try again. return; } BaseHouse house = BaseHouse.FindHouseAt(m_Contract); if (house == null) { return; } int price = m_Contract.Price; int currencyToGive; if (price > 0) { Type cType = m_Contract.Expansion == Expansion.T2A ? typeof(Silver) : typeof(Gold); if (Banker.Withdraw(from, cType, price)) { from.SendMessage("{0:#,0} {1} has been withdrawn from your bank box.", price, cType.Name); int depositedCurrency = Banker.DepositUpTo(m_Landlord, cType, price); currencyToGive = price - depositedCurrency; if (depositedCurrency > 0) { m_Landlord.SendMessage("{0:#,0} {1} has been deposited into your bank box.", price, cType.Name); } if (currencyToGive > 0) { m_Landlord.SendLocalizedMessage(500390); // Your bank box is full. } } else { from.SendMessage("You do not have enough {0} in your bank account to cover the cost of the contract.", cType.Name); m_Landlord.SendLocalizedMessage(1062374, from.Name); // ~1_NAME~ has declined your vendor rental offer. return; } } else { currencyToGive = 0; } PlayerVendor vendor = new RentedVendor( from, house, m_Contract.Duration, price, m_Contract.LandlordRenew, currencyToGive); vendor.MoveToWorld(m_Contract.Location, m_Contract.Map); m_Contract.Delete(); // You have accepted the offer and now own a vendor in this house. Rental contract options and details may be viewed on this vendor via the 'Contract Options' context menu. from.SendLocalizedMessage(1062377); // ~1_NAME~ has accepted your vendor rental offer. Rental contract details and options may be viewed on this vendor via the 'Contract Options' context menu. m_Landlord.SendLocalizedMessage(1062376, from.Name); }
public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 0) { return; } Mobile from = sender.Mobile; HouseSign sign = m_House.Sign; if (m_House.Deleted || sign == null || sign.Deleted || !from.CheckAlive()) { return; } if (from.Map != sign.Map || !from.InRange(sign, 5)) { // You must be within five paces of the house sign to use this option. from.SendLocalizedMessage(1062429); return; } int index = info.ButtonID - 1; if (index < 0 || index >= m_Inventories.Count) { return; } var inventory = (VendorInventory)m_Inventories[index]; if (inventory.Owner != from || !m_House.VendorInventories.Contains(inventory)) { return; } int totalItems = 0; int givenToBackpack = 0; int givenToBankBox = 0; for (int i = inventory.Items.Count - 1; i >= 0; i--) { Item item = inventory.Items[i]; if (item.Deleted) { inventory.Items.RemoveAt(i); continue; } totalItems += 1 + item.TotalItems; if (from.PlaceInBackpack(item)) { inventory.Items.RemoveAt(i); givenToBackpack += 1 + item.TotalItems; } else { BankBox box = from.FindBank(m_House.Expansion) ?? from.BankBox; if (box.TryDropItem(from, item, false)) { inventory.Items.RemoveAt(i); givenToBankBox += 1 + item.TotalItems; } } } from.SendMessage( "The vendor you selected had {0:#,0} items in its inventory, and {1:#,0} {2} in its account.", totalItems, inventory.Currency, inventory.TypeOfCurrency.Name); int givenGold = Banker.DepositUpTo(from, inventory.TypeOfCurrency, inventory.Currency); inventory.Currency -= givenGold; from.SendMessage("{0:#,0} {1} has been deposited into your bank box.", givenGold, inventory.TypeOfCurrency.Name); // ~1_COUNT~ items have been removed from the shop inventory and placed in your backpack. // ~2_BANKCOUNT~ items were removed from the shop inventory and placed in your bank box. from.SendLocalizedMessage(1062437, givenToBackpack.ToString("#,0") + "\t" + givenToBankBox.ToString("#,0")); if (inventory.Currency > 0 || inventory.Items.Count > 0) { // Some of the shop inventory would not fit in your backpack or bank box. // Please free up some room and try again. from.SendLocalizedMessage(1062440); } else { inventory.Delete(); // The shop is now empty of inventory and funds, so it has been deleted. from.SendLocalizedMessage(1062438); } }