public int HandlePacket(GameClient client, GSPacketIn packet) { if (998 <= client.Player.PlayerCharacter.Money) { SqlDataProvider.Data.ItemInfo item = this.getitem(client, 1, "", "", 1101801); SqlDataProvider.Data.ItemInfo info2 = this.getitem(client, 1, "", "", 1102001); SqlDataProvider.Data.ItemInfo info3 = this.getitem(client, 1, "", "", 1102401); SqlDataProvider.Data.ItemInfo info4 = this.getitem(client, 1, "", "", 1102401); SqlDataProvider.Data.ItemInfo info5 = this.getitem(client, 1, "", "", 1102401); PlayerInventory bag = client.Player.GetInventory(eBageType.Store); PlayerInventory inventory = client.Player.GetInventory(eBageType.PropBag); List<SqlDataProvider.Data.ItemInfo> items = bag.GetItems(); foreach (SqlDataProvider.Data.ItemInfo info6 in items) { bag.MoveToStore(bag, info6.Place, inventory.FindFirstEmptySlot(0), inventory, 50); } bag.AddItemTo(item, 4); bag.AddItemTo(info2, 3); bag.AddItemTo(info3, 2); bag.AddItemTo(info4, 1); bag.AddItemTo(info5, 0); client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.Success", new object[0])); client.Player.RemoveMoney(998); } else { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.NoMoney", new object[0])); } return 0; }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.CurrentHotSpringRoom != null) { client.Player.CurrentHotSpringRoom.ProcessData(client.Player, packet); } return 0; }
public int HandlePacket(GameClient client, GSPacketIn packet) { int val = packet.ReadInt(); GSPacketIn pkg = new GSPacketIn(0xd4); pkg.WriteInt(val); client.SendTCP(pkg); return 0; }
public int HandlePacket(GameClient client, GSPacketIn packet) { HotSpringRoom[] allHotRoom = HotSpringRoomMgr.GetAllHotSpringRoom(); //foreach (HotSpringRoom room in allHotRoom) //{ client.Player.Out.SendHotSpringRoomInfo(client.Player, allHotRoom); //} return 0; }
private SqlDataProvider.Data.ItemInfo getitem(GameClient client, int type, string color, string skin, int id) { ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID); ShopItemInfo shopItemInfoById = ShopMgr.GetShopItemInfoById(id); bool flag = false; SqlDataProvider.Data.ItemInfo info3 = null; if (shopItemInfoById != null) { info3 = SqlDataProvider.Data.ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(shopItemInfoById.TemplateID), 1, 102); if (0 == shopItemInfoById.BuyType) { if (1 == type) { info3.ValidDate = shopItemInfoById.AUnit; } if (2 == type) { info3.ValidDate = shopItemInfoById.BUnit; } if (3 == type) { info3.ValidDate = shopItemInfoById.CUnit; } } else { if (1 == type) { info3.Count = shopItemInfoById.AUnit; } if (2 == type) { info3.Count = shopItemInfoById.BUnit; } if (3 == type) { info3.Count = shopItemInfoById.CUnit; } } if ((info3 != null) || (shopItemInfoById != null)) { info3.Color = (color == null) ? "" : color; info3.Skin = (skin == null) ? "" : skin; if (flag) { info3.IsBinds = true; return info3; } info3.IsBinds = Convert.ToBoolean(shopItemInfoById.IsBind); } } return info3; }
public int HandlePacket(GameClient client, GSPacketIn packet) { packet = packet.Clone(); packet.ClearContext(); int num = packet.ReadInt(); int num2 = packet.ReadInt(); int num3 = packet.ReadInt(); int num4 = packet.ReadInt(); int num5 = packet.ReadInt(); int num6 = packet.ReadInt(); int num7 = packet.ReadInt(); client.Player.CurrentHotSpringRoom = new HotSpringRoom(new HotSpringRoomInfo(), new TankHotSpringLogicProcessor()); client.Player.CurrentHotSpringRoom.ProcessData(client.Player, packet); return 0; }
public int HandlePacket(GameClient client, GSPacketIn packet) { int num = packet.ReadByte(); int num2 = packet.ReadInt(); PlayerInventory caddyBag = client.Player.CaddyBag; PlayerInventory propBag = client.Player.PropBag; for (int i = 0; i < caddyBag.Capalility; i++) { if (caddyBag.GetItemAt(i) != null) { caddyBag.MoveToStore(caddyBag, i, propBag.FindFirstEmptySlot(0), propBag, 999); } } return 1; }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.CurrentHotSpringRoom != null) { int iD = client.Player.CurrentHotSpringRoom.Info.RoomID; HotSpringRoom room = client.Player.CurrentHotSpringRoom; using (PlayerBussiness db = new PlayerBussiness()) { db.UpdateHotSpringRoomInfo(room.Info); } GSPacketIn pkg = new GSPacketIn(0xa9); pkg.WriteString("Bạn đã thoát khỏi phòng"); client.SendTCP(pkg); } return 0; }
public int HandlePacket(GameClient client, GSPacketIn packet) { int num = packet.ReadInt(); try { TankHotSpringLogicProcessor processor = new TankHotSpringLogicProcessor(); HotSpringRoomInfo info = new HotSpringRoomInfo { RoomID = num }; client.Player.CurrentHotSpringRoom = new HotSpringRoom(info, processor); } catch { Console.WriteLine("System Error!"); } HotSpringRoom room = client.Player.CurrentHotSpringRoom; using (PlayerBussiness db = new PlayerBussiness()) { db.UpdateHotSpringRoomInfo(room.Info); } string str = packet.ReadString(); GSPacketIn pkg = new GSPacketIn(0xca); pkg.WriteInt(num); pkg.WriteInt(num); pkg.WriteString(room.Info.RoomName); pkg.WriteString(room.Info.Pwd); pkg.WriteInt(1); pkg.WriteInt(1); pkg.WriteInt(client.Player.PlayerCharacter.ID); pkg.WriteString(client.Player.PlayerCharacter.NickName); pkg.WriteDateTime(room.Info.BeginTime); pkg.WriteString(room.Info.RoomIntroduction); pkg.WriteInt(1); pkg.WriteInt(10); pkg.WriteDateTime(DateTime.Now); pkg.WriteInt(10); client.SendTCP(pkg); return 0; }
public static IPacketLib CreatePacketLibForVersion(int rawVersion, GameClient client) { foreach (Type t in ScriptMgr.GetDerivedClasses(typeof(IPacketLib))) { foreach (PacketLibAttribute attr in t.GetCustomAttributes(typeof(PacketLibAttribute), false)) { if (attr.RawVersion == rawVersion) { try { IPacketLib lib = (IPacketLib)Activator.CreateInstance(t, new object[] { client }); return lib; } catch (Exception e) { if (log.IsErrorEnabled) log.Error("error creating packetlib (" + t.FullName + ") for raw version " + rawVersion, e); } } } } return null; }
/// <summary> /// Constructs a new PacketProcessor /// </summary> /// <param name="client">The processor client</param> public PacketProcessor(GameClient client) { m_client = client; }
public new GameClient[] GetAllClients() { GameClient[] list = null; lock (_clients.SyncRoot) { list = new GameClient[_clients.Count]; _clients.Keys.CopyTo(list, 0); } return list; }
public AbstractPacketLib(GameClient client) { m_gameClient = client; }
public int HandlePacket(GameClient client, GSPacketIn packet) { int Lottery = client.Lottery; int[] numArray = listRandomitem[Lottery]; PlayerInventory caddyBag = client.Player.CaddyBag; PlayerInventory propBag = client.Player.PropBag; SqlDataProvider.Data.ItemInfo itemByTemplateID = propBag.GetItemByTemplateID(0, 11444); try { ThreadSafeRandom random = new ThreadSafeRandom(); int num2 = random.Next(100) * random.Next(100); int index = 0; string[] strArray = client.tempData.Split(new char[] { ',' }); List<int> list = new List<int>(); if (client.tempData != "start") { foreach (string str in strArray) { if (!string.IsNullOrEmpty(str)) { list.Add(int.Parse(str)); } } } IOrderedEnumerable<int> enumerable = from s in list orderby s select s; foreach (int num4 in RandomForGetItem) { if (num2 < (num4 * num4)) { foreach (int num5 in enumerable) { if (index == num5) { index++; } } break; } index++; } if (itemByTemplateID.Count > strArray.Length) { itemByTemplateID.Count -= strArray.Length; propBag.UpdateItem(itemByTemplateID); } else if (itemByTemplateID.Count == strArray.Length) { propBag.RemoveItem(itemByTemplateID); } if (client.tempData == "start") { client.tempData = index + ","; } else { client.tempData = client.tempData + index + ","; } if (index >= numArray.Length) { index = 0; } SqlDataProvider.Data.ItemInfo item = SqlDataProvider.Data.ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(numArray[index]), 1, 105); item.BeginDate = DateTime.Now; item.ValidDate = 7; item.RemoveDate = DateTime.Now.AddDays(7.0); caddyBag.AddItem(item); GSPacketIn pkg = new GSPacketIn(30, client.Player.PlayerId); pkg.WriteInt(numArray[index]); pkg.WriteInt(0); pkg.WriteInt(0); pkg.WriteInt(0); pkg.WriteInt(0); pkg.WriteInt(0); pkg.WriteInt(0); pkg.WriteBoolean(false); pkg.WriteInt(7); pkg.WriteByte(1); client.SendTCP(pkg); } catch { Console.WriteLine("Error "); } return 1; }
public int HandlePacket(GameClient client, GSPacketIn packet) { bool isStack = packet.ReadBoolean(); int count = packet.ReadInt(); int bagType = packet.ReadInt(); PlayerInventory inventory = client.Player.GetInventory((eBageType)bagType); List<ItemInfo> recoverItems = inventory.GetItems(inventory.BeginSlot, inventory.Capalility - 1); if (count == recoverItems.Count) { inventory.BeginChanges(); bool result = false; try { ItemInfo[] rawitems = inventory.GetRawSpaces(); inventory.ClearBag(); for (int i = 0; i < count; i++) { int oldplace = packet.ReadInt(); int newplace = packet.ReadInt(); ItemInfo it = rawitems[oldplace]; if (!inventory.AddItemTo(it, newplace)) { throw new Exception(string.Format("move item error: old place:{0} new place:{1}", oldplace, newplace)); } } //============================= if (isStack && bagType == 1) { recoverItems = inventory.GetItems(inventory.BeginSlot, inventory.Capalility - 1); List<int> list2 = new List<int>(); for (int i = 0; i < recoverItems.Count; i++) { if (!list2.Contains(i)) { for (int j = recoverItems.Count - 1; j > i; j--) { if (!list2.Contains(j) && ((recoverItems[i].TemplateID == recoverItems[j].TemplateID) && recoverItems[i].CanStackedTo(recoverItems[j]))) { inventory.MoveItem(recoverItems[j].Place, recoverItems[i].Place, recoverItems[j].Count); list2.Add(j); } } } } } recoverItems = inventory.GetItems(inventory.BeginSlot, inventory.Capalility - 1); if (inventory.FindFirstEmptySlot(inventory.BeginSlot) != -1) { for (int k = 1; inventory.FindFirstEmptySlot(inventory.BeginSlot) < recoverItems[recoverItems.Count - k].Place; k++) { inventory.MoveItem(recoverItems[recoverItems.Count - k].Place, inventory.FindFirstEmptySlot(inventory.BeginSlot), recoverItems[recoverItems.Count - k].Count); } } //============================= result = true; } catch (Exception ex) { log.ErrorFormat("Arrage bag errror,user id:{0} msg:{1}", client.Player.PlayerId, ex.Message); } finally { if (!result) { inventory.ClearBag(); foreach (ItemInfo info in recoverItems) { inventory.AddItemTo(info, info.Place); } } inventory.CommitChanges(); } } return 0; }