public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.ConsortiaID == 0) { return(0); } int bagType = packet.ReadByte(); int place = packet.ReadInt(); bool result = false; string msg = "ConsortiaUpGradeHandler.Failed"; using (ConsortiaBussiness db = new ConsortiaBussiness()) { ConsortiaInfo info = db.GetConsortiaSingle(client.Player.PlayerCharacter.ConsortiaID); if (info == null) { msg = "ConsortiaUpGradeHandler.NoConsortia"; } else { ConsortiaLevelInfo levelInfo = ConsortiaLevelMgr.FindConsortiaLevelInfo(info.Level + 1); //ItemTemplateInfo temp = ItemMgr.GetSingleGoods(levelInfo.NeedItem); if (levelInfo == null) { msg = "ConsortiaUpGradeHandler.NoUpGrade"; } //else if (levelInfo.NeedItem != 0 && client.Player.GetAllItemCount(levelInfo.NeedItem) < 1) //{ // msg = "ConsortiaUpGradeHandler.NoItem"; //} else if (levelInfo.NeedGold > client.Player.PlayerCharacter.Gold) { msg = "ConsortiaUpGradeHandler.NoGold"; } else { using (ConsortiaBussiness cb = new ConsortiaBussiness()) { if (cb.UpGradeConsortia(client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.ID, ref msg)) { info.Level++; client.Player.RemoveGold(levelInfo.NeedGold); // client.Player.RemoveItemCount(levelInfo.NeedItem, 1); GameServer.Instance.LoginServer.SendConsortiaUpGrade(info); msg = "ConsortiaUpGradeHandler.Success"; result = true; } } } } if (info.Level >= 5) { string msg1 = LanguageMgr.GetTranslation("ConsortiaUpGradeHandler.Notice", info.ConsortiaName, info.Level); GSPacketIn pkg = new GSPacketIn((byte)ePackageType.SYS_NOTICE); pkg.WriteInt(2); pkg.WriteString(msg1); GameServer.Instance.LoginServer.SendPacket(pkg); GamePlayer[] players = Game.Server.Managers.WorldMgr.GetAllPlayers(); foreach (GamePlayer p in players) { if (p != client.Player && p.PlayerCharacter.ConsortiaID != client.Player.PlayerCharacter.ConsortiaID) { p.Out.SendTCP(pkg); } } } } packet.WriteBoolean(result); packet.WriteString(LanguageMgr.GetTranslation(msg)); client.Out.SendTCP(packet); return(1); }
public int HandlePacket(GameClient client, GSPacketIn packet) { var consortiaCmd = packet.ReadInt(); bool result = false; string msg = "Packet Error!"; ConsortiaLevelInfo levelInfo = null; GamePlayer[] players = WorldMgr.GetAllPlayers(); switch (consortiaCmd) { case (int)ConsortiaPackageType.CONSORTIA_TRYIN: HandleCONSORTIA_TRYIN(packet); break; case (int)ConsortiaPackageType.CONSORTIA_CREATE: //Create Guild { if (client.Player.PlayerCharacter.ConsortiaID != 0) return 0; levelInfo = ConsortiaLevelMgr.FindConsortiaLevelInfo(1); string name = packet.ReadString(); //if (string.IsNullOrEmpty(name) || System.Text.Encoding.Default.GetByteCount(name) > 12) //{ // client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaCreateHandler.Long")); // return 1; //} //result = false; int id = 0; int mustGold = levelInfo.NeedGold; int mustLevel = 5; msg = "ConsortiaCreateHandler.Failed"; ConsortiaDutyInfo dutyInfo = new ConsortiaDutyInfo(); if (!string.IsNullOrEmpty(name) && client.Player.PlayerCharacter.Gold >= mustGold && client.Player.PlayerCharacter.Grade >= mustLevel) { using (ConsortiaBussiness db = new ConsortiaBussiness()) { ConsortiaInfo info = new ConsortiaInfo(); info.BuildDate = DateTime.Now; info.CelebCount = 0; info.ChairmanID = client.Player.PlayerCharacter.ID; info.ChairmanName = client.Player.PlayerCharacter.NickName; info.ConsortiaName = name; info.CreatorID = info.ChairmanID; info.CreatorName = info.ChairmanName; info.Description = ""; info.Honor = 0; info.IP = ""; info.IsExist = true; info.Level = levelInfo.Level; info.MaxCount = levelInfo.Count; info.Riches = levelInfo.Riches; info.Placard = ""; info.Port = 0; info.Repute = 0; info.Count = 1; if (db.AddConsortia(info, ref msg, ref dutyInfo)) { client.Player.PlayerCharacter.ConsortiaID = info.ConsortiaID; client.Player.PlayerCharacter.ConsortiaName = info.ConsortiaName; client.Player.PlayerCharacter.DutyLevel = dutyInfo.Level; client.Player.PlayerCharacter.DutyName = dutyInfo.DutyName; client.Player.PlayerCharacter.Right = dutyInfo.Right; client.Player.PlayerCharacter.ConsortiaLevel = levelInfo.Level; client.Player.RemoveGold(mustGold); msg = "ConsortiaCreateHandler.Success"; result = true; id = info.ConsortiaID; GameServer.Instance.LoginServer.SendConsortiaCreate(id, client.Player.PlayerCharacter.Offer, info.ConsortiaName); } else { client.Player.SendMessage("db.AddConsortia Error "); } } } //Send package create Guild client.Out.SendConsortiaCreate(name, result, id, name, LanguageMgr.GetTranslation(msg), dutyInfo.Level, dutyInfo.DutyName, dutyInfo.Right, client.Player.PlayerCharacter.ID); } break; case (int)ConsortiaPackageType.CONSORTIA_DISBAND: HandleCONSORTIA_DISBAND(packet); break; case (int)ConsortiaPackageType.CONSORTIA_RENEGADE: HandleCONSORTIA_RENEGADE(packet); break; case (int)ConsortiaPackageType.CONSORTIA_TRYIN_PASS: HandleCONSORTIA_TRYIN_PASS(packet); break; case (int)ConsortiaPackageType.CONSORTIA_TRYIN_DEL: HandleCONSORTIA_TRYIN_DEL(packet); break; case (int)ConsortiaPackageType.CONSORTIA_RICHES_OFFER: break; case (int)ConsortiaPackageType.CONSORTIA_APPLY_STATE: break; case (int)ConsortiaPackageType.CONSORTIA_DUTY_DELETE: break; case (int)ConsortiaPackageType.CONSORTIA_DUTY_UPDATE: break; case (int)ConsortiaPackageType.CONSORTIA_INVITE: break; case (int)ConsortiaPackageType.CONSORTIA_INVITE_PASS: break; case (int)ConsortiaPackageType.CONSORTIA_INVITE_DELETE: break; case (int)ConsortiaPackageType.CONSORTIA_DESCRIPTION_UPDATE: break; case (int)ConsortiaPackageType.CONSORTIA_PLACARD_UPDATE: break; case (int)ConsortiaPackageType.CONSORTIA_BANCHAT_UPDATE: break; case (int)ConsortiaPackageType.CONSORTIA_USER_REMARK_UPDATE: break; case (int)ConsortiaPackageType.CONSORTIA_USER_GRADE_UPDATE: break; case (int)ConsortiaPackageType.CONSORTIA_CHAIRMAN_CHAHGE: break; case (int)ConsortiaPackageType.CONSORTIA_CHAT: break; case (int)ConsortiaPackageType.CONSORTIA_LEVEL_UP: break; case (int)ConsortiaPackageType.CONSORTIA_TASK_RELEASE: break; case (int)ConsortiaPackageType.DONATE: break; case (int)ConsortiaPackageType.CONSORTIA_EQUIP_CONTROL: break; case (int)ConsortiaPackageType.POLL_CANDIDATE: break; case (int)ConsortiaPackageType.SKILL_SOCKET: break; case (int)ConsortiaPackageType.CONSORTION_MAIL: break; case (int)ConsortiaPackageType.BUY_BADGE: break; } return 0; }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int result2; if (player.PlayerCharacter.ConsortiaID != 0) { result2 = 0; } else { ConsortiaLevelInfo levelInfo = ConsortiaLevelMgr.FindConsortiaLevelInfo(1); string name = packet.ReadString(); if (string.IsNullOrEmpty(name) || Encoding.Default.GetByteCount(name) > 12) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaCreateHandler.Long", new object[0])); result2 = 1; } else { bool result = false; int id = 0; //int mustGold = levelInfo.NeedGold; //int mustLevel = 5; string msg = "ConsortiaCreateHandler.Failed"; ConsortiaDutyInfo dutyInfo = new ConsortiaDutyInfo(); if (!string.IsNullOrEmpty(name) && player.PlayerCharacter.Money >= 1000) { using (ConsortiaBussiness db = new ConsortiaBussiness()) { ConsortiaInfo info = new ConsortiaInfo(); info.BuildDate = DateTime.Now; info.CelebCount = 0; info.ChairmanID = player.PlayerCharacter.ID; info.ChairmanName = player.PlayerCharacter.NickName; info.ConsortiaName = name; info.CreatorID = info.ChairmanID; info.CreatorName = info.ChairmanName; info.Description = ""; info.Honor = 0; info.IP = ""; info.IsExist = true; info.Level = levelInfo.Level; info.MaxCount = levelInfo.Count; info.Riches = levelInfo.Riches; info.Placard = ""; info.Port = 0; info.Repute = 0; info.Count = 1; if (db.AddConsortia(info, ref msg, ref dutyInfo)) { player.PlayerCharacter.ConsortiaID = info.ConsortiaID; player.PlayerCharacter.ConsortiaName = info.ConsortiaName; player.PlayerCharacter.DutyLevel = dutyInfo.Level; player.PlayerCharacter.DutyName = dutyInfo.DutyName; player.PlayerCharacter.Right = dutyInfo.Right; player.PlayerCharacter.ConsortiaLevel = levelInfo.Level; player.RemoveGold(1000); msg = "ConsortiaCreateHandler.Success"; result = true; id = info.ConsortiaID; GameServer.Instance.LoginServer.SendConsortiaCreate(id, player.PlayerCharacter.Offer, info.ChairmanName); } } } packet.WriteBoolean(result); packet.WriteInt(id); packet.WriteString("cName");//UnKnown packet.WriteString(LanguageMgr.GetTranslation(msg, new object[0])); packet.WriteInt(dutyInfo.Level); packet.WriteString((dutyInfo.DutyName == null) ? "" : dutyInfo.DutyName); packet.WriteInt(dutyInfo.Right); player.Out.SendTCP(packet); result2 = 0; } } return(result2); }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.ConsortiaID != 0) { return(0); } ConsortiaLevelInfo levelInfo = ConsortiaLevelMgr.FindConsortiaLevelInfo(1); string name = packet.ReadString(); if (string.IsNullOrEmpty(name) || System.Text.Encoding.Default.GetByteCount(name) > 12) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaCreateHandler.Long")); return(1); } bool result = false; int id = 0; int mustGold = levelInfo.NeedGold; int mustLevel = 5; string msg = "ConsortiaCreateHandler.Failed"; ConsortiaDutyInfo dutyInfo = new ConsortiaDutyInfo(); if (!string.IsNullOrEmpty(name) && client.Player.PlayerCharacter.Gold >= mustGold && client.Player.PlayerCharacter.Grade >= mustLevel) { using (ConsortiaBussiness db = new ConsortiaBussiness()) { ConsortiaInfo info = new ConsortiaInfo(); info.BuildDate = DateTime.Now; info.CelebCount = 0; info.ChairmanID = client.Player.PlayerCharacter.ID; info.ChairmanName = client.Player.PlayerCharacter.NickName; info.ConsortiaName = name; info.CreatorID = info.ChairmanID; info.CreatorName = info.ChairmanName; info.Description = ""; info.Honor = 0; info.IP = ""; info.IsExist = true; info.Level = levelInfo.Level; info.MaxCount = levelInfo.Count; info.Riches = levelInfo.Riches; info.Placard = ""; info.Port = 0; info.Repute = 0; info.Count = 1; if (db.AddConsortia(info, ref msg, ref dutyInfo)) { client.Player.PlayerCharacter.ConsortiaID = info.ConsortiaID; client.Player.PlayerCharacter.ConsortiaName = info.ConsortiaName; client.Player.PlayerCharacter.DutyLevel = dutyInfo.Level; client.Player.PlayerCharacter.DutyName = dutyInfo.DutyName; client.Player.PlayerCharacter.Right = dutyInfo.Right; client.Player.PlayerCharacter.ConsortiaLevel = levelInfo.Level; client.Player.RemoveGold(mustGold); msg = "ConsortiaCreateHandler.Success"; result = true; id = info.ConsortiaID; GameServer.Instance.LoginServer.SendConsortiaCreate(id, client.Player.PlayerCharacter.Offer, info.ConsortiaName); } } } packet.WriteBoolean(result); packet.WriteInt(id); packet.WriteString(name); packet.WriteString(LanguageMgr.GetTranslation(msg)); packet.WriteInt(dutyInfo.Level); packet.WriteString(dutyInfo.DutyName == null ? "" : dutyInfo.DutyName); packet.WriteInt(dutyInfo.Right); client.Out.SendTCP(packet); //client.Out.SendMessage(eMessageType.Normal, msg); return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int result2; if (client.Player.PlayerCharacter.ConsortiaID == 0) { result2 = 0; } else { int bagType = (int)packet.ReadByte(); int place = packet.ReadInt(); bool result = false; string msg = "ConsortiaUpGradeHandler.Failed"; using (ConsortiaBussiness db = new ConsortiaBussiness()) { ConsortiaInfo info = db.GetConsortiaSingle(client.Player.PlayerCharacter.ConsortiaID); if (info == null) { msg = "ConsortiaUpGradeHandler.NoConsortia"; } else { ConsortiaLevelInfo levelInfo = ConsortiaLevelMgr.FindConsortiaLevelInfo(info.Level + 1); if (levelInfo == null) { msg = "ConsortiaUpGradeHandler.NoUpGrade"; } else { if (levelInfo.NeedGold > client.Player.PlayerCharacter.Gold) { msg = "ConsortiaUpGradeHandler.NoGold"; } else { using (ConsortiaBussiness cb = new ConsortiaBussiness()) { if (cb.UpGradeConsortia(client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.ID, ref msg)) { info.Level++; client.Player.RemoveGold(levelInfo.NeedGold); GameServer.Instance.LoginServer.SendConsortiaUpGrade(info); msg = "ConsortiaUpGradeHandler.Success"; result = true; } } } } } if (info.Level >= 5 && info.Level <= 10) { string msg2 = LanguageMgr.GetTranslation("ConsortiaUpGradeHandler.Notice", new object[] { info.ConsortiaName, info.Level }); GSPacketIn pkg = new GSPacketIn(10); pkg.WriteInt(2); pkg.WriteString(msg2); 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 != client.Player && p.PlayerCharacter.ConsortiaID != client.Player.PlayerCharacter.ConsortiaID) { p.Out.SendTCP(pkg); } } } } packet.WriteBoolean(result); packet.WriteString(LanguageMgr.GetTranslation(msg, new object[0])); client.Out.SendTCP(packet); result2 = 1; } return(result2); }