public void StallBuy()
{
try
{
if (!Character.Network.Stall.isOpened) return;
PacketReader Reader = new PacketReader(PacketInformation.buffer);
byte stallslot = Reader.Byte();
stall currentStall = Character.Network.Stall;
stall.stallItem sitem = currentStall.ItemList.Find(i => (i.stallSlot == stallslot));
// stall buyer update
byte slot = GetFreeSlot();
if (slot <= 12) return;
if (Character.Information.Gold >= (long)sitem.price)
{
Character.Information.Gold -= (long)sitem.price;
client.Send(Packet.UpdateGold(Character.Information.Gold));
SaveGold();
}
else return; //insufficent gold
// staller update
if (currentStall.ItemList.Contains(sitem))
{
Systems staller = GetPlayer(currentStall.ownerID);
staller.Character.Information.Gold += (long)sitem.price;
staller.client.Send(Packet.UpdateGold(staller.Character.Information.Gold));
MsSQL.UpdateData("update character set gold='" + staller.Character.Information.Gold + "' where id='" + staller.Character.Information.CharacterID + "'");
//MsSQL.UpdateData("delete from char_items where itemnumber='item" + sitem.Item.Slot + "' AND owner='" + staller.Character.Information.CharacterID + "'");
Systems.MsSQL.InsertData("UPDATE char_items SET owner='" + Character.Information.CharacterID + "',slot='" + slot + "',itemnumber='item" + slot + "' WHERE owner='" + staller.Character.Information.CharacterID + "' AND itemid='" + sitem.Item.ID + "' AND id='" + sitem.Item.dbID + "' AND storagetype='0'");
//take item out from stall
if (currentStall.ItemList.Count == 1)
{
staller.Character.Stall.Stallactive = false;
Character.Stall.Stallactive = false;
}
currentStall.ItemList.Remove(sitem);
client.Send(Packet.StallBuyItem(stallslot, 1));
currentStall.Send(Packet.StallBuyItem2(Character.Information.Name, stallslot, currentStall.ItemList));
}
else
{
Disconnect("ban");
Console.WriteLine("Autobanned user: " + Player.AccountName + " Due to hacking");
}
}
catch (Exception ex)
{
Systems.Debugger.Write(ex);
}
}