public override int HandlePacket(GamePlayer player, GSPacketIn packet) { eBageType bagType = (eBageType)packet.ReadByte(); int place = packet.ReadInt(); int payType = (int)packet.ReadByte(); int price = packet.ReadInt(); int mouthful = packet.ReadInt(); int validDate = packet.ReadInt(); string msg = "AuctionAddHandler.Fail"; payType = 1; int result; if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); result = 0; } else { if (price < 0 || (mouthful != 0 && mouthful < price)) { result = 0; } else { if (payType != 0) { payType = 1; } int needGold = (validDate == 0) ? 100 : ((validDate == 1) ? 200 : 300); needGold = ((needGold < 1) ? 1 : needGold); ItemInfo goods = player.GetItemAt(bagType, place); if (price < 0) { msg = "AuctionAddHandler.Msg1"; } else { if (mouthful != 0 && mouthful < price) { msg = "AuctionAddHandler.Msg2"; } else { if (needGold > player.PlayerCharacter.Gold) { msg = "AuctionAddHandler.Msg3"; } else { if (goods == null) { msg = "AuctionAddHandler.Msg4"; } else { if (goods.IsBinds) { msg = "AuctionAddHandler.Msg5"; } else { if (goods.ItemID == 0) { using (PlayerBussiness db = new PlayerBussiness()) { db.AddGoods(goods); } } AuctionInfo info = new AuctionInfo(); info.AuctioneerID = player.PlayerCharacter.ID; info.AuctioneerName = player.PlayerCharacter.NickName; info.BeginDate = DateTime.Now; info.BuyerID = 0; info.BuyerName = ""; info.IsExist = true; info.ItemID = goods.ItemID; info.Mouthful = mouthful; info.PayType = payType; info.Price = price; info.Rise = price / 10; info.Rise = ((info.Rise < 1) ? 1 : info.Rise); info.Name = goods.Template.Name; info.Category = goods.Template.CategoryID; info.ValidDate = ((validDate == 0) ? 8 : ((validDate == 1) ? 24 : 48)); info.TemplateID = goods.TemplateID; info.Random = AuctionAddHandler.random.Next(45, 75); using (PlayerBussiness db = new PlayerBussiness()) { if (db.AddAuction(info)) { player.TakeOutItem(goods); player.SaveIntoDatabase(); player.RemoveGold(needGold); msg = "AuctionAddHandler.Msg6"; player.Out.SendAuctionRefresh(info, info.AuctionID, true, goods); } } } } } } } player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(msg, new object[0])); result = 0; } } return(result); }
public int HandlePacket(GameClient client, GSPacketIn packet) { eBageType bagType = (eBageType)packet.ReadByte(); int place = packet.ReadInt(); int num = (int)packet.ReadByte(); int num2 = packet.ReadInt(); int num3 = packet.ReadInt(); int num4 = packet.ReadInt(); int num5 = packet.ReadInt(); string translateId = "AuctionAddHandler.Fail"; num = 1; if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); return(0); } if (num2 < 0 || (num3 != 0 && num3 < num2)) { return(0); } int num6 = 1; if (num != 0) { num6 = 1; num = 1; } int num7 = (int)((double)(num6 * num2) * 0.03 * (double)((num4 == 0) ? 1 : ((num4 == 1) ? 3 : 6))); num7 = ((num7 < 1) ? 1 : num7); ItemInfo itemAt = client.Player.GetItemAt(bagType, place); if (itemAt == null) { client.Player.SendMessage("Vật phẩm lạ không tìm thấy!!! Hack chăng???!!!"); return(0); } int num8 = itemAt.Count - num5; if (itemAt.Count < num5 || num5 < 0) { num5 = itemAt.Count; } if (num2 < 0) { translateId = "AuctionAddHandler.Msg1"; } else { if (num3 != 0 && num3 < num2) { translateId = "AuctionAddHandler.Msg2"; } else { if (num7 > client.Player.PlayerCharacter.Gold) { translateId = "AuctionAddHandler.Msg3"; } else { if (itemAt == null) { translateId = "AuctionAddHandler.Msg4"; } else { if (itemAt.IsBinds) { translateId = "AuctionAddHandler.Msg5"; } else { client.Player.SaveIntoDatabase(); AuctionInfo auctionInfo = new AuctionInfo(); auctionInfo.AuctioneerID = client.Player.PlayerCharacter.ID; auctionInfo.AuctioneerName = client.Player.PlayerCharacter.NickName; auctionInfo.BeginDate = DateTime.Now; auctionInfo.BuyerID = 0; auctionInfo.BuyerName = ""; auctionInfo.IsExist = true; auctionInfo.ItemID = itemAt.ItemID; auctionInfo.Mouthful = num3; auctionInfo.PayType = num; auctionInfo.Price = num2; auctionInfo.Rise = num2 / 10; auctionInfo.Rise = ((auctionInfo.Rise < 1) ? 1 : auctionInfo.Rise); auctionInfo.Name = itemAt.Template.Name; auctionInfo.Category = itemAt.Template.CategoryID; auctionInfo.ValidDate = ((num4 == 0) ? 8 : ((num4 == 1) ? 24 : 48)); auctionInfo.TemplateID = itemAt.TemplateID; auctionInfo.goodsCount = num5; auctionInfo.Random = ThreadSafeRandom.NextStatic(GameProperties.BeginAuction, GameProperties.EndAuction); using (PlayerBussiness playerBussiness = new PlayerBussiness()) { if (playerBussiness.AddAuction(auctionInfo)) { itemAt.Count = num5; client.Player.TakeOutItem(itemAt); if (num8 > 0) { client.Player.AddTemplate(itemAt, bagType, num8); } client.Player.SaveIntoDatabase(); client.Player.RemoveGold(num7); translateId = "AuctionAddHandler.Msg6"; client.Out.SendAuctionRefresh(auctionInfo, auctionInfo.AuctionID, true, itemAt); } } } } } } } client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(translateId, new object[0])); return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { eBageType bagType = (eBageType)packet.ReadByte(); int place = packet.ReadInt(); int payType = packet.ReadByte(); int price = packet.ReadInt(); int mouthful = packet.ReadInt(); int validDate = packet.ReadInt(); string msg = "AuctionAddHandler.Fail"; payType = 1; if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked")); return(0); } if (price < 0 || (mouthful != 0 && mouthful < price)) { return(0); } int multiple = 1; if (payType != 0) { //multiple = 10; multiple = 1; payType = 1; } int needGold = (int)(multiple * price * 0.03 * (validDate == 0 ? 1 : validDate == 1 ? 3 : 6)); needGold = needGold < 1 ? 1 : needGold; ItemInfo goods = client.Player.GetItemAt(bagType, place); if (price < 0) { msg = "AuctionAddHandler.Msg1"; } else if (mouthful != 0 && mouthful < price) { msg = "AuctionAddHandler.Msg2"; } else if (needGold > client.Player.PlayerCharacter.Gold) { msg = "AuctionAddHandler.Msg3"; } else if (goods == null) { msg = "AuctionAddHandler.Msg4"; } else if (goods.IsBinds) { msg = "AuctionAddHandler.Msg5"; } else { client.Player.SaveIntoDatabase(); AuctionInfo info = new AuctionInfo(); info.AuctioneerID = client.Player.PlayerCharacter.ID; //获取物品ID info.AuctioneerName = client.Player.PlayerCharacter.NickName; //获取物品妮称 info.BeginDate = DateTime.Now; info.BuyerID = 0; info.BuyerName = ""; info.IsExist = true; info.ItemID = goods.ItemID; info.Mouthful = mouthful; info.PayType = payType; info.Price = price; info.Rise = price / 10; info.Rise = info.Rise < 1 ? 1 : info.Rise; info.Name = goods.Template.Name; info.Category = goods.Template.CategoryID; info.ValidDate = validDate == 0 ? 8 : validDate == 1 ? 24 : 48; info.TemplateID = goods.TemplateID; info.Random = Bussiness.ThreadSafeRandom.NextStatic(GameProperties.BeginAuction, GameProperties.EndAuction); using (PlayerBussiness db = new PlayerBussiness()) //写数据库 { if (db.AddAuction(info)) { //client.Player.RemoveAllItem(goods, true, Game.Server.Statics.ItemRemoveType.Auction, bagType); //client.Player.up //client.Player.SaveIntoDatabase(); //client.Player.SetGold(-needGold, Game.Server.Statics.GoldRemoveType.Auction); //msg = "AuctionAddHandler.Msg6"; //client.Out.SendAuctionRefresh(info, info.AuctionID, true, goods); client.Player.RemoveItem(goods); goods.IsExist = true; client.Player.SaveIntoDatabase(); client.Player.RemoveGold(needGold); msg = "AuctionAddHandler.Msg6"; client.Out.SendAuctionRefresh(info, info.AuctionID, true, goods); } } } //client.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Receiver); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(msg)); return(0); }