private void Notice(GamePlayer player, int id, string name) { int rate = ShopMgr.GetLimitCountByID(id) * 100 / ShopMgr.GetLimitMax(id); if (rate == 70 || rate == 50 || rate == 30 || rate == 10) { GSPacketIn pkg = new GSPacketIn(10); pkg.WriteInt(2); pkg.WriteString(LanguageMgr.GetTranslation("UserBuyLimitItemNotice.Content", new object[] { name, ShopMgr.GetLimitCountByID(id) })); GameServer.Instance.LoginServer.SendPacket(pkg); GamePlayer[] players = WorldMgr.GetAllPlayers(); GamePlayer[] array = players; for (int i = 0; i < array.Length; i++) { GamePlayer p = array[i]; if (p != player) { p.Out.SendTCP(pkg); } } } }
public int HandlePacket(GameClient client, GSPacketIn packet) { int num = packet.ReadInt(); packet.ReadBoolean(); if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); return(1); } ShopItemInfo shopItemInfoById = ShopMgr.GetShopItemInfoById(1123301); ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(shopItemInfoById.TemplateID); int num2 = num * shopItemInfoById.AValue1; if (client.Player.PlayerCharacter.Money > num2) { client.Player.RemoveMoney(num2); int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; List <ItemInfo> infos = new List <ItemInfo>(); this.OpenUpItem(itemTemplateInfo.Data, infos, ref num4, ref num3, ref num5, ref num6); int num7 = num * num4; client.Player.AddGold(num7); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bạn nhận được " + num7 + " vàng.", new object[0])); } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserBuyItemHandler.NoMoney", new object[0])); } return(0); }
void Awake() { Inst = this; _enemy = gameObject.AddComponent <EnemyMgr>(); _ui = gameObject.AddComponent <UIMgr>(); _shop = gameObject.AddComponent <ShopMgr>(); _npc = gameObject.AddComponent <NPCMgr>(); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { eMessageType eMsg = eMessageType.Normal; string msg = "UserChangeItemColorHandler.Success"; int Card_bagType = packet.ReadInt(); int Card_place = packet.ReadInt(); int bagType = packet.ReadInt(); int place = packet.ReadInt(); string color = packet.ReadString(); string skin = packet.ReadString(); int templateID = packet.ReadInt(); ItemInfo item = player.MainBag.GetItemAt(place); ItemInfo card = player.PropBag.GetItemAt(Card_place); if (item != null) { player.BeginChanges(); try { bool changed = false; if (card != null && card.IsValidItem()) { player.PropBag.RemoveItem(card, eItemRemoveType.Use); changed = true; } else { ItemTemplateInfo template = ItemMgr.FindItemTemplate(templateID); List <ShopItemInfo> Template = ShopMgr.FindShopbyTemplatID(templateID); int Money = 0; for (int i = 0; i < Template.Count; i++) { if (Template[i].APrice1 == -1 && Template[i].AValue1 != 0) { Money = Template[i].AValue1; } } if (Money <= player.PlayerCharacter.Money) { player.RemoveMoney(Money, LogMoneyType.Item, LogMoneyType.Item_Color); changed = true; } } if (changed) { item.Color = ((color == null) ? "" : color); item.Skin = ((skin == null) ? "" : skin); player.MainBag.UpdateItem(item); } } finally { player.CommitChanges(); } } player.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg, new object[0])); return(0); }
private void Notice(GamePlayer player, int id, string name) { float rate = (float)ShopMgr.GetLimitCountByID(id) / (float)ShopMgr.GetLimitMax(id); int index; if (rate <= 0.7f && rate > 0.5f) { index = 0; } else { if (rate <= 0.5f && rate > 0.3f) { index = 1; } else { if (rate <= 0.3f && rate > 0.1f) { index = 2; } else { if (rate > 0.1f || rate <= 0f) { return; } index = 3; } } } if (ShopMgr.GetIsNotice(id, index) != 0) { GSPacketIn pkg = new GSPacketIn(10); pkg.WriteInt(2); pkg.WriteString(LanguageMgr.GetTranslation("UserBuyLimitItemNotice.Content", new object[] { name, ShopMgr.GetLimitCountByID(id) })); GameServer.Instance.LoginServer.SendPacket(pkg); GamePlayer[] players = WorldMgr.GetAllPlayers(); GamePlayer[] array = players; for (int i = 0; i < array.Length; i++) { GamePlayer p = array[i]; if (p != player) { p.Out.SendTCP(pkg); } } ShopMgr.CloseNotice(id, index); GSPacketIn pkg2 = new GSPacketIn(204); pkg2.WriteInt(id); pkg2.WriteInt(index); GameServer.Instance.LoginServer.SendPacket(pkg2); } }
private ItemInfo getitem(GameClient client, int type, string color, string skin, int id) { ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID); ShopItemInfo shopItemInfoById = ShopMgr.GetShopItemInfoById(id); bool flag = false; ItemInfo itemInfo = null; if (shopItemInfoById != null) { itemInfo = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(shopItemInfoById.TemplateID), 1, 102); if (shopItemInfoById.BuyType == 0) { if (1 == type) { itemInfo.ValidDate = shopItemInfoById.AUnit; } if (2 == type) { itemInfo.ValidDate = shopItemInfoById.BUnit; } if (3 == type) { itemInfo.ValidDate = shopItemInfoById.CUnit; } } else { if (1 == type) { itemInfo.Count = shopItemInfoById.AUnit; } if (2 == type) { itemInfo.Count = shopItemInfoById.BUnit; } if (3 == type) { itemInfo.Count = shopItemInfoById.CUnit; } } if (itemInfo != null || shopItemInfoById != null) { itemInfo.Color = ((color == null) ? "" : color); itemInfo.Skin = ((skin == null) ? "" : skin); if (flag) { itemInfo.IsBinds = true; return(itemInfo); } itemInfo.IsBinds = Convert.ToBoolean(shopItemInfoById.IsBind); } } return(itemInfo); }
public void HandleUpdateLimitCount(GSPacketIn pkg) { Dictionary <int, int> temp = new Dictionary <int, int>(); int len = pkg.ReadInt(); for (int i = 0; i < len; i++) { temp.Add(pkg.ReadInt(), pkg.ReadInt()); } ShopMgr.UpdateLimitCount(temp); }
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 bool HandleCommand(TankMarryLogicProcessor process, GamePlayer player, GSPacketIn packet) { bool result; if (player.CurrentMarryRoom != null) { int userID = packet.ReadInt(); int templateID = packet.ReadInt(); ShopItemInfo temp = ShopMgr.FindShopbyTemplatID(templateID).FirstOrDefault <ShopItemInfo>(); if (temp != null) { if (temp.APrice1 == -2) { if (player.PlayerCharacter.Gold >= temp.AValue1) { player.RemoveGold(temp.AValue1); player.CurrentMarryRoom.ReturnPacketForScene(player, packet); player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.Successed1", new object[] { temp.AValue1 })); player.OnUsingItem(temp.TemplateID); result = true; return(result); } player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserFirecrackersCommand.GoldNotEnough", new object[0])); } if (temp.APrice1 == -1) { if (player.PlayerCharacter.Money >= temp.AValue1) { player.RemoveMoney(temp.AValue1, LogMoneyType.Marry, LogMoneyType.Marry_Flower); player.CurrentMarryRoom.ReturnPacketForScene(player, packet); player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.Successed2", new object[] { temp.AValue1 })); player.OnUsingItem(temp.TemplateID); result = true; return(result); } player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough", new object[0])); } } } result = false; return(result); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { GSPacketIn pkg = packet.Clone(); pkg.ClearContext(); Dictionary <int, int> infos = ShopMgr.GetLimitShopItemInfo(); pkg.WriteInt(infos.Count); foreach (int key in infos.Keys) { pkg.WriteInt(key); pkg.WriteInt(infos[key]); } player.SendTCP(pkg); return(0); }
protected void LoadShopLimitCount(object sender) { try { if (DateTime.Now.ToString("hh:mm") == "20:00") { ShopMgr.RefreshLimitCount(); } } catch (Exception e) { //if (GameServer.log.IsErrorEnabled) //{ //} } }
public bool HandleCommand(TankMarryLogicProcessor process, GamePlayer player, GSPacketIn packet) { if (player.CurrentMarryRoom != null /* && player.CurrentMarryRoom.RoomState == eRoomState.FREE*/) { int userID = packet.ReadInt(); int templateID = packet.ReadInt(); //ItemTemplateInfo template = ItemMgr.FindItemTemplate(templateID); ShopItemInfo temp = ShopMgr.FindShopbyTemplatID(templateID).FirstOrDefault(); if (temp != null) { if (temp.APrice1 == -2) { if (player.PlayerCharacter.Gold >= temp.AValue1) { player.RemoveGold(temp.AValue1); //0 player.CurrentMarryRoom.ReturnPacket(player, packet); player.CurrentMarryRoom.ReturnPacketForScene(player, packet); player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.Successed1", temp.AValue1)); return(true); } else { player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserFirecrackersCommand.GoldNotEnough")); } } if (temp.APrice1 == -1) { if (player.PlayerCharacter.Money >= temp.AValue1) { player.RemoveMoney(temp.AValue1); LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Flower, player.PlayerCharacter.ID, temp.AValue1, player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", ""); player.CurrentMarryRoom.ReturnPacketForScene(player, packet); player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.Successed2", temp.AValue1)); return(true); } else { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough")); } } } } return(false); }
public bool HandleCommand(TankMarryLogicProcessor process, GamePlayer player, GSPacketIn packet) { if (player.CurrentMarryRoom != null) { packet.ReadInt(); int templatID = packet.ReadInt(); ShopItemInfo shopItemInfo = ShopMgr.FindShopbyTemplatID(templatID).FirstOrDefault <ShopItemInfo>(); if (shopItemInfo != null) { if (shopItemInfo.APrice1 == -2) { if (player.PlayerCharacter.Gold >= shopItemInfo.AValue1) { player.RemoveGold(shopItemInfo.AValue1); player.CurrentMarryRoom.ReturnPacketForScene(player, packet); player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.Successed1", new object[] { shopItemInfo.AValue1 })); return(true); } player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserFirecrackersCommand.GoldNotEnough", new object[0])); } if (shopItemInfo.APrice1 == -1) { if (player.PlayerCharacter.Money >= shopItemInfo.AValue1) { player.RemoveMoney(shopItemInfo.AValue1); LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Flower, player.PlayerCharacter.ID, shopItemInfo.AValue1, player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", ""); player.CurrentMarryRoom.ReturnPacketForScene(player, packet); player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.Successed2", new object[] { shopItemInfo.AValue1 })); return(true); } player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough", new object[0])); } } } return(false); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int gold = 0; int money = 0; int offer = 0; int gifttoken = 0; int type = 1; List <int> needitemsinfo = new List <int>(); int index = packet.ReadInt(); int GoodsID = packet.ReadInt(); ItemInfo item = player.FightBag.GetItemAt(index); if (item != null) { player.FightBag.RemoveItem(item, eItemRemoveType.Sell); ShopItemInfo shopitem = ShopMgr.GetShopItemInfoById(GoodsID); needitemsinfo = ShopMgr.GetShopItemBuyConditions(shopitem, type, ref gold, ref money, ref offer, ref gifttoken); player.AddGold(gold); } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int value = 0; int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int type = 1; int slot = packet.ReadInt(); int iD = packet.ReadInt(); ItemInfo itemAt = client.Player.FightBag.GetItemAt(slot); if (itemAt != null) { client.Player.FightBag.RemoveItem(itemAt); ShopItemInfo shopItemInfoById = ShopMgr.GetShopItemInfoById(iD); ItemInfo.SetItemType(shopItemInfoById, type, ref value, ref num, ref num2, ref num3, ref num4); client.Player.AddGold(value); } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet)//sendGoodsContinue { if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); return(0); } new StringBuilder(); int num = packet.ReadInt(); string translateId = "UserItemContineueHandler.Success"; for (int i = 0; i < num; i++) { eBageType eBageType = (eBageType)packet.ReadByte(); int num2 = packet.ReadInt(); int iD = packet.ReadInt(); int num3 = (int)packet.ReadByte(); bool flag = packet.ReadBoolean(); int themvao = packet.ReadInt();//_loc_3.writeInt(param1[_loc_4][5]);//4.2 if ((eBageType == eBageType.MainBag && num2 >= 31) || eBageType == eBageType.PropBag || eBageType == eBageType.Consortia) { ItemInfo itemAt = client.Player.GetItemAt(eBageType, num2); int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; int num8 = 0; int validDate = itemAt.ValidDate; DateTime arg_C8_0 = itemAt.BeginDate; int count = itemAt.Count; bool flag2 = itemAt.IsValidItem(); if (itemAt.ValidDate > 365) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Thời gian sử dụng đả đạt mức tối đa.", new object[0])); break; } ShopItemInfo shopItemInfoById = ShopMgr.GetShopItemInfoById(iD); if (shopItemInfoById.TemplateID != itemAt.TemplateID) { Console.WriteLine("HACK GIA HAN " + client.Player.Account); return(0); } ItemInfo.SetItemType(shopItemInfoById, num3, ref num4, ref num5, ref num6, ref num7, ref num8); if (num4 <= client.Player.PlayerCharacter.Gold && num5 <= client.Player.PlayerCharacter.Money && num6 <= client.Player.PlayerCharacter.Offer && num7 <= client.Player.PlayerCharacter.GiftToken) { client.Player.RemoveMoney(num5); client.Player.RemoveGold(num4); client.Player.RemoveOffer(num6); client.Player.RemoveGiftToken(num7); if (!flag2 && itemAt.ValidDate != 0) { itemAt.ValidDate = 0; } if (1 == num3) { itemAt.ValidDate += shopItemInfoById.AUnit; } if (2 == num3) { itemAt.ValidDate += shopItemInfoById.BUnit; } if (3 == num3) { itemAt.ValidDate += shopItemInfoById.CUnit; } if (!flag2 && itemAt.ValidDate != 0) { itemAt.BeginDate = DateTime.Now; itemAt.IsUsed = false; } LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Continue, client.Player.PlayerCharacter.ID, num5, client.Player.PlayerCharacter.Money, num4, 0, 0, 0, "牌子编号", itemAt.TemplateID.ToString(), num3.ToString()); } else { itemAt.ValidDate = validDate; itemAt.Count = count; translateId = "UserItemContineueHandler.NoMoney"; } if (eBageType == eBageType.MainBag) { if (flag) { int toSlot = client.Player.MainBag.FindItemEpuipSlot(itemAt.Template); client.Player.MainBag.MoveItem(num2, toSlot, itemAt.Count); } else { client.Player.MainBag.UpdateItem(itemAt); } } else { if (eBageType == eBageType.PropBag) { client.Player.PropBag.UpdateItem(itemAt); } else { client.Player.ConsortiaBag.UpdateItem(itemAt); } } } } client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(translateId, new object[0])); return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int num = 0; int num2 = 0; int offer = 0; int num3 = 0; int medal = 0; StringBuilder stringBuilder = new StringBuilder(); eMessageType eMessageType = eMessageType.Normal; string translateId = "UserPresentGoodsHandler.Success"; string str = packet.ReadString(); string nickName = packet.ReadString(); int num4 = packet.ReadInt(); List <ItemInfo> list = new List <ItemInfo>(); StringBuilder stringBuilder2 = new StringBuilder(); GamePlayer clientByPlayerNickName = WorldMgr.GetClientByPlayerNickName(nickName); PlayerInfo playerInfo; if (clientByPlayerNickName == null) { using (PlayerBussiness playerBussiness = new PlayerBussiness()) { playerInfo = playerBussiness.GetUserSingleByNickName(nickName); goto IL_78; } } playerInfo = clientByPlayerNickName.PlayerCharacter; IL_78: bool flag = false; for (int i = 0; i < num4; i++) { int iD = packet.ReadInt(); int num5 = packet.ReadInt(); string text = packet.ReadString(); string text2 = packet.ReadString(); packet.ReadInt(); ShopItemInfo shopItemInfoById = ShopMgr.GetShopItemInfoById(iD); ItemTemplateInfo goods = ItemMgr.FindItemTemplate(shopItemInfoById.TemplateID); ItemInfo itemInfo = ItemInfo.CreateFromTemplate(goods, 1, 102); if (shopItemInfoById.BuyType == 0) { if (1 == num5) { itemInfo.ValidDate = shopItemInfoById.AUnit; } if (2 == num5) { itemInfo.ValidDate = shopItemInfoById.BUnit; } if (3 == num5) { itemInfo.ValidDate = shopItemInfoById.CUnit; } } else { if (1 == num5) { itemInfo.Count = shopItemInfoById.AUnit; } if (2 == num5) { itemInfo.Count = shopItemInfoById.BUnit; } if (3 == num5) { itemInfo.Count = shopItemInfoById.CUnit; } } if (itemInfo != null || shopItemInfoById != null) { itemInfo.Color = ((text == null) ? "" : text); itemInfo.Skin = ((text2 == null) ? "" : text2); if (flag) { itemInfo.IsBinds = true; } else { itemInfo.IsBinds = Convert.ToBoolean(shopItemInfoById.IsBind); } stringBuilder2.Append(num5); stringBuilder2.Append(","); list.Add(itemInfo); ItemInfo.SetItemType(shopItemInfoById, num5, ref num, ref num2, ref offer, ref num3, ref medal); } } if (list.Count == 0) { return(1); } if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); return(1); } if (num <= client.Player.PlayerCharacter.Gold && num2 <= client.Player.PlayerCharacter.Money && num3 <= client.Player.PlayerCharacter.GiftToken) { client.Player.RemoveMoney(num2); client.Player.RemoveGold(num); client.Player.RemoveGiftToken(num3); string text3 = ""; int num6 = 0; MailInfo mailInfo = new MailInfo(); StringBuilder stringBuilder3 = new StringBuilder(); stringBuilder3.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark", new object[0])); for (int j = 0; j < list.Count; j++) { text3 += ((text3 == "") ? list[j].TemplateID.ToString() : ("," + list[j].TemplateID.ToString())); using (PlayerBussiness playerBussiness2 = new PlayerBussiness()) { list[j].UserID = 0; playerBussiness2.AddGoods(list[j]); num6++; stringBuilder3.Append(num6); stringBuilder3.Append("、"); stringBuilder3.Append(list[j].Template.Name); stringBuilder3.Append("x"); stringBuilder3.Append(list[j].Count); stringBuilder3.Append(";"); switch (num6) { case 1: mailInfo.Annex1 = list[j].ItemID.ToString(); mailInfo.Annex1Name = list[j].Template.Name; break; case 2: mailInfo.Annex2 = list[j].ItemID.ToString(); mailInfo.Annex2Name = list[j].Template.Name; break; case 3: mailInfo.Annex3 = list[j].ItemID.ToString(); mailInfo.Annex3Name = list[j].Template.Name; break; case 4: mailInfo.Annex4 = list[j].ItemID.ToString(); mailInfo.Annex4Name = list[j].Template.Name; break; case 5: mailInfo.Annex5 = list[j].ItemID.ToString(); mailInfo.Annex5Name = list[j].Template.Name; break; } if (num6 == 5) { num6 = 0; mailInfo.AnnexRemark = stringBuilder3.ToString(); stringBuilder3.Remove(0, stringBuilder3.Length); stringBuilder3.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark", new object[0])); mailInfo.Content = LanguageMgr.GetTranslation("UserBuyItemHandler.Title", new object[0]) + mailInfo.Annex1Name + "] " + str; mailInfo.Gold = 0; mailInfo.Money = 0; mailInfo.Receiver = playerInfo.NickName; mailInfo.ReceiverID = playerInfo.ID; mailInfo.Sender = client.Player.PlayerCharacter.NickName; mailInfo.SenderID = client.Player.PlayerCharacter.ID; mailInfo.Title = mailInfo.Content; mailInfo.Type = 8; playerBussiness2.SendMail(mailInfo); eMessageType = eMessageType.ERROR; mailInfo.Revert(); } } } if (num6 > 0) { using (PlayerBussiness playerBussiness3 = new PlayerBussiness()) { mailInfo.AnnexRemark = stringBuilder3.ToString(); mailInfo.Content = LanguageMgr.GetTranslation("UserBuyItemHandler.Title", new object[0]) + mailInfo.Annex1Name + "] " + str; mailInfo.Gold = 0; mailInfo.Money = 0; mailInfo.Receiver = playerInfo.NickName; mailInfo.ReceiverID = playerInfo.ID; mailInfo.Sender = client.Player.PlayerCharacter.NickName; mailInfo.SenderID = client.Player.PlayerCharacter.ID; mailInfo.Title = mailInfo.Content; mailInfo.Type = 8; playerBussiness3.SendMail(mailInfo); eMessageType = eMessageType.ERROR; } } if (eMessageType == eMessageType.ERROR && clientByPlayerNickName != null) { clientByPlayerNickName.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Receiver); } client.Player.OnPaid(num2, num, offer, num3, medal, stringBuilder.ToString()); LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Buy, client.Player.PlayerCharacter.ID, num2, client.Player.PlayerCharacter.Money, num, num3, offer, medal, "牌子编号", text3, stringBuilder2.ToString()); } else { if (num > client.Player.PlayerCharacter.Gold) { translateId = "UserBuyItemHandler.NoGold"; } if (num2 > client.Player.PlayerCharacter.Money) { translateId = "UserBuyItemHandler.NoMoney"; } if (num3 > client.Player.PlayerCharacter.GiftToken) { translateId = "UserBuyItemHandler.GiftToken"; } eMessageType = eMessageType.ERROR; } client.Out.SendMessage(eMessageType, LanguageMgr.GetTranslation(translateId, new object[0])); return(0); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int totalGold = 0; int totalMoney = 0; int totalOffer = 0; int totalGifttoken = 0; int buyItemCount = 0; eMessageType eMsg = eMessageType.Normal; string msg = "UserBuyItemHandler.Success"; GSPacketIn pkg = new GSPacketIn(44); List <ItemInfo> buyItems = new List <ItemInfo>(); List <ItemInfo> canNotBuyItems = new List <ItemInfo>(); List <int> needitemsinfo = new List <int>(); Dictionary <int, int> changeLimitShopsID = new Dictionary <int, int>(); List <bool> dresses = new List <bool>(); List <int> places = new List <int>(); List <ItemJoinShopInfo> log = new List <ItemJoinShopInfo>(); Dictionary <int, int> playerPayGoods = new Dictionary <int, int>(); int result2; if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); result2 = 1; } else { ConsortiaInfo consotia = ConsortiaMgr.FindConsortiaInfo(player.PlayerCharacter.ConsortiaID); int count = packet.ReadInt(); for (int i = 0; i < count; i++) { int goodsId = packet.ReadInt(); int type = packet.ReadInt(); string color = packet.ReadString(); bool isDress = packet.ReadBoolean(); string skin = packet.ReadString(); int place = packet.ReadInt(); bool isBind = false; int gold = 0; int money = 0; int offer = 0; int gifttoken = 0; ShopItemInfo shopItem = ShopMgr.GetShopItemInfoById(goodsId); if (shopItem != null && shopItem.ShopID != 21 && shopItem.ShopID != 22) { if (shopItem.ShopID == 2 || !ShopMgr.CanBuy(shopItem.ShopID, (consotia == null) ? 1 : consotia.ShopLevel, ref isBind, player.PlayerCharacter.ConsortiaID, player.PlayerCharacter.Riches)) { player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.FailbyPermission", new object[0])); result2 = 1; return(result2); } List <int> needsItems = ShopMgr.GetShopItemBuyConditions(shopItem, type, ref gold, ref money, ref offer, ref gifttoken); for (int j = 0; j < needsItems.Count; j += 2) { if (!playerPayGoods.ContainsKey(needsItems[j])) { playerPayGoods.Add(needsItems[j], player.GetItemCount(needsItems[j])); } } bool result = true; string needsItemsLog = ""; for (int j = 0; j < needsItems.Count; j += 2) { if (playerPayGoods.ContainsKey(needsItems[j]) && playerPayGoods[needsItems[j]] >= needsItems[j + 1]) { foreach (int a in needsItems) { needitemsinfo.Add(a); } string text = needsItemsLog; needsItemsLog = string.Concat(new string[] { text, needsItems[j].ToString(), ":", needsItems[j + 1].ToString(), "|" }); Dictionary <int, int> dictionary; int key; (dictionary = playerPayGoods)[key = needsItems[j]] = dictionary[key] - needsItems[j + 1]; } else { result = false; } } ItemInfo item = ShopMgr.CreateItem(shopItem, 102, type, color, skin, isBind); int limitCount = ShopMgr.GetLimitCountByID(goodsId); if (limitCount == -1 || limitCount > 0) { if (result && player.PlayerCharacter.Gold >= gold + totalGold && player.PlayerCharacter.Money >= money + totalMoney && player.PlayerCharacter.Offer >= offer + totalOffer && player.PlayerCharacter.GiftToken >= gifttoken + totalGifttoken) { totalGold += gold; totalMoney += money; totalOffer += offer; totalGifttoken += gifttoken; buyItemCount++; buyItems.Add(item); dresses.Add(isDress); places.Add(place); if (limitCount != -1) { ShopMgr.SubtractShopLimit(goodsId); this.Notice(player, goodsId, item.Template.Name); if (!changeLimitShopsID.ContainsKey(goodsId)) { changeLimitShopsID.Add(goodsId, ShopMgr.GetLimitCountByID(goodsId)); } else { changeLimitShopsID[goodsId] = ShopMgr.GetLimitCountByID(goodsId); } } log.Add(new ItemJoinShopInfo(item.TemplateID, item.Count, money, gold, gifttoken, offer, needsItemsLog)); } else { canNotBuyItems.Add(item); } } } } if (buyItems.Count == 0) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserBuyItemHandler.Failed", new object[0])); result2 = 1; } else { int buyFrom = packet.ReadInt(); player.RemoveMoney(totalMoney, LogMoneyType.Shop, LogMoneyType.Shop_Buy); player.RemoveGold(totalGold); player.RemoveOffer(totalOffer); player.RemoveGiftToken(totalGifttoken); StringBuilder allPayItemsStr = new StringBuilder(); for (int j = 0; j < needitemsinfo.Count; j += 2) { player.RemoveTemplate(needitemsinfo[j], needitemsinfo[j + 1], eItemRemoveType.Shopping); allPayItemsStr.Append(needitemsinfo[j]).Append(","); } foreach (ItemJoinShopInfo templog in log) { //LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Buy, player.PlayerCharacter.ID, templog.Moneys, templog.Gold, templog.GiftToken, templog.Offer, templog.OtherPay, templog.TemplateID, 4, templog.Data); } List <ItemInfo> lastItems = new List <ItemInfo>(); player.StackItem(ref buyItems); for (int i = 0; i < buyItems.Count; i++) { switch (buyFrom) { case 0: case 3: if (player.AddItem(buyItems[i])) { if (dresses[i]) { player.EquipItem(buyItems[i], places[i]); msg = "UserBuyItemHandler.Save"; } } else { lastItems.Add(buyItems[i]); } break; case 1: if (!UserBuyItemHandler.AddStrengthItemsToHideBag(player, buyItems[i])) { lastItems.Add(buyItems[i]); } break; case 2: if (!UserBuyItemHandler.AddComposeItemsToHideBag(player, buyItems[i])) { lastItems.Add(buyItems[i]); } break; case 4: if (!UserBuyItemHandler.AddFusionItemsToHideBag(player, buyItems[i])) { lastItems.Add(buyItems[i]); } break; } } bool sentMail = false; if (lastItems.Count > 0) { string title = ""; sentMail = player.SendItemsToMail(lastItems, "", title, eMailType.BuyItem); msg = "UserBuyItemHandler.Mail"; } if (canNotBuyItems.Count > 0) { string title = LanguageMgr.GetTranslation("UserBuyItemHandler.ListTitle", new object[0]); StringBuilder content = new StringBuilder(); if (buyItems.Count > 0) { content.Append(LanguageMgr.GetTranslation("UserBuyItemHandler.BuyList", new object[] { buyItems.Count })); for (int i = 0; i < buyItems.Count; i++) { content.Append(string.Format("{0}{1}", (i == 0) ? "" : ";", buyItems[i].Template.Name)); } } if (canNotBuyItems.Count > 0) { content.Append(LanguageMgr.GetTranslation("UserBuyItemHandler.NoBuyList", new object[] { "\n" })); for (int j = 0; j < canNotBuyItems.Count; j++) { content.Append(string.Format("{0}{1}", (j == 0) ? "" : ";", canNotBuyItems[j].Template.Name)); } } sentMail = player.SendMail(content.ToString(), title, null, eMailType.BuyItem); } if (sentMail) { player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver); } player.OnPaid(totalMoney, totalGold, totalOffer, totalGifttoken, allPayItemsStr.ToString()); int buyResult = 0; if (buyItemCount == count) { buyResult = (sentMail ? 2 : 1); } pkg.WriteInt(buyResult); pkg.WriteInt(buyFrom); player.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg, new object[0])); player.Out.SendTCP(pkg); player.SaveIntoDatabase(); this.UpdateLimitShopCount(player, changeLimitShopsID); result2 = 0; } } return(result2); }
public static void DoCommand(string CommandName, string[] CommandArgs) { PlayerBussiness bussiness; PlayerInfo userSingleByNickName; Exception exception; string str3; string str4; string str5; ManageBussiness bussiness2; switch (CommandName) { case "exit": GameServer.KeepRunning = false; break; case "cp": { GameClient[] allClients = GameServer.Instance.GetAllClients(); int num = (allClients == null) ? 0 : allClients.Length; GamePlayer[] allPlayers = WorldMgr.GetAllPlayers(); int num2 = (allPlayers == null) ? 0 : allPlayers.Length; List <BaseRoom> allUsingRoom = RoomMgr.GetAllUsingRoom(); int num3 = 0; int num4 = 0; foreach (BaseRoom room in allUsingRoom) { if (!room.IsEmpty) { num3++; if (room.IsPlaying) { num4++; } } } double totalMemory = GC.GetTotalMemory(false); Console.WriteLine(string.Format("Total Clients/Players:{0}/{1}", num, num2)); Console.WriteLine(string.Format("Total Rooms/Games:{0}/{1}", num3, num4)); Console.WriteLine(string.Format("Total Momey Used:{0} MB", (totalMemory / 1024.0) / 1024.0)); break; } case "setlevel": try { string path = Path.Combine(Environment.CurrentDirectory, "LevelList.xml"); if (!File.Exists(path)) { log.Error("LevelList.xml not found!"); } else { int num6; Console.Write("Please enter the level: "); string s = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!int.TryParse(s, out num6)) { log.Error("Level is not valid int!"); } else { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName == null) { log.Error(string.Format("Player not found in db!", new object[0])); break; } if (!IsValidGZip(File.ReadAllBytes(path))) { log.Error("LevelList.xml is not valid!"); } else if (!IsValidXML(GZip.gzuncompress(File.ReadAllBytes(path)))) { log.Error("LevelList.xml is not valid!"); } if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } XmlDocument document = new XmlDocument(); document.LoadXml(GZip.gzuncompress(File.ReadAllBytes(path))); int num7 = -1; int num8 = -1; foreach (XmlNode node in document.SelectNodes("/Result/*")) { if (node.Attributes["Grade"].Value == s) { num7 = int.Parse(s); num8 = int.Parse(node.Attributes["GP"].Value) + 5; break; } } if ((num7 != -1) && (num8 != -1)) { userSingleByNickName.GP = num8; userSingleByNickName.Grade = num7; bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } else { log.Error(string.Format("Level {0} not found!", new object[0])); } } } } } catch (Exception exception1) { exception = exception1; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "addmoney": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of money: "); str3 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str3)) { log.Error("Money is not valid!"); } else { userSingleByNickName.Money += int.Parse(str3); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception3) { exception = exception3; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "addgold": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of gold: "); str4 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str4)) { log.Error("Gold is not valid!"); } else { userSingleByNickName.Gold += int.Parse(str4); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception4) { exception = exception4; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "addgift": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { Console.Write("Please enter the amount of gift token: "); str5 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str5)) { log.Error("Gold is not valid!"); } else { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } userSingleByNickName.GiftToken += int.Parse(str5); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception5) { exception = exception5; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "removemoney": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of money: "); str3 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str3)) { log.Error("Money is not valid!"); } else { userSingleByNickName.Money -= int.Parse(str3); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception6) { exception = exception6; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "removegold": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of gold: "); str4 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str4)) { log.Error("Gold is not valid!"); } else { userSingleByNickName.Gold -= int.Parse(str4); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception7) { exception = exception7; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "removegift": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of gift token: "); str5 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str5)) { log.Error("Gold is not valid!"); } else { userSingleByNickName.GiftToken -= int.Parse(str5); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception8) { exception = exception8; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "shutdown": _count = 6; _timer = new System.Threading.Timer(new TimerCallback(ConsoleStart.ShutDownCallBack), null, 0, 0xea60); break; case "addcps": try { Console.Write("Insira o valor dos Cupons:"); int num9 = int.Parse((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); foreach (GamePlayer player in WorldMgr.GetAllPlayers()) { player.AddMoney(num9); player.SendMessage("Parab\x00e9ns, voc\x00ea recebeu " + num9 + " cupons do evento, bom jogo !"); } } catch (Exception exception9) { exception = exception9; log.Error("Error on AddCps", exception); } break; case "bnick": { Console.Clear(); Console.WriteLine("Digite o NickName do personagem: "); string nickName = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para banir: "); string msg = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); DateTime date = new DateTime(0x7e1, 7, 2); using (bussiness2 = new ManageBussiness()) { bussiness2.ForbidPlayerByNickName(nickName, date, false); bussiness2.KitoffUserByNickName(nickName, msg); } Console.WriteLine("O Usu\x00e1rio " + nickName + " Foi Banido do servidor."); foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + nickName + " foi banido do servidor, motivo do BAN: " + msg + "."); } break; } case "buser": { Console.Clear(); Console.WriteLine("Digite o UserName do personagem: "); string userName = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para banir: "); string str9 = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); DateTime time2 = new DateTime(0x7e1, 7, 2); using (bussiness2 = new ManageBussiness()) { bussiness2.ForbidPlayerByUserName(userName, time2, false); bussiness2.KitoffUserByUserName(userName, str9); } Console.WriteLine("O Usu\x00e1rio " + userName + " Foi Banido do servidor."); foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + userName + " foi banido do servidor, motivo do BAN: " + str9 + "."); } break; } case "nkick": { Console.Clear(); Console.WriteLine("Digite o NickName do personagem: "); string name = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para kikar: "); string str11 = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); using (bussiness2 = new ManageBussiness()) { bussiness2.KitoffUserByNickName(name, str11); } foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + name + " foi kikado do servidor, motivo do KICK: " + str11 + "."); } break; } case "ukick": { Console.Clear(); Console.WriteLine("Digite o NickName do personagem: "); string str12 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para kikar: "); string str13 = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); using (bussiness2 = new ManageBussiness()) { bussiness2.KitoffUserByUserName(str12, str13); } foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + str12 + " foi kikado do servidor, motivo do KICK: " + str13 + "."); } break; } case "maint": try { int num10; Console.Write("Enter time in minutes to start maintenance: "); string str14 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!int.TryParse(str14, out num10)) { log.Error("Invalid MainTime!"); } else { new Thread(delegate(object mt) { if (mt is string) { Action <string, string> Sys = delegate(string nick, string Text) { Console.WriteLine(Text); foreach (GamePlayer player in WorldMgr.GetAllPlayers()) { player.SendMessage(string.Format("[{0}] {1}", nick, Text)); } }; Action DisconnectAll = delegate { foreach (GamePlayer player in WorldMgr.GetAllPlayers()) { log.Info(string.Format("Saving Player {0} into Database!", player.PlayerCharacter.NickName)); player.SaveIntoDatabase(); log.Info(string.Format("Disconnecting Player {0}!", player.PlayerCharacter.NickName)); player.Disconnect(); } log.Info("Shutdown Server!"); GameServer.Instance.Shutdown(); LogManager.Shutdown(); }; Sys("Auto Maintenance", "Manuten\x00e7\x00e3o agendada, fiquem atentos aos aviso!"); System.Timers.Timer MainTimer = new System.Timers.Timer { Interval = 1000.0 }; DateTime MainTime = DateTime.Parse(string.Format("{0} 00:00:00", "01/27/2011"), CultureInfo.GetCultureInfo("en-US")); MainTime = MainTime.AddMinutes(double.Parse(mt as string)); string CurrentTime = MainTime.ToString("HH:mm:ss"); MainTimer.Elapsed += delegate(object s, ElapsedEventArgs e) { if (CurrentTime != "00:00:00") { if ((MainTime.Minute != 0) && (MainTime.Second == 0)) { Sys("Auto Maintenance", string.Format("Falta {0} {1} para a manuten\x00e7\x00e3o!", MainTime.Minute, (MainTime.Minute == 1) ? "Minuto" : "Minutos")); } else if (MainTime.Second < 11) { Sys("Auto Maintenance", string.Format("Fechando o servidor em {0}", MainTime.Second)); } CurrentTime = MainTime.AddSeconds(-1.0).ToString("HH:mm:ss"); } else { Sys("Auto Maintenance", "Estamos desconectando todos os usu\x00e1rios para a manuten\x00e7\x00e3o, voltamos daqui a alguns minutos, saiam do servidor para evitar perca de itens!"); log.Info("End!"); DisconnectAll(); MainTimer.Stop(); } }; MainTimer.Start(); } }).Start(str14); } } catch (Exception exception10) { exception = exception10; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "savemap": break; case "clear": Console.Clear(); break; case "ball&reload": if (BallMgr.ReLoad()) { Console.WriteLine("Ball info is Reload!"); } else { Console.WriteLine("Ball info is Error!"); } break; case "map&reload": if (!MapMgr.ReLoadMap()) { Console.WriteLine("Map info is Error!"); break; } Console.WriteLine("Map info is Reload!"); break; case "mapserver&reload": if (!MapMgr.ReLoadMapServer()) { Console.WriteLine("mapserver info is Error!"); break; } Console.WriteLine("mapserver info is Reload!"); break; case "prop&reload": if (!PropItemMgr.Reload()) { Console.WriteLine("prop info is Error!"); break; } Console.WriteLine("prop info is Reload!"); break; case "item&reload": if (!ItemMgr.ReLoad()) { Console.WriteLine("item info is Error!"); break; } Console.WriteLine("item info is Reload!"); break; case "shop&reload": if (!ShopMgr.ReLoad()) { Console.WriteLine("shop info is Error!"); break; } Console.WriteLine("shop info is Reload!"); break; case "quest&reload": if (!QuestMgr.ReLoad()) { Console.WriteLine("quest info is Error!"); break; } Console.WriteLine("quest info is Reload!"); break; case "fusion&reload": if (!FusionMgr.ReLoad()) { Console.WriteLine("fusion info is Error!"); break; } Console.WriteLine("fusion info is Reload!"); break; case "consortia&reload": if (!ConsortiaMgr.ReLoad()) { Console.WriteLine("consortiaMgr info is Error!"); break; } Console.WriteLine("consortiaMgr info is Reload!"); break; case "rate&reload": if (!RateMgr.ReLoad()) { Console.WriteLine("Rate Rate is Error!"); break; } Console.WriteLine("Rate Rate is Reload!"); break; case "fight&reload": if (!FightRateMgr.ReLoad()) { Console.WriteLine("FightRateMgr is Error!"); break; } Console.WriteLine("FightRateMgr is Reload!"); break; case "dailyaward&reload": if (!AwardMgr.ReLoad()) { Console.WriteLine("dailyaward is Error!"); break; } Console.WriteLine("dailyaward is Reload!"); break; case "language&reload": if (!LanguageMgr.Reload("")) { Console.WriteLine("language is Error!"); break; } Console.WriteLine("language is Reload!"); break; case "treasure&reload": if (!TreasureAwardMgr.ReLoad()) { Console.WriteLine("TreasureAward is Error!"); break; } Console.WriteLine("TreasureAward is Reload!"); break; case "nickname": { Console.WriteLine("Please enter the nickname"); string str15 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine(WorldMgr.GetPlayerStringByPlayerNickName(str15)); break; } default: { string cmdLine = CommandName + string.Join(" ", CommandArgs); if (cmdLine.Length > 0) { if (cmdLine[0] == '/') { cmdLine = cmdLine.Remove(0, 1).Insert(0, "&"); } try { if (!CommandMgr.HandleCommandNoPlvl(client, cmdLine)) { Console.WriteLine("Unknown command: " + cmdLine); } } catch (Exception exception2) { Console.WriteLine(exception2.ToString()); } } break; } } }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int result2; if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); result2 = 0; } else { StringBuilder payGoods = new StringBuilder(); int count = packet.ReadInt(); bool istips = true; for (int i = 0; i < count; i++) { eBageType bag = (eBageType)packet.ReadByte(); int place = packet.ReadInt(); int goodsID = packet.ReadInt(); int type = (int)packet.ReadByte(); bool isDress = packet.ReadBoolean(); if (bag == eBageType.MainBag || bag == eBageType.PropBag || bag == eBageType.Bank) { ItemInfo item = player.GetItemAt(bag, place); if (item != null && item.ValidDate != 0 && !item.IsValidItem() && (bag == eBageType.MainBag || (bag == eBageType.PropBag && item.TemplateID == 10200))) { int gold = 0; int money = 0; int offer = 0; int gifttoken = 0; int oldDate = item.ValidDate; int oldCount = item.Count; bool isValid = item.IsValidItem(); List <int> needitemsinfo = new List <int>(); ShopItemInfo shopitem = ShopMgr.GetShopItemInfoById(goodsID); needitemsinfo = ShopMgr.GetShopItemBuyConditions(shopitem, type, ref gold, ref money, ref offer, ref gifttoken); int icount = player.MainBag.GetItems().Count; bool result = true; for (int j = 0; j < needitemsinfo.Count; j += 2) { if (player.GetItemCount(needitemsinfo[j]) < needitemsinfo[j + 1]) { result = false; } } if (!result) { eMessageType eMsg = eMessageType.ERROR; string msg = "UserBuyItemHandler.NoBuyItem"; player.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg, new object[0])); result2 = 1; return(result2); } if (gold <= player.PlayerCharacter.Gold && money <= player.PlayerCharacter.Money && offer <= player.PlayerCharacter.Offer && gifttoken <= player.PlayerCharacter.GiftToken) { player.RemoveMoney(money, LogMoneyType.Shop, LogMoneyType.Shop_Continue); player.RemoveGold(gold); player.RemoveOffer(offer); player.RemoveGiftToken(gifttoken); for (int j = 0; j < needitemsinfo.Count; j += 2) { player.RemoveTemplate(needitemsinfo[j], needitemsinfo[j + 1], eItemRemoveType.ShoppingForContinue); payGoods.Append(needitemsinfo[j].ToString() + ":"); } if (!isValid && item.ValidDate != 0) { if (1 == type) { item.ValidDate = shopitem.AUnit; item.BeginDate = DateTime.Now; item.IsUsed = true; } if (2 == type) { item.ValidDate = shopitem.BUnit; item.BeginDate = DateTime.Now; item.IsUsed = true; } if (3 == type) { item.ValidDate = shopitem.CUnit; item.BeginDate = DateTime.Now; item.IsUsed = true; } } if (bag == eBageType.MainBag) { player.MainBag.UpdateItem(item); } else { if (bag == eBageType.PropBag) { player.PropBag.UpdateItem(item); } else { player.StoreBag.UpdateItem(item); } } //LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Continue, player.PlayerCharacter.ID, money, gold, gifttoken, offer, "", item.TemplateID, 6, item.Count); } else { if (money <= player.PlayerCharacter.Money) { istips = false; item.ValidDate = oldDate; item.Count = oldCount; player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserItemContineueHandler.NoMoney", new object[0])); } else { if (gifttoken <= player.PlayerCharacter.GiftToken) { istips = false; item.ValidDate = oldDate; item.Count = oldCount; player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserItemContineueHandler.NoMoney", new object[0])); } } } } } } if (istips) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserItemContineueHandler.Success", new object[0])); } result2 = 0; } return(result2); }
public int HandlePacket(GameClient client, GSPacketIn packet) { //判断是否结婚 if (client.Player.PlayerCharacter.IsMarried) { return(1); } //是否有二级密码 if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked")); return(1); } //开始求婚,购买戒指 int SpouseID = packet.ReadInt(); string loveProclamation = packet.ReadString(); bool Broadcast = packet.ReadBoolean(); bool result = false; bool removeRing = true; string SpouseName = ""; using (PlayerBussiness db = new PlayerBussiness()) { PlayerInfo tempSpouse = db.GetUserSingleByUserID(SpouseID); if (tempSpouse == null || tempSpouse.Sex == client.Player.PlayerCharacter.Sex) { return(1); } if (tempSpouse.IsMarried) { client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg2")); return(1); } ItemInfo WeddingRing = client.Player.PropBag.GetItemByTemplateID(0, 11103); if (WeddingRing == null) { ShopItemInfo tempRing = ShopMgr.FindShopbyTemplatID(11103).FirstOrDefault(); if (tempRing != null) { //玩家身上钱是否足够。 if (client.Player.PlayerCharacter.Money >= tempRing.AValue1) { removeRing = false; } else { client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg1")); return(1); } } else { client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg6")); return(1); } } //插入结婚消息 MarryApplyInfo info = new MarryApplyInfo(); info.UserID = SpouseID; info.ApplyUserID = client.Player.PlayerCharacter.ID; info.ApplyUserName = client.Player.PlayerCharacter.NickName; info.ApplyType = 1; info.LoveProclamation = loveProclamation; info.ApplyResult = false; int id = 0; if (db.SavePlayerMarryNotice(info, 0, ref id)) { if (removeRing) { client.Player.RemoveItem(WeddingRing); } else { //未开始 ShopItemInfo tempRing = ShopMgr.FindShopbyTemplatID(11103).FirstOrDefault(); client.Player.RemoveMoney(tempRing.AValue1); LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Spark, client.Player.PlayerCharacter.ID, tempRing.AValue1, client.Player.PlayerCharacter.Money, 0, 0, 0, 0, "", tempRing.TemplateID.ToString(), "1"); } client.Player.Out.SendPlayerMarryApply(client.Player, client.Player.PlayerCharacter.ID, client.Player.PlayerCharacter.NickName, loveProclamation, id); //发送求婚信息 //发送消息给中心服务器 GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(SpouseID); SpouseName = tempSpouse.NickName; result = true; client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg3")); } } if (result && Broadcast && SpouseName != "") { string msg = LanguageMgr.GetTranslation("MarryApplyHandler.Msg5", client.Player.PlayerCharacter.NickName, SpouseName); GSPacketIn pkg = new GSPacketIn((byte)ePackageType.SYS_NOTICE); pkg.WriteInt(2); pkg.WriteString(msg); GameServer.Instance.LoginServer.SendPacket(pkg); GamePlayer[] players = WorldMgr.GetAllPlayers(); foreach (GamePlayer p in players) { p.Out.SendTCP(pkg); } } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; StringBuilder stringBuilder = new StringBuilder(); eMessageType eMessageType = eMessageType.Normal; string translateId = "UserBuyItemHandler.Success"; GSPacketIn gSPacketIn = new GSPacketIn(44); List <ItemInfo> list = new List <ItemInfo>(); List <bool> list2 = new List <bool>(); List <int> list3 = new List <int>(); StringBuilder stringBuilder2 = new StringBuilder(); bool flag = false; ConsortiaInfo consortiaInfo = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID); int num6 = packet.ReadInt(); for (int i = 0; i < num6; i++) { packet.ReadInt(); int iD = packet.ReadInt(); int num7 = packet.ReadInt(); string text = packet.ReadString(); bool item = packet.ReadBoolean(); string text2 = packet.ReadString(); int item2 = packet.ReadInt(); packet.ReadBoolean(); ShopItemInfo shopItemInfoById = ShopMgr.GetShopItemInfoById(iD); if (shopItemInfoById == null) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.FailByPermission", new object[0])); return(1); } if (!ShopMgr.CanBuy(shopItemInfoById.ShopID, (consortiaInfo == null) ? 1 : consortiaInfo.ShopLevel, ref flag, client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.Riches)) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.FailByPermission", new object[0])); return(1); } ItemTemplateInfo goods = ItemMgr.FindItemTemplate(shopItemInfoById.TemplateID); ItemInfo itemInfo = ItemInfo.CreateFromTemplate(goods, 1, 102); if (shopItemInfoById.BuyType == 0) { if (1 == num7) { itemInfo.ValidDate = shopItemInfoById.AUnit; } if (2 == num7) { itemInfo.ValidDate = shopItemInfoById.BUnit; } if (3 == num7) { itemInfo.ValidDate = shopItemInfoById.CUnit; } } else { if (1 == num7) { itemInfo.Count = shopItemInfoById.AUnit; } if (2 == num7) { itemInfo.Count = shopItemInfoById.BUnit; } if (3 == num7) { itemInfo.Count = shopItemInfoById.CUnit; } } if (itemInfo != null || shopItemInfoById != null) { itemInfo.Color = ((text == null) ? "" : text); itemInfo.Skin = ((text2 == null) ? "" : text2); if (flag) { itemInfo.IsBinds = true; } else { itemInfo.IsBinds = Convert.ToBoolean(shopItemInfoById.IsBind); } stringBuilder2.Append(num7); stringBuilder2.Append(","); list.Add(itemInfo); list2.Add(item); list3.Add(item2); ItemInfo.SetItemType(shopItemInfoById, num7, ref num, ref num2, ref num3, ref num4, ref num5); } } int val = packet.ReadInt(); if (list.Count == 0) { return(1); } if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); return(1); } bool flag2 = false; int num8 = 0; if (num <= client.Player.PlayerCharacter.Gold && num2 <= client.Player.PlayerCharacter.Money && num3 <= client.Player.PlayerCharacter.Offer && num4 <= client.Player.PlayerCharacter.GiftToken) { num8++; client.Player.AddExpVip(num2); client.Player.RemoveMoney(num2); client.Player.RemoveGold(num); client.Player.RemoveOffer(num3); client.Player.RemoveGiftToken(num4); string text3 = ""; int num9 = 0; MailInfo mailInfo = new MailInfo(); StringBuilder stringBuilder3 = new StringBuilder(); stringBuilder3.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark", new object[0])); for (int j = 0; j < list.Count; j++) { text3 += ((text3 == "") ? list[j].TemplateID.ToString() : ("," + list[j].TemplateID.ToString())); if (!client.Player.AddTemplate(list[j], list[j].Template.BagType, list[j].Count)) { flag2 = true; using (PlayerBussiness playerBussiness = new PlayerBussiness()) { list[j].UserID = 0; playerBussiness.AddGoods(list[j]); num9++; stringBuilder3.Append(num9); stringBuilder3.Append("、"); stringBuilder3.Append(list[j].Template.Name); stringBuilder3.Append("x"); stringBuilder3.Append(list[j].Count); stringBuilder3.Append(";"); switch (num9) { case 1: mailInfo.Annex1 = list[j].ItemID.ToString(); mailInfo.Annex1Name = list[j].Template.Name; break; case 2: mailInfo.Annex2 = list[j].ItemID.ToString(); mailInfo.Annex2Name = list[j].Template.Name; break; case 3: mailInfo.Annex3 = list[j].ItemID.ToString(); mailInfo.Annex3Name = list[j].Template.Name; break; case 4: mailInfo.Annex4 = list[j].ItemID.ToString(); mailInfo.Annex4Name = list[j].Template.Name; break; case 5: mailInfo.Annex5 = list[j].ItemID.ToString(); mailInfo.Annex5Name = list[j].Template.Name; break; } if (num9 == 5) { num9 = 0; mailInfo.AnnexRemark = stringBuilder3.ToString(); stringBuilder3.Remove(0, stringBuilder3.Length); stringBuilder3.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark", new object[0])); mailInfo.Content = LanguageMgr.GetTranslation("UserBuyItemHandler.Title", new object[0]) + mailInfo.Annex1Name + "]"; mailInfo.Gold = 0; mailInfo.Money = 0; mailInfo.Receiver = client.Player.PlayerCharacter.NickName; mailInfo.ReceiverID = client.Player.PlayerCharacter.ID; mailInfo.Sender = mailInfo.Receiver; mailInfo.SenderID = mailInfo.ReceiverID; mailInfo.Title = mailInfo.Content; mailInfo.Type = 8; playerBussiness.SendMail(mailInfo); eMessageType = eMessageType.ERROR; translateId = "UserBuyItemHandler.Mail"; mailInfo.Revert(); } } } } if (num9 > 0) { using (PlayerBussiness playerBussiness2 = new PlayerBussiness()) { mailInfo.AnnexRemark = stringBuilder3.ToString(); mailInfo.Content = LanguageMgr.GetTranslation("UserBuyItemHandler.Title", new object[0]) + mailInfo.Annex1Name + "]"; mailInfo.Gold = 0; mailInfo.Money = 0; mailInfo.Receiver = client.Player.PlayerCharacter.NickName; mailInfo.ReceiverID = client.Player.PlayerCharacter.ID; mailInfo.Sender = mailInfo.Receiver; mailInfo.SenderID = mailInfo.ReceiverID; mailInfo.Title = mailInfo.Content; mailInfo.Type = 8; playerBussiness2.SendMail(mailInfo); eMessageType = eMessageType.ERROR; translateId = "UserBuyItemHandler.Mail"; } } if (eMessageType == eMessageType.ERROR) { client.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Receiver); } client.Player.OnPaid(num2, num, num3, num4, num5, stringBuilder.ToString()); LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Buy, client.Player.PlayerCharacter.ID, num2, client.Player.PlayerCharacter.Money, num, num4, num3, num5, "牌子编号", text3, stringBuilder2.ToString()); } else { if (num2 > client.Player.PlayerCharacter.Money) { translateId = "UserBuyItemHandler.NoMoney"; } if (num > client.Player.PlayerCharacter.Gold) { translateId = "UserBuyItemHandler.NoGold"; } if (num3 > client.Player.PlayerCharacter.Offer) { translateId = "UserBuyItemHandler.NoOffer"; } if (num4 > client.Player.PlayerCharacter.GiftToken) { translateId = "UserBuyItemHandler.GiftToken"; } if (num5 > client.Player.PlayerCharacter.medal) { translateId = "UserBuyItemHandler.Medal"; } eMessageType = eMessageType.ERROR; } int val2 = 0; if (num8 == num6) { val2 = (flag2 ? 2 : 1); } client.Player.MainBag.SaveToDatabase(); client.Player.PropBag.SaveToDatabase(); gSPacketIn.WriteInt(val2); gSPacketIn.WriteInt(val); client.Out.SendMessage(eMessageType, LanguageMgr.GetTranslation(translateId, new object[0])); client.Out.SendTCP(gSPacketIn); return(0); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int bagType = packet.ReadInt(); int place = packet.ReadInt(); int goodsID = packet.ReadInt(); int type = packet.ReadInt(); bool ignoreBagLock = packet.ReadBoolean(); int result; if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked && !ignoreBagLock) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); result = 0; } else { ItemInfo item; string msg; if (place == -1) { int gold = 0; int money = 0; int offer = 0; int gifttoken = 0; ShopItemInfo info = ShopMgr.GetShopItemInfoById(goodsID); if (null == info) { result = 1; return(result); } List <int> payGoods = ShopMgr.GetShopItemBuyConditions(info, type, ref gold, ref money, ref offer, ref gifttoken); if (offer > 0 || payGoods.Count > 0) { result = 1; return(result); } item = ShopMgr.CreateItem(info, 102, type, "", "", true); if (item == null) { result = 1; return(result); } player.RemoveMoney(money, LogMoneyType.Shop, LogMoneyType.Shop_Card); player.RemoveGold(gold); player.RemoveOffer(offer); player.RemoveGiftToken(gifttoken); //LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Card, player.PlayerCharacter.ID, money, gold, 0, 0, "", item.TemplateID, 1, item.Count); msg = "CardUseHandler.Success"; } else { item = player.PropBag.GetItemAt(place); msg = "CardUseHandler.Success"; } if (item != null) { string msg2 = string.Empty; if (item.Template.Property1 != 21) { AbstractBuffer buffer = BufferList.CreateBuffer(item.Template, item.ValidDate); if (buffer != null) { buffer.Start(player); if (place != -1) { player.OnUsingItem(item.TemplateID); player.PropBag.RemoveItem(item, eItemRemoveType.Use); } } player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(msg, new object[0])); } else { if (item.IsValidItem()) { player.AddGpDirect(item.Template.Property2); player.OnUsingItem(item.TemplateID); player.RemoveItem(item, eItemRemoveType.Use); msg2 = "GPDanUser.Success"; } player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(msg2, new object[] { item.Template.Property2 })); } } result = 0; } return(result); }
public int HandlePacket(GameClient client, GSPacketIn packet) { eMessageType eMsg = eMessageType.Normal; string msg = "UserChangeItemColorHandler.Success"; int Card_bagType = packet.ReadInt(); int Card_place = packet.ReadInt(); int bagType = packet.ReadInt(); int place = packet.ReadInt(); string color = packet.ReadString(); string skin = packet.ReadString(); int templateID = packet.ReadInt(); ItemInfo item = client.Player.MainBag.GetItemAt(place); ItemInfo card = client.Player.PropBag.GetItemAt(Card_place); if (item != null) { client.Player.BeginChanges(); try { bool changed = false; if (card != null && card.IsValidItem()) { client.Player.PropBag.RemoveItem(card); changed = true; } else { ItemTemplateInfo template = ItemMgr.FindItemTemplate(templateID); List <ShopItemInfo> Template = ShopMgr.FindShopbyTemplatID(templateID); int Money = 0; for (int i = 0; i < Template.Count; i++) { if (Template[i].APrice1 == -1 && Template[i].AValue1 != 0) { Money = Template[i].AValue1; } } if (Money <= client.Player.PlayerCharacter.Money) { client.Player.RemoveMoney(Money); LogMgr.LogMoneyAdd(LogMoneyType.Item, LogMoneyType.Item_Color, client.Player.PlayerCharacter.ID, Money, client.Player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", ""); // client.Player.RemoveGold(template.Gold, GoldRemoveType.Other); changed = true; } } if (changed) { item.Color = color == null ? "" : color; item.Skin = skin == null ? "" : skin; client.Player.MainBag.UpdateItem(item); } } finally { client.Player.CommitChanges(); } } client.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg)); return(0); }
public void HandleReload(GSPacketIn packet) { eReloadType type = (eReloadType)packet.ReadInt(); bool result = false; switch (type) { case eReloadType.ball: result = BallMgr.ReLoad(); break; case eReloadType.fusion: result = FusionMgr.ReLoad(); break; case eReloadType.item: result = ItemMgr.ReLoad(); break; case eReloadType.map: result = MapMgr.ReLoadMap(); break; case eReloadType.mapserver: result = MapMgr.ReLoadMapServer(); break; case eReloadType.quest: result = QuestMgr.ReLoad(); break; case eReloadType.server: GameServer.Instance.Configuration.Refresh(); break; case eReloadType.rate: result = RateMgr.ReLoad(); break; case eReloadType.fight: result = FightRateMgr.ReLoad(); break; case eReloadType.dailyaward: result = AwardMgr.ReLoad(); break; case eReloadType.language: result = LanguageMgr.Reload(""); break; default: break; case eReloadType.shop: result = ShopMgr.ReLoad(); break; case eReloadType.consortia: result = ConsortiaMgr.ReLoad(); break; //case eReloadType.prop: // result = PropItemMgr.Reload(); // break; } packet.WriteInt(GameServer.Instance.Configuration.ServerID); packet.WriteBoolean(result); SendTCP(packet); }
void Awake() { AccessScript = GameObject.FindObjectOfType <ShopMgr> (); //holdGold = PlayerPrefs.GetInt ("Gold", 0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; int iD = packet.ReadInt(); int num6 = 1; ShopItemInfo shopItemInfoById = ShopMgr.GetShopItemInfoById(iD); if (shopItemInfoById == null) { return(0); } ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(shopItemInfoById.TemplateID); ItemInfo.SetItemType(shopItemInfoById, num6, ref num, ref num2, ref num3, ref num4, ref num5); if (itemTemplateInfo.CategoryID == 10) { PlayerInfo playerCharacter = client.Player.PlayerCharacter; if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked && (num2 > 0 || num3 > 0 || num4 > 0 || num5 > 0)) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); return(0); } if (num <= playerCharacter.Gold && num2 <= ((playerCharacter.Money < 0) ? 0 : playerCharacter.Money) && num3 <= playerCharacter.Offer && num4 <= playerCharacter.GiftToken && num5 <= playerCharacter.medal) { ItemInfo itemInfo = ItemInfo.CreateFromTemplate(itemTemplateInfo, 1, 102); if (shopItemInfoById.BuyType == 0) { if (1 == num6) { itemInfo.ValidDate = shopItemInfoById.AUnit; } if (2 == num6) { itemInfo.ValidDate = shopItemInfoById.BUnit; } if (3 == num6) { itemInfo.ValidDate = shopItemInfoById.CUnit; } } else { if (1 == num6) { itemInfo.Count = shopItemInfoById.AUnit; } if (2 == num6) { itemInfo.Count = shopItemInfoById.BUnit; } if (3 == num6) { itemInfo.Count = shopItemInfoById.CUnit; } } if (client.Player.FightBag.AddItem(itemInfo, 0)) { client.Player.RemoveGold(num); client.Player.RemoveMoney(num2); client.Player.RemoveOffer(num3); client.Player.RemoveGiftToken(num4); client.Player.RemoveMedal(num5); LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Buy, client.Player.PlayerCharacter.ID, num2, client.Player.PlayerCharacter.Money, num, 0, 0, 0, "牌子编号", itemTemplateInfo.TemplateID.ToString(), num6.ToString()); } } else { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("PropBuyHandler.NoMoney", new object[0])); } } return(0); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int gold = 0; int money = 0; int offer = 0; int gifttoken = 0; StringBuilder payGoods = new StringBuilder(); int GoodsID = packet.ReadInt(); int type = 1; ShopItemInfo shopItem = ShopMgr.GetShopItemInfoById(GoodsID); int result2; if (shopItem == null) { result2 = 1; } else { List <int> needitemsinfo = ShopMgr.GetShopItemBuyConditions(shopItem, type, ref gold, ref money, ref offer, ref gifttoken); ItemInfo prop = ShopMgr.CreateItem(shopItem, 102, 1, "", "", false); if (prop == null) { result2 = 1; } else { if (prop.Template.CategoryID == 10) { PlayerInfo pi = player.PlayerCharacter; if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked && (money > 0 || offer > 0 || gifttoken > 0 || GoodsID == 11408)) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); result2 = 1; return(result2); } int icount = player.MainBag.GetItems().Count; bool result = true; for (int i = 0; i < needitemsinfo.Count; i += 2) { if (player.GetItemCount(needitemsinfo[i]) < needitemsinfo[i + 1]) { result = false; } } if (!result) { eMessageType eMsg = eMessageType.ERROR; string msg = "UserBuyItemHandler.NoBuyItem"; player.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg, new object[0])); result2 = 1; return(result2); } if (gold <= pi.Gold && money <= ((pi.Money < 0) ? 0 : pi.Money) && offer <= pi.Offer && gifttoken <= pi.GiftToken) { if (player.FightBag.AddItem(prop, 0)) { player.RemoveGold(gold); player.RemoveMoney(money, LogMoneyType.Shop, LogMoneyType.Shop_Buy); player.RemoveOffer(offer); player.RemoveGiftToken(gifttoken); for (int i = 0; i < needitemsinfo.Count; i += 2) { player.RemoveTemplate(needitemsinfo[i], needitemsinfo[i + 1], eItemRemoveType.Shopping); payGoods.Append(needitemsinfo[i].ToString() + ":"); } //LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Buy, player.PlayerCharacter.ID, money, gold, gifttoken, offer, "", prop.TemplateID, 3, prop.Count); } } else { player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("PropBuyHandler.NoMoney", new object[0])); } } result2 = 0; } } return(result2); }
public override bool Start() { if (m_isRunning) { return(false); } try { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Thread.CurrentThread.Priority = ThreadPriority.Normal; GameProperties.Refresh(); if (!InitComponent(RecompileScripts(), "Recompile Scripts")) { return(false); } if (!InitComponent(StartScriptComponents(), "Script components")) { return(false); } if (!InitComponent((GameProperties.EDITION == Edition), "Edition:" + Edition)) { return(false); } if (!InitComponent(InitSocket(IPAddress.Parse(Configuration.Ip), Configuration.Port), "InitSocket Port:" + Configuration.Port)) { return(false); } if (!InitComponent(AllocatePacketBuffers(), "AllocatePacketBuffers()")) { return(false); } if (!InitComponent(LogMgr.Setup(Configuration.GAME_TYPE, Configuration.ServerID, Configuration.AreaID), "LogMgr Init")) { return(false); } if (!InitComponent(WorldMgr.Init(), "WorldMgr Init")) { return(false); } if (!InitComponent(MapMgr.Init(), "MapMgr Init")) { return(false); } if (!InitComponent(ItemMgr.Init(), "ItemMgr Init")) { return(false); } if (!InitComponent(ItemBoxMgr.Init(), "ItemBox Init")) { return(false); } if (!InitComponent(BallMgr.Init(), "BallMgr Init")) { return(false); } if (!InitComponent(BallConfigMgr.Init(), "BallConfigMgr Init")) { return(false); } if (!InitComponent(FusionMgr.Init(), "FusionMgr Init")) { return(false); } if (!InitComponent(AwardMgr.Init(), "AwardMgr Init")) { return(false); } if (!InitComponent(NPCInfoMgr.Init(), "NPCInfoMgr Init")) { return(false); } if (!InitComponent(MissionInfoMgr.Init(), "MissionInfoMgr Init")) { return(false); } if (!InitComponent(PveInfoMgr.Init(), "PveInfoMgr Init")) { return(false); } if (!InitComponent(DropMgr.Init(), "Drop Init")) { return(false); } if (!InitComponent(FightRateMgr.Init(), "FightRateMgr Init")) { return(false); } if (!InitComponent(ConsortiaLevelMgr.Init(), "ConsortiaLevelMgr Init")) { return(false); } if (!InitComponent(RefineryMgr.Init(), "RefineryMgr Init")) { return(false); } if (!InitComponent(StrengthenMgr.Init(), "StrengthenMgr Init")) { return(false); } if (!InitComponent(PropItemMgr.Init(), "PropItemMgr Init")) { return(false); } if (!InitComponent(ShopMgr.Init(), "ShopMgr Init")) { return(false); } if (!InitComponent(QuestMgr.Init(), "QuestMgr Init")) { return(false); } if (!InitComponent(RoomMgr.Setup(Configuration.MaxRoomCount), "RoomMgr.Setup")) { return(false); } if (!InitComponent(GameMgr.Setup(Configuration.ServerID, GameProperties.BOX_APPEAR_CONDITION), "GameMgr.Start()")) { return(false); } if (!InitComponent(ConsortiaMgr.Init(), "ConsortiaMgr Init")) { return(false); } if (!InitComponent(LanguageMgr.Setup(@""), "LanguageMgr Init")) { return(false); } if (!InitComponent(RateMgr.Init(Configuration), "ExperienceRateMgr Init")) { return(false); } if (!InitComponent(MacroDropMgr.Init(), "MacroDropMgr Init")) { return(false); } if (!InitComponent(BattleMgr.Setup(), "BattleMgr Setup")) { return(false); } if (!InitComponent(InitGlobalTimer(), "Init Global Timers")) { return(false); } if (!InitComponent(MarryRoomMgr.Init(), "MarryRoomMgr Init")) { return(false); } if (!InitComponent(LogMgr.Setup(1, 4, 4), "LogMgr Setup")) { return(false); } GameEventMgr.Notify(ScriptEvent.Loaded); if (!InitComponent(InitLoginServer(), "Login To CenterServer")) { return(false); } RoomMgr.Start(); GameMgr.Start(); BattleMgr.Start(); MacroDropMgr.Start(); if (!InitComponent(base.Start(), "base.Start()")) { return(false); } GameEventMgr.Notify(GameServerEvent.Started, this); GC.Collect(GC.MaxGeneration); if (log.IsInfoEnabled) { log.Info("GameServer is now open for connections!"); } m_isRunning = true; return(true); } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("Failed to start the server", e); } return(false); } }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.IsMarried) { return(1); } if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); return(1); } int num = packet.ReadInt(); string loveProclamation = packet.ReadString(); packet.ReadBoolean(); bool flag = true; using (PlayerBussiness playerBussiness = new PlayerBussiness()) { PlayerInfo userSingleByUserID = playerBussiness.GetUserSingleByUserID(num); if (userSingleByUserID == null || userSingleByUserID.Sex == client.Player.PlayerCharacter.Sex) { int result = 1; return(result); } if (userSingleByUserID.IsMarried) { client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg2", new object[0])); int result = 1; return(result); } ItemInfo itemByTemplateID = client.Player.PropBag.GetItemByTemplateID(0, 11103); if (itemByTemplateID == null) { ShopItemInfo shopItemInfo = ShopMgr.FindShopbyTemplatID(11103).FirstOrDefault <ShopItemInfo>(); if (shopItemInfo == null) { client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg6", new object[0])); int result = 1; return(result); } if (client.Player.PlayerCharacter.Money < shopItemInfo.AValue1) { client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg1", new object[0])); int result = 1; return(result); } flag = false; } MarryApplyInfo marryApplyInfo = new MarryApplyInfo(); marryApplyInfo.UserID = num; marryApplyInfo.ApplyUserID = client.Player.PlayerCharacter.ID; marryApplyInfo.ApplyUserName = client.Player.PlayerCharacter.NickName; marryApplyInfo.ApplyType = 1; marryApplyInfo.LoveProclamation = loveProclamation; marryApplyInfo.ApplyResult = false; int iD = 0; if (playerBussiness.SavePlayerMarryNotice(marryApplyInfo, 0, ref iD)) { if (flag) { client.Player.RemoveItem(itemByTemplateID); } else { ShopItemInfo shopItemInfo2 = ShopMgr.FindShopbyTemplatID(11103).FirstOrDefault <ShopItemInfo>(); client.Player.RemoveMoney(shopItemInfo2.AValue1); LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Spark, client.Player.PlayerCharacter.ID, shopItemInfo2.AValue1, client.Player.PlayerCharacter.Money, 0, 0, 0, 0, "", shopItemInfo2.TemplateID.ToString(), "1"); } client.Player.Out.SendPlayerMarryApply(client.Player, client.Player.PlayerCharacter.ID, client.Player.PlayerCharacter.NickName, loveProclamation, iD); GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(num); string arg_2BA_0 = userSingleByUserID.NickName; client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg3", new object[0])); } } return(0); }