TheGodfather
So this seems trivial, but I just can't find where to edit it so if you buy too much and it makes you overweight instead of dropping at your feet it goes to your bank. Any help is much appreciated!
private void ProcessValidPurchase(int amount, IBuyItemInfo bii, Mobile buyer, Container cont)
{
if (amount > bii.Amount)
{
amount = bii.Amount;
}
if (amount < 1)
{
return;
}
bii.Amount -= amount;
IEntity o = bii.GetEntity();
if (o is Item)
{
Item item = (Item)o;
if (item.Stackable)
{
item.Amount = amount;
if (cont == null || !cont.TryDropItem(buyer, item, false))
{
item.MoveToWorld(buyer.Location, buyer.Map);
}
}
else
{
item.Amount = 1;
if (cont == null || !cont.TryDropItem(buyer, item, false))
{
item.MoveToWorld(buyer.Location, buyer.Map);
}
for (int i = 1; i < amount; i++)
{
item = bii.GetEntity() as Item;
if (item != null)
{
item.Amount = 1;
if (cont == null || !cont.TryDropItem(buyer, item, false))
{
item.MoveToWorld(buyer.Location, buyer.Map);
}
}
}
}
}
foreach (IShopSellInfo ssi in info)
{
if (ssi.IsSellable(item))
{
if (ssi.IsResellable(item))
{
Item buyItem;
if (amount >= item.Amount)
{
buyItem = item;
}
else
{
buyItem = LiftItemDupe(item, item.Amount - amount);
if (buyItem == null)
{
buyItem = item;
}
}
if (cont == null || !cont.TryDropItem(buyer, buyItem, false))
{
buyItem.MoveToWorld(buyer.Location, buyer.Map);
}
break;
}
}
}
private void ProcessValidPurchase(int amount, IBuyItemInfo bii, Mobile buyer, Container cont)
{
if (amount > bii.Amount)
{
amount = bii.Amount;
}
if (amount < 1)
{
return;
}
bii.Amount -= amount;
IEntity o = bii.GetEntity();
if (o is Item)
{
Item item = (Item)o;
if (item.Stackable)
{
item.Amount = amount;
if (cont == null || !cont.TryDropItem(buyer, item, false))
{
//item.MoveToWorld(buyer.Location, buyer.Map);
//change container to Bank
cont = buyer.BankBox;
if(!cont.TryDropItem(buyer, item, false)) {
SayTo(buyer, true, "Warning! {0} gold was dropped at your feet. This should not happen!", amount);
item.MoveToWorld(buyer.Location, buyer.Map);
} else {
SayTo(buyer, true, "{0} gold was deposited within your bank because you did not have enough space in your pack.", amount);
}
}
}
else
{
item.Amount = 1;
if (cont == null || !cont.TryDropItem(buyer, item, false))
{
//item.MoveToWorld(buyer.Location, buyer.Map);
//change container to Bank
cont = buyer.BankBox;
if(!cont.TryDropItem(buyer, item, false)) {
SayTo(buyer, true, "Warning! {0} gold was dropped at your feet. This should not happen!", amount);
item.MoveToWorld(buyer.Location, buyer.Map);
} else {
SayTo(buyer, true, "{0} gold was deposited within your bank because you did not have enough space in your pack.", amount);
}
}
for (int i = 1; i < amount; i++)
{
item = bii.GetEntity() as Item;
if (item != null)
{
item.Amount = 1;
if (cont == null || !cont.TryDropItem(buyer, item, false))
{
//item.MoveToWorld(buyer.Location, buyer.Map);
//change container to Bank
cont = buyer.BankBox;
if(!cont.TryDropItem(buyer, item, false)) {
SayTo(buyer, true, "Warning! {0} gold was dropped at your feet. This should not happen!", amount);
item.MoveToWorld(buyer.Location, buyer.Map);
} else {
SayTo(buyer, true, "{0} gold was deposited within your bank because you did not have enough space in your pack.", amount);
}
}
}
}
}
are you saying replace all buyer.bankbox with that?buyer.BankBox.DropItem(item);
sorry
replace cont = buyer.BankBox;
with that
if (cont == null || !cont.TryDropItem(buyer, item, false))
{
//item.MoveToWorld(buyer.Location, buyer.Map);
//change container to Bank
buyer.BankBox.DropItem(item);
if(!cont.TryDropItem(buyer, item, false)) {
SayTo(buyer, true, "Warning! {0} gold was dropped at your feet. This should not happen!", amount);
item.MoveToWorld(buyer.Location, buyer.Map);
} else {
SayTo(buyer, true, "{0} gold was deposited within your bank because you did not have enough space in your pack.", amount);
}
}
wait this is talking about dropping gold to the ground
if im buying something why would they be giving me gold?
i think this is for selling
so far i've been able to move items to bank but not gold, yet
private void ProcessValidPurchase(int amount, IBuyItemInfo bii, Mobile buyer, Container cont)
{
if (amount > bii.Amount)
{
amount = bii.Amount;
}
if (amount < 1)
{
return;
}
bii.Amount -= amount;
IEntity o = bii.GetEntity();
if (o is Item)
{
Item item = (Item)o;
if (item.Stackable)
{
item.Amount = amount;
if( WeightOverloading.IsOverloaded(buyer) )
{
buyer.BankBox.DropItem( item );
}
// if (cont == null || !cont.TryDropItem(buyer, item, false))
// {
// item.MoveToWorld(buyer.Location, buyer.Map);
// }
}
else
{
item.Amount = 1;
if( WeightOverloading.IsOverloaded(buyer) )
{
buyer.BankBox.DropItem(item);
}
// if (cont == null || !cont.TryDropItem(buyer, item, false))
// {
// item.MoveToWorld(buyer.Location, buyer.Map);
// }
for (int i = 1; i < amount; i++)
{
item = bii.GetEntity() as Item;
if (item != null)
{
item.Amount = 1;
if( WeightOverloading.IsOverloaded(buyer) )
{
buyer.BankBox.DropItem(item);
}
// if (cont == null || !cont.TryDropItem(buyer, item, false))
// {
// item.MoveToWorld(buyer.Location, buyer.Map);
// }
}
}
}
}
else if (o is Mobile)
{
Mobile m = (Mobile)o;
m.Direction = (Direction)Utility.Random(8);
m.MoveToWorld(buyer.Location, buyer.Map);
m.PlaySound(m.GetIdleSound());
if (m is BaseCreature)
{
((BaseCreature)m).SetControlMaster(buyer);
}
for (int i = 1; i < amount; ++i)
{
m = bii.GetEntity() as Mobile;
if (m != null)
{
m.Direction = (Direction)Utility.Random(8);
m.MoveToWorld(buyer.Location, buyer.Map);
if (m is BaseCreature)
{
((BaseCreature)m).SetControlMaster(buyer);
}
}
}
}
}
public virtual bool OnBuyItems(Mobile buyer, List<BuyItemResponse> list)
{
if (!IsActiveSeller)
{
return false;
}
if (!buyer.CheckAlive())
{
return false;
}
if (!CheckVendorAccess(buyer))
{
Say(501522); // I shall not treat with scum like thee!
return false;
}
UpdateBuyInfo();
var buyInfo = GetBuyInfo();
var info = GetSellInfo();
int totalCost = 0;
var validBuy = new List<BuyItemResponse>(list.Count);
Container cont;
bool bought = false;
bool fromBank = false;
bool fullPurchase = true;
int controlSlots = buyer.FollowersMax - buyer.Followers;
foreach (BuyItemResponse buy in list)
{
Serial ser = buy.Serial;
int amount = buy.Amount;
if (ser.IsItem)
{
Item item = World.FindItem(ser);
if (item == null)
{
continue;
}
GenericBuyInfo gbi = LookupDisplayObject(item);
if (gbi != null)
{
ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost);
}
else if (item != BuyPack && item.IsChildOf(BuyPack))
{
if (amount > item.Amount)
{
amount = item.Amount;
}
if (amount <= 0)
{
continue;
}
foreach (IShopSellInfo ssi in info)
{
if (ssi.IsSellable(item))
{
if (ssi.IsResellable(item))
{
totalCost += ssi.GetBuyPriceFor(item) * amount;
validBuy.Add(buy);
break;
}
}
}
}
}
else if (ser.IsMobile)
{
Mobile mob = World.FindMobile(ser);
if (mob == null)
{
continue;
}
GenericBuyInfo gbi = LookupDisplayObject(mob);
if (gbi != null)
{
ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost);
}
}
} //foreach
if (fullPurchase && validBuy.Count == 0)
{
SayTo(buyer, 500190); // Thou hast bought nothing!
}
else if (validBuy.Count == 0)
{
SayTo(buyer, 500187); // Your order cannot be fulfilled, please try again.
}
if (validBuy.Count == 0)
{
return false;
}
bought = buyer.AccessLevel >= AccessLevel.GameMaster;
cont = buyer.Backpack;
if (!bought && cont != null)
{
if (cont.ConsumeTotal(typeof(Gold), totalCost))
{
bought = true;
}
}
if (!bought &&
(totalCost >= 2000 ||
AccountGold.Enabled)
)
{
if (Banker.Withdraw(buyer, totalCost))
{
bought = true;
fromBank = true;
}
else
{
cont = buyer.FindBankNoCreate();
if (cont != null && cont.ConsumeTotal(typeof(Gold), totalCost))
{
bought = true;
fromBank = true;
}
}
}
if (!bought)
{
// ? Begging thy pardon, but thy bank account lacks these funds.
// : Begging thy pardon, but thou casnt afford that.
SayTo(buyer, totalCost >= 2000 ? 500191 : 500192);
return false;
}
buyer.PlaySound(0x32);
cont = buyer.Backpack ?? buyer.BankBox;
foreach (BuyItemResponse buy in validBuy)
{
Serial ser = buy.Serial;
int amount = buy.Amount;
if (amount < 1)
{
continue;
}
if (ser.IsItem)
{
Item item = World.FindItem(ser);
if (item == null)
{
continue;
}
GenericBuyInfo gbi = LookupDisplayObject(item);
if (gbi != null)
{
ProcessValidPurchase(amount, gbi, buyer, cont);
}
else
{
if (amount > item.Amount)
{
amount = item.Amount;
}
foreach (IShopSellInfo ssi in info)
{
if (ssi.IsSellable(item))
{
if (ssi.IsResellable(item))
{
Item buyItem;
if (amount >= item.Amount)
{
buyItem = item;
}
else
{
buyItem = LiftItemDupe(item, item.Amount - amount);
if (buyItem == null)
{
buyItem = item;
}
}
if( WeightOverloading.IsOverloaded(buyer) )
{
buyer.BankBox.DropItem( buyItem );
}
// if (cont == null || !cont.TryDropItem(buyer, buyItem, false))
// {
// buyItem.MoveToWorld(buyer.Location, buyer.Map);
// }
break;
}
}
}
}
}
else if (ser.IsMobile)
{
Mobile mob = World.FindMobile(ser);
if (mob == null)
{
continue;
}
GenericBuyInfo gbi = LookupDisplayObject(mob);
if (gbi != null)
{
ProcessValidPurchase(amount, gbi, buyer, cont);
}
}
} //foreach
if (fullPurchase)
{
if (buyer.AccessLevel >= AccessLevel.GameMaster)
{
SayTo(buyer, true, "I would not presume to charge thee anything. Here are the goods you requested.");
}
else if (fromBank)
{
SayTo(
buyer,
true,
"The total of thy purchase is {0} gold, which has been withdrawn from your bank account. My thanks for the patronage.",
totalCost);
}
else
{
SayTo(buyer, true, "The total of thy purchase is {0} gold. My thanks for the patronage.", totalCost);
}
}
else
{
if (buyer.AccessLevel >= AccessLevel.GameMaster)
{
SayTo(
buyer,
true,
"I would not presume to charge thee anything. Unfortunately, I could not sell you all the goods you requested.");
}
else if (fromBank)
{
SayTo(
buyer,
true,
"The total of thy purchase is {0} gold, which has been withdrawn from your bank account. My thanks for the patronage. Unfortunately, I could not sell you all the goods you requested.",
totalCost);
}
else
{
SayTo(
buyer,
true,
"The total of thy purchase is {0} gold. My thanks for the patronage. Unfortunately, I could not sell you all the goods you requested.",
totalCost);
}
}
return true;
}
public virtual bool OnSellItems(Mobile seller, List<SellItemResponse> list)
{
if (!IsActiveBuyer)
{
return false;
}
if (!seller.CheckAlive())
{
return false;
}
if (!CheckVendorAccess(seller))
{
Say(501522); // I shall not treat with scum like thee!
return false;
}
seller.PlaySound(0x32);
var info = GetSellInfo();
var buyInfo = GetBuyInfo();
int GiveGold = 0;
int Sold = 0;
Container cont;
foreach (SellItemResponse resp in list)
{
if (resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable ||
(resp.Item is Container && (resp.Item).Items.Count != 0))
{
continue;
}
foreach (IShopSellInfo ssi in info)
{
if (ssi.IsSellable(resp.Item))
{
Sold++;
break;
}
}
}
if (Sold > MaxSell)
{
SayTo(seller, true, "You may only sell {0} items at a time!", MaxSell);
return false;
}
else if (Sold == 0)
{
return true;
}
foreach (SellItemResponse resp in list)
{
if (resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable ||
(resp.Item is Container && (resp.Item).Items.Count != 0))
{
continue;
}
foreach (IShopSellInfo ssi in info)
{
if (ssi.IsSellable(resp.Item))
{
int amount = resp.Amount;
if (amount > resp.Item.Amount)
{
amount = resp.Item.Amount;
}
if (ssi.IsResellable(resp.Item))
{
bool found = false;
foreach (IBuyItemInfo bii in buyInfo)
{
if (bii.Restock(resp.Item, amount))
{
resp.Item.Consume(amount);
found = true;
break;
}
}
if (!found)
{
cont = BuyPack;
if (amount < resp.Item.Amount)
{
Item item = LiftItemDupe(resp.Item, resp.Item.Amount - amount);
if (item != null)
{
item.SetLastMoved();
cont.DropItem(item);
}
else
{
resp.Item.SetLastMoved();
cont.DropItem(resp.Item);
}
}
else
{
resp.Item.SetLastMoved();
cont.DropItem(resp.Item);
}
}
}
else
{
if (amount < resp.Item.Amount)
{
resp.Item.Amount -= amount;
}
else
{
resp.Item.Delete();
}
}
GiveGold += ssi.GetSellPriceFor(resp.Item) * amount;
break;
}
}
}
if (GiveGold > 0)
{
while (GiveGold > 60000)
{
if( WeightOverloading.IsOverloaded(seller) )
{
seller.BankBox.DropItem(new Gold(60000));
}
seller.AddToBackpack(new Gold(60000));
GiveGold -= 60000;
}
//seller.AddToBackpack(new Gold(GiveGold));
if( WeightOverloading.IsOverloaded(seller) )
{
seller.BankBox.DropItem(new Gold(GiveGold));
}
else
{
seller.AddToBackpack(new Gold(GiveGold));
}
seller.PlaySound(0x0037); //Gold dropping sound
if (SupportsBulkOrders(seller))
{
Item bulkOrder = CreateBulkOrder(seller, false);
if (bulkOrder is LargeBOD)
{
seller.SendGump(new LargeBODAcceptGump(seller, (LargeBOD)bulkOrder));
}
else if (bulkOrder is SmallBOD)
{
seller.SendGump(new SmallBODAcceptGump(seller, (SmallBOD)bulkOrder));
}
}
}
//no cliloc for this?
//SayTo( seller, true, "Thank you! I bought {0} item{1}. Here is your {2}gp.", Sold, (Sold > 1 ? "s" : ""), GiveGold );
return true;
}
private void ProcessValidPurchase(int amount, IBuyItemInfo bii, Mobile buyer, Container cont)
private void ProcessValidPurchase(int amount, IBuyItemInfo bii, Mobile buyer, Container cont)
{
if (amount > bii.Amount)
{
amount = bii.Amount;
}
if (amount < 1)
{
return;
}
bii.Amount -= amount;
IEntity o = bii.GetEntity();
if (o is Item)
{
Item item = (Item)o;
if (item.Stackable)
{
item.Amount = amount;
if( WeightOverloading.IsOverloaded(buyer) )
{
buyer.BankBox.DropItem( item );
}
// if (cont == null || !cont.TryDropItem(buyer, item, false))
// {
// item.MoveToWorld(buyer.Location, buyer.Map);
// }
}
else
{
item.Amount = 1;
if( WeightOverloading.IsOverloaded(buyer) )
{
buyer.BankBox.DropItem(item);
}
// if (cont == null || !cont.TryDropItem(buyer, item, false))
// {
// item.MoveToWorld(buyer.Location, buyer.Map);
// }
for (int i = 1; i < amount; i++)
{
item = bii.GetEntity() as Item;
if (item != null)
{
item.Amount = 1;
if( WeightOverloading.IsOverloaded(buyer) )
{
buyer.BankBox.DropItem(item);
}
// if (cont == null || !cont.TryDropItem(buyer, item, false))
// {
// item.MoveToWorld(buyer.Location, buyer.Map);
// }
}
}
}
}
else if (o is Mobile)
{
Mobile m = (Mobile)o;
m.Direction = (Direction)Utility.Random(8);
m.MoveToWorld(buyer.Location, buyer.Map);
m.PlaySound(m.GetIdleSound());
if (m is BaseCreature)
{
((BaseCreature)m).SetControlMaster(buyer);
}
for (int i = 1; i < amount; ++i)
{
m = bii.GetEntity() as Mobile;
if (m != null)
{
m.Direction = (Direction)Utility.Random(8);
m.MoveToWorld(buyer.Location, buyer.Map);
if (m is BaseCreature)
{
((BaseCreature)m).SetControlMaster(buyer);
}
}
}
}
}
public virtual bool OnBuyItems(Mobile buyer, List<BuyItemResponse> list)
public virtual bool OnBuyItems(Mobile buyer, List<BuyItemResponse> list)
{
if (!IsActiveSeller)
{
return false;
}
if (!buyer.CheckAlive())
{
return false;
}
if (!CheckVendorAccess(buyer))
{
Say(501522); // I shall not treat with scum like thee!
return false;
}
UpdateBuyInfo();
var buyInfo = GetBuyInfo();
var info = GetSellInfo();
int totalCost = 0;
var validBuy = new List<BuyItemResponse>(list.Count);
Container cont;
bool bought = false;
bool fromBank = false;
bool fullPurchase = true;
int controlSlots = buyer.FollowersMax - buyer.Followers;
foreach (BuyItemResponse buy in list)
{
Serial ser = buy.Serial;
int amount = buy.Amount;
if (ser.IsItem)
{
Item item = World.FindItem(ser);
if (item == null)
{
continue;
}
GenericBuyInfo gbi = LookupDisplayObject(item);
if (gbi != null)
{
ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost);
}
else if (item != BuyPack && item.IsChildOf(BuyPack))
{
if (amount > item.Amount)
{
amount = item.Amount;
}
if (amount <= 0)
{
continue;
}
foreach (IShopSellInfo ssi in info)
{
if (ssi.IsSellable(item))
{
if (ssi.IsResellable(item))
{
totalCost += ssi.GetBuyPriceFor(item) * amount;
validBuy.Add(buy);
break;
}
}
}
}
}
else if (ser.IsMobile)
{
Mobile mob = World.FindMobile(ser);
if (mob == null)
{
continue;
}
GenericBuyInfo gbi = LookupDisplayObject(mob);
if (gbi != null)
{
ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost);
}
}
} //foreach
if (fullPurchase && validBuy.Count == 0)
{
SayTo(buyer, 500190); // Thou hast bought nothing!
}
else if (validBuy.Count == 0)
{
SayTo(buyer, 500187); // Your order cannot be fulfilled, please try again.
}
if (validBuy.Count == 0)
{
return false;
}
bought = buyer.AccessLevel >= AccessLevel.GameMaster;
cont = buyer.Backpack;
if (!bought && cont != null)
{
if (cont.ConsumeTotal(typeof(Gold), totalCost))
{
bought = true;
}
}
if (!bought &&
(totalCost >= 2000 ||
AccountGold.Enabled)
)
{
if (Banker.Withdraw(buyer, totalCost))
{
bought = true;
fromBank = true;
}
else
{
cont = buyer.FindBankNoCreate();
if (cont != null && cont.ConsumeTotal(typeof(Gold), totalCost))
{
bought = true;
fromBank = true;
}
}
}
if (!bought)
{
// ? Begging thy pardon, but thy bank account lacks these funds.
// : Begging thy pardon, but thou casnt afford that.
SayTo(buyer, totalCost >= 2000 ? 500191 : 500192);
return false;
}
buyer.PlaySound(0x32);
cont = buyer.Backpack ?? buyer.BankBox;
foreach (BuyItemResponse buy in validBuy)
{
Serial ser = buy.Serial;
int amount = buy.Amount;
if (amount < 1)
{
continue;
}
if (ser.IsItem)
{
Item item = World.FindItem(ser);
if (item == null)
{
continue;
}
GenericBuyInfo gbi = LookupDisplayObject(item);
if (gbi != null)
{
ProcessValidPurchase(amount, gbi, buyer, cont);
}
else
{
if (amount > item.Amount)
{
amount = item.Amount;
}
foreach (IShopSellInfo ssi in info)
{
if (ssi.IsSellable(item))
{
if (ssi.IsResellable(item))
{
Item buyItem;
if (amount >= item.Amount)
{
buyItem = item;
}
else
{
buyItem = LiftItemDupe(item, item.Amount - amount);
if (buyItem == null)
{
buyItem = item;
}
}
if( WeightOverloading.IsOverloaded(buyer) )
{
buyer.BankBox.DropItem( buyItem );
}
// if (cont == null || !cont.TryDropItem(buyer, buyItem, false))
// {
// buyItem.MoveToWorld(buyer.Location, buyer.Map);
// }
break;
}
}
}
}
}
else if (ser.IsMobile)
{
Mobile mob = World.FindMobile(ser);
if (mob == null)
{
continue;
}
GenericBuyInfo gbi = LookupDisplayObject(mob);
if (gbi != null)
{
ProcessValidPurchase(amount, gbi, buyer, cont);
}
}
} //foreach
if (fullPurchase)
{
if (buyer.AccessLevel >= AccessLevel.GameMaster)
{
SayTo(buyer, true, "I would not presume to charge thee anything. Here are the goods you requested.");
}
else if (fromBank)
{
SayTo(
buyer,
true,
"The total of thy purchase is {0} gold, which has been withdrawn from your bank account. My thanks for the patronage.",
totalCost);
}
else
{
SayTo(buyer, true, "The total of thy purchase is {0} gold. My thanks for the patronage.", totalCost);
}
}
else
{
if (buyer.AccessLevel >= AccessLevel.GameMaster)
{
SayTo(
buyer,
true,
"I would not presume to charge thee anything. Unfortunately, I could not sell you all the goods you requested.");
}
else if (fromBank)
{
SayTo(
buyer,
true,
"The total of thy purchase is {0} gold, which has been withdrawn from your bank account. My thanks for the patronage. Unfortunately, I could not sell you all the goods you requested.",
totalCost);
}
else
{
SayTo(
buyer,
true,
"The total of thy purchase is {0} gold. My thanks for the patronage. Unfortunately, I could not sell you all the goods you requested.",
totalCost);
}
}
return true;
}
publicvirtualbool OnSellItems(Mobile seller, List<SellItemResponse> list)
public virtual bool OnSellItems(Mobile seller, List<SellItemResponse> list)
{
if (!IsActiveBuyer)
{
return false;
}
if (!seller.CheckAlive())
{
return false;
}
if (!CheckVendorAccess(seller))
{
Say(501522); // I shall not treat with scum like thee!
return false;
}
seller.PlaySound(0x32);
var info = GetSellInfo();
var buyInfo = GetBuyInfo();
int GiveGold = 0;
int Sold = 0;
Container cont;
foreach (SellItemResponse resp in list)
{
if (resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable ||
(resp.Item is Container && (resp.Item).Items.Count != 0))
{
continue;
}
foreach (IShopSellInfo ssi in info)
{
if (ssi.IsSellable(resp.Item))
{
Sold++;
break;
}
}
}
if (Sold > MaxSell)
{
SayTo(seller, true, "You may only sell {0} items at a time!", MaxSell);
return false;
}
else if (Sold == 0)
{
return true;
}
foreach (SellItemResponse resp in list)
{
if (resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable ||
(resp.Item is Container && (resp.Item).Items.Count != 0))
{
continue;
}
foreach (IShopSellInfo ssi in info)
{
if (ssi.IsSellable(resp.Item))
{
int amount = resp.Amount;
if (amount > resp.Item.Amount)
{
amount = resp.Item.Amount;
}
if (ssi.IsResellable(resp.Item))
{
bool found = false;
foreach (IBuyItemInfo bii in buyInfo)
{
if (bii.Restock(resp.Item, amount))
{
resp.Item.Consume(amount);
found = true;
break;
}
}
if (!found)
{
cont = BuyPack;
if (amount < resp.Item.Amount)
{
Item item = LiftItemDupe(resp.Item, resp.Item.Amount - amount);
if (item != null)
{
item.SetLastMoved();
cont.DropItem(item);
}
else
{
resp.Item.SetLastMoved();
cont.DropItem(resp.Item);
}
}
else
{
resp.Item.SetLastMoved();
cont.DropItem(resp.Item);
}
}
}
else
{
if (amount < resp.Item.Amount)
{
resp.Item.Amount -= amount;
}
else
{
resp.Item.Delete();
}
}
GiveGold += ssi.GetSellPriceFor(resp.Item) * amount;
break;
}
}
}
if (GiveGold > 0)
{
while (GiveGold > 60000)
{
if( WeightOverloading.IsOverloaded(seller) )
{
seller.BankBox.DropItem(new Gold(60000));
}
seller.AddToBackpack(new Gold(60000));
GiveGold -= 60000;
}
//seller.AddToBackpack(new Gold(GiveGold));
if( WeightOverloading.IsOverloaded(seller) )
{
seller.BankBox.DropItem(new Gold(GiveGold));
}
else
{
seller.AddToBackpack(new Gold(GiveGold));
}
seller.PlaySound(0x0037); //Gold dropping sound
if (SupportsBulkOrders(seller))
{
Item bulkOrder = CreateBulkOrder(seller, false);
if (bulkOrder is LargeBOD)
{
seller.SendGump(new LargeBODAcceptGump(seller, (LargeBOD)bulkOrder));
}
else if (bulkOrder is SmallBOD)
{
seller.SendGump(new SmallBODAcceptGump(seller, (SmallBOD)bulkOrder));
}
}
}
//no cliloc for this?
//SayTo( seller, true, "Thank you! I bought {0} item{1}. Here is your {2}gp.", Sold, (Sold > 1 ? "s" : ""), GiveGold );
return true;
}
Will need added messages to tell players that item or gold was moved to bank
Ok that's due to the gold in bankbox being added to bank balanceThe gold actually says "this has been depositted"
The items say nothing.
if (cont == null || !cont.TryDropItem(buyer, buyItem, false))
{
// buyItem.MoveToWorld(buyer.Location, buyer.Map);
buyer.BankBox.DropItem(item);
buyer.SendMessage(200, "{0} has been sent to your bank, thank you for your purchase",item);
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.