///////////////////////////////////////////////////////////////////////////// // Handle new premium tickets ///////////////////////////////////////////////////////////////////////////// void HandlePremiumType(int ItemID) { //First we check if the user allready has a ticket active or not. if (!Character.Premium.Active) { //Set default values that we will use for the ticket. DateTime StartTime = DateTime.Now; double Timespan = StartTime.Minute; byte NewRate = 0; //Check which ticket the user has selected. if (Data.ItemBase[ItemID].Ticket == Global.item_database.Tickets.GOLD_1_DAY) { } else if (Data.ItemBase[ItemID].Ticket == Global.item_database.Tickets.GOLD_4_WEEKS) { NewRate = 2; } //Send visual packet for the icon } else { //Send message to user that an active ticket excists. client.Send(Packet.IngameMessages(Systems.SERVER_TICKET, IngameMessages.UIIT_MSG_PREMIUM_NOT_USE)); } }
///////////////////////////////////////////////////////////////////////////////// // Put gold to storage ///////////////////////////////////////////////////////////////////////////////// void Player_GiveGoldW(byte type, long gold) { #region Instert gold into storage try { //Check if the user isnt in any state/action that we will not allow. if (!Character.State.Die || !Character.Stall.Stallactive || !Character.Alchemy.working || !Character.Position.Walking) { //Check if the deposit gold is equally or higher then player inventory gold if (Character.Information.Gold >= gold) { //If the user is storing in normal storage if (!Character.Network.Guild.UsingStorage) { //Set new storage gold plus Character.Account.StorageGold += gold; //Update player inventory gold minus Character.Information.Gold -= gold; //Send update packet client.Send(Packet.UpdateGold(Character.Information.Gold)); //Send visual packet of moving gold client.Send(Packet.MoveItem(type, 0, 0, 0, gold, "MOVE_WAREHOUSE_GOLD")); //Save gold information SaveGold(); } //If the user is using guild storage else { //Set new storage gold plus Character.Network.Guild.StorageGold += gold; //Update player inventory gold minus Character.Information.Gold -= gold; //Send update packet client.Send(Packet.UpdateGold(Character.Information.Gold)); client.Send(Packet.GuildGoldUpdate(Character.Network.Guild.StorageGold, 0x20)); client.Send(Packet.GuildStorageGold(Character)); //Save gold information SaveGold(); //Save guild gold SaveGuildGold(); } } //If gold is to low else { //Send error message to player client.Send(Packet.IngameMessages(SERVER_UPDATEGOLD, IngameMessages.UIIT_MSG_STRGERR_NOT_ENOUGH_GOLD)); } } } catch (Exception ex) { Console.WriteLine("Deposit gold error {0}", ex); Systems.Debugger.Write(ex); } //Save player information SavePlayerInfo(); #endregion }
void GuildInvite() { //Wrap our code into a catcher try { //Create new packet reader PacketReader Reader = new PacketReader(PacketInformation.buffer); //Read lenght of invited character name Int16 InvitedCharacterLEN = Reader.Int16(); //Read invited character name string InvitedCharacter = Reader.String(InvitedCharacterLEN); //Close packet reader Reader.Close(); //Get information for target Systems sys = GetPlayerName(InvitedCharacter); //Set targetid information Character.Network.TargetID = sys.Character.Information.UniqueID; //If player allready has a guild if (sys.Character.Network.Guild.Guildid != 0) { client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_GUILDERR_MEMBER_OF_ANOTHER_GUILD)); return; } //If player has to wait before the player can join another guild if (sys.Character.Information.JoinGuildWait) { client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_GUILD_PENALTY)); return; } //If the guild has max members if (Character.Network.Guild.TotalMembers >= Character.Network.Guild.MaxMembers) { client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_GUILDERR_MEMBER_FULL)); } //If the character doesnt have join rights if (!Character.Network.Guild.joinRight) { //This should not happen unless hack attempt, because button should be grayed out return; } //Set targetid to the invited player sys.Character.Network.TargetID = this.Character.Information.UniqueID; //Send guild request packet sys.client.Send(Packet.PartyRequest(5, this.Character.Information.UniqueID, 0)); //Set bools active Character.State.GuildInvite = true; sys.Character.State.GuildInvite = true; } //Catch bad exception errors catch (Exception ex) { //Write information to the console Console.WriteLine("Guild invite error {0}", ex); //Write information to the debug log Systems.Debugger.Write(ex); } }
void Handle() { try { //Read packet information PacketReader Reader = new PacketReader(PacketInformation.buffer); byte iSlot = Reader.Byte(); //Get global item information Global.slotItem uItemID = GetItem((uint)Character.Information.CharacterID, iSlot, 0); //Checks before continuing if (uItemID.ID != 0 || !Character.State.Die) { //########################################################################################### // Grabpets //########################################################################################### #region Pets (PET OBJECTS) // Grabpets #region Grabpets if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.GRABPET) { //Check if we have pet active allready. if (!Character.Grabpet.Active && Character.Action.MonsterID.Count == 0) { //If not active , add new pet object. HandleGrabPet(iSlot, uItemID.ID); //Need to change this to active effect on slot. HandleUpdateSlotn(iSlot, uItemID, Reader.Int32()); } } #endregion // Attackpets #region Attackpets else if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.ATTACKPET) { //Check if we have pet active allready. if (!Character.Attackpet.Active && Character.Action.MonsterID.Count == 0 || !Character.Attackpet.Active && Character.Action.MonsterID == null) { //If not active , add new pet object. if (!Character.Attackpet.Active) { HandleUpdateSlotn(iSlot, uItemID, Reader.Int32()); HandleAttackPet(iSlot, uItemID.ID); client.Send(Packet.Update2(iSlot)); client.Send(Packet.ChangeStatus(Character.Information.UniqueID, 5, 0)); } } } #endregion #endregion // Horses (NOTE: Detail error messages per if statement (if level, summoned etc). #region Horses if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.TRANSPORT) { //Checks before we continue if (!Character.Stall.Stallactive && !Character.Transport.Right && Character.Action.MonsterID.Count == 0 && !Character.State.Sitting && !Character.Information.Scroll) { //Check if level is high enough if (this.Character.Information.Level >= Data.ItemBase[uItemID.ID].Level) { HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); HandleHorseScroll(uItemID.ID); } //Else else { client.Send(Packet.IngameMessages(SERVER_PLAYER_UPTOHORSE, IngameMessages.UIIT_MSG_COSPETERR_CANT_PETSUM_HIGHLEVEL)); } } } #endregion // Special transport #region Special transport else if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.ATTACKPET) { } #endregion // Job Transport #region Job Transport else if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.JOBTRANSPORT) { //HandleJobTransport(uItemID.ID); } #endregion //########################################################################################### // Potions //########################################################################################### #region Potions #region HP potion if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.HP_POTION && Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.HPSTATPOTION) { HandlePotion(1, uItemID.ID); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } else if (Data.ItemBase[uItemID.ID].Name.Contains("_HP_") && Data.ItemBase[uItemID.ID].Name.Contains("_SUPERSET_")) { HandlePotion(1, uItemID.ID); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } #endregion #region HP STAT Potions else if (Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.HP_POTION && Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.HPSTATPOTION) { } #endregion #region MP potions else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.MP_POTION && Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.MPSTATPOTION) { HandlePotion(2, uItemID.ID); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } else if (Data.ItemBase[uItemID.ID].Name.Contains("_MP_") && Data.ItemBase[uItemID.ID].Name.Contains("_SUPERSET_")) { HandlePotion(1, uItemID.ID); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } #endregion #region HP STAT Potions else if (Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.HP_POTION && Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.MPSTATPOTION) { } #endregion #region Vigor potions /* * else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.VIGOR_POTION) * { * HandlePotion(5, uItemID.ID); * HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); * } */ else if (Data.ItemBase[uItemID.ID].Name.Contains("ITEM_ETC_ALL_")) { HandlePotion(5, uItemID.ID); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } #endregion #region Speed potions else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.SPEED_POTION) { if (Character.Speed.DefaultSpeed == Character.Speed.RunSpeed || Character.Speed.DefaultSpeed + Character.Speed.Updateded[20] != Character.Speed.RunSpeed && Character.Information.Berserking) { this.SpecialBuff(Data.ItemBase[uItemID.ID].SkillID); HandleUpdateSlot(iSlot, uItemID, Reader.UInt16()); } } #endregion #region Berserk Potion else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.BERSERKPOTION) { if (Character.Information.BerserkBar < 5) { if (Character.Information.Berserking == false) { this.Character.Information.BerserkBar = 5; client.Send(Packet.InfoUpdate(4, 0, Character.Information.BerserkBar)); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } } } #endregion #endregion //########################################################################################### // Tickets //########################################################################################### #region Tickets //Forgotten world #region Forgotten world else if (Data.ItemBase[uItemID.ID].Ticket == Global.item_database.Tickets.DUNGEON_FORGOTTEN_WORLD) { //Must add check if user location currently is forgotten world. //Must add level check of portal. ForgottenWorld(uItemID.ID); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } #endregion #endregion //########################################################################################### // Global chat //########################################################################################### #region Global Chat else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.GLOBALCHAT) { HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); byte something = Reader.Byte(); string text = Reader.Text3(); Reader.Close(); SendAll(Packet.ChatPacket(6, 0, text, Character.Information.Name)); } #endregion //########################################################################################### // Stall decoration //########################################################################################### #region Stall decoration else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.STALLDECORATION) { StallDeco(uItemID.ID, iSlot); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } #endregion //########################################################################################### // Monster masks //########################################################################################### #region Monster masks else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.MONSTERMASK) { //If character monster mask isnt enabled allready. if (!Character.Transformed) { if (Character.Information.Level >= Data.ItemBase[uItemID.ID].Level) { //Load Mask MonsterMasks(uItemID.ID, iSlot); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } else { //Send msg level to low } } else { //Send msg allready in use } } #endregion //########################################################################################### // Return scrolls //########################################################################################### #region Return scrolls else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.RETURNSCROLL && Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.REVERSESCROLL) { if (Character.Information.Scroll) { return; } if (Timer.Movement != null) { Timer.Movement.Dispose(); Character.Position.Walking = false; } HandleReturnScroll(uItemID.ID); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } #endregion //########################################################################################### // Reverse scrolls //########################################################################################### #region Reverse scrolls else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.REVERSESCROLL) { if (Character.Information.Scroll) { return; } if (Character.Position.Walking) { return; } //Read item id int itemid = Reader.Int32(); //Our switch byte byte type = Reader.Byte(); //locations for reverse int locid = 0; if (type == 7) { locid = Reader.Int32(); } //Start our handle HandleReverse(itemid, type, locid); //Update slot HandleUpdateSlot(iSlot, uItemID, itemid); } #endregion //########################################################################################### // Thief scrolls //########################################################################################### #region Thief scrolls else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.BANDITSCROLL) { if (Character.Information.Scroll) { return; } HandleThiefScroll(uItemID.ID); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } #endregion //########################################################################################### // Summon scrolls //########################################################################################### #region Summon scrolls else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.SUMMONSCROLL) { HandleSummon(Character.Information.Level); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } #endregion //########################################################################################### // Skin change scrolls //########################################################################################### #region Skin change scrolls else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.CHANGESKIN) { HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); int skinmodel = Reader.Int32(); HandleSkinScroll(skinmodel, uItemID.ID); } #endregion //########################################################################################### // Item change tool //########################################################################################### #region Skin change scrolls else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.ITEMCHANGETOOL) { int itemid = Reader.Int32(); byte targetslot = Reader.Byte(); //Make sure the item target is not equiped. if (targetslot < 13) { return; } //Continue HandleUpdateSlot(iSlot, uItemID, itemid); HandleItemChange(uItemID.ID, iSlot, targetslot); } #endregion //########################################################################################### // Dungeon items //########################################################################################### #region Forgotten world else if (Data.ItemBase[uItemID.ID].Ticket == Global.item_database.Tickets.DUNGEON_FORGOTTEN_WORLD) { HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); ForgottenWorld(uItemID.ID); } #endregion //########################################################################################### // Inventory expansion //########################################################################################### #region Inventory expansion else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.INVENTORYEXPANSION) { HandleInventoryExp(uItemID.ID); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } #endregion //########################################################################################### // Warehouse expansion //########################################################################################### #region Warehouse expansion else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.WAREHOUSE) { HandleWareHouse(uItemID.ID); HandleUpdateSlot(iSlot, uItemID, Reader.Int32()); } #endregion //########################################################################################### // Guild related //########################################################################################### #region Guild Icon else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.GUILD_ICON) { HandleRegisterIcon(); } #endregion //########################################################################################### // Non coded types //########################################################################################### else { //Need to make message in progress or such Console.WriteLine("Non Coded Item ID: " + Data.ItemBase[uItemID.ID].ID + " Name: " + Data.ItemBase[uItemID.ID].Name + ""); } } // Close our packet reader Reader.Close(); } catch (Exception ex) { Console.WriteLine("Item usage error {0}", ex); Systems.Debugger.Write(ex); } }
/////////////////////////////////////////////////////////////////////////// // Rename grab pet /////////////////////////////////////////////////////////////////////////// void RenamePet() { try { //Start reading packet data PacketReader Reader = new PacketReader(PacketInformation.buffer); //Pet id int petid = Reader.Int32(); //Pet name lenght short petnamel = Reader.Int16(); //Pet name string petname = Reader.String(petnamel); //Check availability for pet name. int nameavailable = MsSQL.GetRowsCount("SELECT pet_name FROM pets WHERE pet_name='" + petname + "'"); //If available (Row count is zero). if (nameavailable == 0) { //Create the query we will use MsSQL ms = new MsSQL("SELECT * FROM pets WHERE playerid='" + Character.Information.CharacterID + "' AND pet_unique='" + petid + "'"); //Open our data reader using (SqlDataReader reader = ms.Read()) { //While the reader is reading from database while (reader.Read()) { //First we check the lenght of the name. if (petnamel < 3) { client.Send(Packet.IngameMessages(SERVER_PET_RENAME_MSG, IngameMessages.UIIT_MSG_COSPETERR_PETNAME_NOTPUT)); } //Check if renamed allready. (Should not be needed just extra check) if (Character.Grabpet.Details != null) { if (petid == Character.Grabpet.Details.UniqueID) { if (Character.Grabpet.Details.Petname == "No name") { //Update name in database MsSQL.UpdateData("UPDATE pets SET pet_state='2',pet_name='" + petname + "' WHERE pet_unique='" + petid + "' AND playerid='" + Character.Information.CharacterID + "'"); //Send needed packets to update name (Official sends 2 times)... client.Send(Packet.PetSpawn(petid, 2, Character.Grabpet.Details)); //Send to all currently in spawn range Send(Packet.PetSpawn(petid, 2, Character.Grabpet.Details)); } } } //Check if renamed allready. (Should not be needed just extra check) if (Character.Attackpet.Details != null) { if (petid == Character.Attackpet.Details.UniqueID) { if (Character.Attackpet.Details.Petname == "No name") { //Update name in database MsSQL.UpdateData("UPDATE pets SET pet_state='2',pet_name='" + petname + "' WHERE pet_unique='" + petid + "' AND playerid='" + Character.Information.CharacterID + "'"); //Send needed packets to update name (Official sends 2 times)... client.Send(Packet.PetSpawn(petid, 2, Character.Attackpet.Details)); //Send to all currently in spawn range Send(Packet.PetSpawn(petid, 2, Character.Attackpet.Details)); } } } } } } //If name has been taken else { //Not sure if correct msg. client.Send(Packet.IngameMessages(SERVER_PET_RENAME_MSG, IngameMessages.UIIT_MSG_COSPETERR_PETNAME_NOTPUT)); } } catch (Exception ex) { Console.WriteLine("Grab pet renaming error : " + ex); } }
//########################################################################################### // Start teleporting //########################################################################################### void Teleport_Start() { try { lock (this) { //Checks before we continue if (Character.Action.PickUping) { return; } //Timer checks StopTimers(); //Open the packet reader PacketReader Reader = new PacketReader(PacketInformation.buffer); //Teleport id int teleportidinfo = Reader.Int32(); //Number byte number = Reader.Byte(); //Teleport selected int teleportselect = Reader.Int32(); Reader.Close(); //Find price information int price = Data.TeleportPrice.Find(pc => (pc.ID == number)).price; //If the user has less gold then it costs if (this.Character.Information.Gold < price) { //Send error message this.client.Send(Packet.IngameMessages(SERVER_TELEPORTSTART, IngameMessages.UIIT_MSG_INTERACTION_FAIL_NOT_ENOUGH_MONEY)); return; } //If the user level is lower then the required level if (Data.TeleportPrice.Find(dd => (dd.ID == teleportselect)).level > 0 && Character.Information.Level < Data.TeleportPrice.Find(dd => (dd.ID == teleportselect)).level) { client.Send(Packet.IngameMessages(SERVER_TELEPORTSTART, IngameMessages.UIIT_MSG_INTERACTION_FAIL_OUT_OF_REQUIRED_LEVEL_FOR_TELEPORT)); return; } //If the user is currently with job transport (TODO). //Update players gold this.Character.Information.Gold -= price; //Update players gold in database SaveGold(); //Close buffs BuffAllClose(); //Send teleport packet #1 this.client.Send(Packet.TeleportStart()); //Set state this.Character.InGame = false; //Update location Teleport_UpdateXYZ(Convert.ToByte(teleportselect)); //Despawn objects ObjectDeSpawnCheck(); //Despawn player to other players DeSpawnMe(); //Required client.Send(Packet.TeleportStart2()); //Send loading screen image this.client.Send(Packet.TeleportImage(Data.PointBase[Convert.ToByte(teleportselect)].xSec, Data.PointBase[Convert.ToByte(teleportselect)].ySec)); //Set bool this.Character.Teleport = true; } } catch (Exception ex) { Console.WriteLine("Teleport select error {0}", ex); Systems.Debugger.Write(ex); } }
void GuildStorage() { //Wrap our function inside a catcher try { //If guild level is to low send message if (Character.Network.Guild.Level == 1) { //Need to sniff to check what opcode is sending for the message client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_STORAGE, IngameMessages.GUILD_STORAGE_LEVEL_TO_LOW)); } //If guild level is 2 meaning it has storage option else { //Make sure the user has guild storage rights if (Character.Network.Guild.guildstorageRight) { //Check if other guild members are currently in storage foreach (int member in Character.Network.Guild.Members) { //Make sure member isnt 0 if (member != 0) { //Get player details Systems getplayer = GetPlayerMainid(member); //Make sure player isnt null if (getplayer != null) { //Check if the player is using storage if (getplayer.Character.Network.Guild.UsingStorage) { //Send storage message error client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_STRGERR_STORAGE_OPERATION_BLOCKED)); return; } } } } //Make sure that the user isnt using storage allready if (!Character.Network.Guild.UsingStorage) { byte type = 1; //Set user as active storage user Character.Network.Guild.UsingStorage = true; //Send storage begin packet client.Send(Packet.GuildStorageStart(type)); } } //If the player has no storage rights else { //Send error message to user not allowed client.Send(Packet.IngameMessages(SERVER_GUILD_STORAGE, IngameMessages.UIIT_MSG_STRGERR_STORAGE_OPERATION_BLOCKED)); } } } //Catch any bad errors catch (Exception ex) { //Write information to the console Console.WriteLine("GuildStorage Open Error: {0}", ex); //Write information to the debug log Systems.Debugger.Write(ex); } }
///////////////////////////////////////////////////////////////////////////////// // Take gold from storage ///////////////////////////////////////////////////////////////////////////////// void Player_TakeGoldW(byte type, long gold) { #region Take gold from storage try { //Check if the user isnt in any state/action that we will not allow. if (!Character.State.Die || !Character.Stall.Stallactive || !Character.Alchemy.working || !Character.Position.Walking) { //Normal storage if (!Character.Network.Guild.UsingStorage) { //Check if the gold is equally or higher to the amount withdrawing if (Character.Account.StorageGold >= gold) { //If ok, reduce the gold from storage Character.Account.StorageGold -= gold; //Add the gold to inventory gold Character.Information.Gold += gold; //Send packet update gold client.Send(Packet.UpdateGold(Character.Information.Gold)); //Send visual update client.Send(Packet.MoveItem(type, 0, 0, 0, gold, "MOVE_WAREHOUSE_GOLD")); //Save the gold information SaveGold(); } //If gold is to low else { //Send error message to the player. client.Send(Packet.IngameMessages(SERVER_UPDATEGOLD, IngameMessages.UIIT_MSG_STRGERR_NOT_ENOUGH_GOLD)); } } //Guild storage else { //Check if the gold is equally or higher to the amount withdrawing if (Character.Network.Guild.StorageGold >= gold) { //If ok, reduce the gold from storage Character.Network.Guild.StorageGold -= gold; //Add the gold to inventory gold Character.Information.Gold += gold; //Send packet update gold client.Send(Packet.UpdateGold(Character.Information.Gold)); client.Send(Packet.GuildGoldUpdate(Character.Network.Guild.StorageGold, 0x21)); client.Send(Packet.GuildStorageGold(Character)); //Save the gold information SaveGold(); //Save guild gold SaveGuildGold(); } //If gold is to low else { //Send error message to the player. client.Send(Packet.IngameMessages(SERVER_UPDATEGOLD, IngameMessages.UIIT_MSG_STRGERR_NOT_ENOUGH_GOLD)); } } } } catch (Exception ex) { Systems.Debugger.Write(ex); Console.WriteLine("Take gold from warehouse error {0}", ex); } //Save player information SavePlayerInfo(); #endregion }
///////////////////////////////////////////////////////////////////////////////// // Move item to storage ///////////////////////////////////////////////////////////////////////////////// void Player_MoveItemToStorage(byte f_slot, byte t_slot, int o_id) { #region Move item to storage try { //Check if the user isnt in any state/action that we will not allow. if (Character.State.Die) { return; } if (Character.Stall.Stallactive) { return; } if (Character.Alchemy.working) { return; } if (Character.Position.Walking) { return; } //Normal storage if (!Character.Network.Guild.UsingStorage) { //Get item information Global.slotItem item = GetItem((uint)Character.Information.CharacterID, f_slot, 0); //Get storage price of the item int storageprice = Data.ItemBase[item.ID].Storage_price; //Set amount if its only 1 if (item.Amount == 0) { item.Amount = 1; } //Multiply the price, per amount storageprice *= item.Amount; //Anti hack check make sure that the owner of the item is correct int ownerid = Convert.ToInt32(MsSQL.GetData("SELECT * FROM char_items WHERE id='" + item.dbID + "'", "owner")); //Check if the owner really owns the item. if (ownerid == Character.Information.CharacterID) { //Make sure the stack count is equal or lower then max stack amount if (item.Amount <= Data.ItemBase[item.ID].Max_Stack) { //If the user has enough gold (Equally or higher to storage price). if (Character.Information.Gold >= storageprice) { //Set character gold Character.Information.Gold -= storageprice; //Send update packet for gold client.Send(Packet.UpdateGold(Character.Information.Gold)); //Update mssql database information MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + t_slot + "',slot='" + t_slot + "',storagetype='1' WHERE storageacc='" + Player.ID + "' AND id='" + item.dbID + "'"); //Send visual move packet to player client.Send(Packet.MoveItem(2, f_slot, t_slot, 0, 0, "MOVE_TO_STORAGE")); //Save the player gold SaveGold(); } //If the user does not have enough gold else { client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UIIT_MSG_STRGERR_NOT_ENOUGH_GOLD)); } } //This should not happen but if the stack is to high. else { return; } } //If the player is not the item owner (Hacking attempt). else { Disconnect("ban"); Console.WriteLine("Autobanned user: "******" Due to hacking"); } } //Guild storage else { //Get item information Global.slotItem item = GetItem((uint)Character.Information.CharacterID, f_slot, 0); //Get storage price of the item int storageprice = Data.ItemBase[item.ID].Storage_price; //Set amount if its only 1 if (item.Amount == 0) { item.Amount = 1; } //Multiply the price, per amount storageprice *= item.Amount; //Anti hack check make sure that the owner of the item is correct int ownerid = Convert.ToInt32(MsSQL.GetData("SELECT * FROM char_items WHERE id='" + item.dbID + "'", "owner")); //Check if the owner really owns the item. if (ownerid == Character.Information.CharacterID) { //Make sure the stack count is equal or lower then max stack amount if (item.Amount <= Data.ItemBase[item.ID].Max_Stack) { //If the user has enough gold (Equally or higher to storage price). if (Character.Information.Gold >= storageprice) { //Set character gold Character.Information.Gold -= storageprice; //Send update packet for gold client.Send(Packet.UpdateGold(Character.Information.Gold)); //Update mssql database information MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + t_slot + "',slot='" + t_slot + "',storagetype='3' ,guild_storage_id='" + Character.Network.Guild.Guildid + "' WHERE id='" + item.dbID + "'"); //Send visual move packet to player client.Send(Packet.MoveItem(2, f_slot, t_slot, 0, 0, "MOVE_TO_GUILD_STORAGE")); //Save the player gold SaveGold(); } //If the user does not have enough gold else { client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UIIT_MSG_STRGERR_NOT_ENOUGH_GOLD)); } } //This should not happen but if the stack is to high. else { return; } } //If the player is not the item owner (Hacking attempt). else { Disconnect("ban"); Console.WriteLine("Autobanned user: "******" Due to hacking"); } } } catch (Exception ex) { Console.WriteLine("Storage move error : {0}", ex); Systems.Debugger.Write(ex); } //Save player information SavePlayerInfo(); #endregion }
void GuildPromote() { try { //Read client information int32 id PacketReader reader = new PacketReader(PacketInformation.buffer); int guildid = reader.Int32(); reader.Close(); //When a guild has reached its max level if (Character.Network.Guild.Level == 5) { //Send packet to client and return (Message level up max). client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_ERROR_GUILD_LEVEL_UP_FULL)); return; } //Definition for gold needed int GoldRequired; //Definition for guild points needed int GuildPointRequired; //Check if player is allready in process of upgrading if (!IsUpgrading) { //Set bool to true, so we cant dupe IsUpgrading = true; //Load player guild information before we continue (Check last info). LoadPlayerGuildInfo(false); //Create switch on guildl evel switch (Character.Network.Guild.Level) { case 1: GoldRequired = 3000000; GuildPointRequired = 5400; break; case 2: GoldRequired = 9000000; GuildPointRequired = 50400; break; case 3: GoldRequired = 15000000; GuildPointRequired = 135000; break; case 4: GoldRequired = 21000000; GuildPointRequired = 378000; break; default: return; } //Set new guild level definition + 1 int NewLevel = Character.Network.Guild.Level + 1; //Set new guild storage slot amount int NewStorageSlots = Character.Network.Guild.StorageSlots + 30; //If character's gold is not enough if (Character.Information.Gold < GoldRequired) { //Send message to client client.Send(Packet.IngameMessages(SERVER_GUILD_PROMOTE_MSG, IngameMessages.UIIT_MSG_ERROR_GUILD_LEVEL_UP_GOLD_DEFICIT)); return; } //Not enough guildpoints if (Character.Network.Guild.PointsTotal < GuildPointRequired) { //Send client message client.Send(Packet.IngameMessages(SERVER_GUILD_PROMOTE_MSG, IngameMessages.UIIT_MSG_ERROR_GUILD_LEVEL_UP_GP_DEFICIT)); return; } //Max level if (Character.Network.Guild.Level == 5) { //Send client message client.Send(Packet.IngameMessages(SERVER_GUILD_PROMOTE_MSG, IngameMessages.UIIT_MSG_ERROR_GUILD_LEVEL_UP_FULL)); return; } //If everything else is fine else //Upgrade guild initiate { //If max level return just incase. if (Character.Network.Guild.Level == 5) { return; } //Reduct guildpoints Character.Network.Guild.PointsTotal -= GuildPointRequired; //If the upgrade is final upgrade set points to 0 if (Character.Network.Guild.Level == 4) { Character.Network.Guild.PointsTotal = 0; } //Reduct gold Character.Information.Gold -= GoldRequired; //Send update information to client client.Send(Packet.InfoUpdate(1, Character.Network.Guild.PointsTotal, 0)); //Send success message to client client.Send(Packet.PromoteOrDisband(2)); //Update guild in database MsSQL.UpdateData("UPDATE guild SET guild_level='" + NewLevel + "',guild_points='" + Character.Network.Guild.PointsTotal + "',guild_storage_slots='" + NewStorageSlots + "' WHERE guild_name='" + Character.Network.Guild.Name + "'"); //Repeat for each member in our guild foreach (int member in Character.Network.Guild.Members) { //Check if memeber is not null if (member != 0) { //Get detailed member information Systems memberinfo = GetPlayerMainid(member); //Make sure the member is not null if (memberinfo != null) { //Reload information for the current guild member memberinfo.LoadPlayerGuildInfo(false); //Send guild update packet for current guild member memberinfo.client.Send(Packet.GuildUpdate(Character, 5, 0, 0, 0)); } } } //Save player's gold SaveGold(); //Send update gold packet to client client.Send(Packet.UpdateGold(Character.Information.Gold)); } } //Disable the bool so we can upgrade again IsUpgrading = false; } //If any error accures catch (Exception ex) { //Write error to the console Console.WriteLine("Guild Promote Error: {0}", ex); //Write error to debug log Systems.Debugger.Write(ex); } }
void GuildCreate() { try { //Extra check if user is allready in guild. if (Character.Network.Guild.Guildid != 0) { return; } //If player has recently been in a guild if (Character.Information.JoinGuildWait) { //Need to sniff the retail packet (Tmp used guild war error). client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_GUILDWARERR_GUILD_CREATE_PENALTY)); return; } //Create new packet reader for reading information PacketReader Reader = new PacketReader(PacketInformation.buffer); //None needed integer int notneeded = Reader.Int32(); //Get guild name lenght short GuildNameLen = Reader.Int16(); //Get guild name string GuildName = Reader.String(GuildNameLen); //Close packet reader Reader.Close(); //Remove bad characters from guildname GuildName = Removebadchars(GuildName); //Check length lower are 4 return if (GuildName.Length < 4) { //Send incorrect lenght client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_GUILDERR_INVALID_GUILDNAME_LEN)); return; } //Check if guild name is taken or not. int guildcheckname = MsSQL.GetRowsCount("SELECT * FROM guild WHERE guild_name='" + GuildName + "'"); //If name excists if (guildcheckname == 1) { client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_GUILDERR_SAME_GUILDNAME_EXIST)); return; } //If character level is to low if (Character.Information.Level < 20) { //Send packet level to low message client.Send(Packet.IngameMessages(Systems.SERVER_GUILD, IngameMessages.UIIT_MSG_GUILDERR_TOO_LOW_CREATOR_LEVEL)); return; } //Set the gold requirements 500.000 retail info int goldrequired = 500000; //If gold is lower then price of creating a guild if (Character.Information.Gold < goldrequired) { //Send message not enough gold client.Send(Packet.IngameMessages(SERVER_GUILD, IngameMessages.UIIT_MSG_GUILDERR_NOT_ENOUGH_GOLD)); return; } //All checks ok, continue creating new guild. else { //Reduct the gold required from player gold Character.Information.Gold -= goldrequired; //Save player information SavePlayerInfo(); //Insert guild into database MsSQL.InsertData("INSERT INTO guild (guild_name, guild_level, guild_points, guild_news_t, guild_news_m, guild_members_t, guild_master_id) VALUES ('" + GuildName + "','1','0','" + "" + "','" + "" + "','1','" + Character.Information.CharacterID + "')"); //Get guild id string guildid = MsSQL.GetData("SELECT id FROM guild WHERE guild_name='" + GuildName + "'", "id"); int docount = Convert.ToInt32(guildid); //Insert member into database MsSQL.InsertData("INSERT INTO guild_members (guild_id, guild_member_id, guild_rank, guild_points, guild_fortress, guild_grant, guild_perm_join, guild_perm_withdraw, guild_perm_union, guild_perm_storage, guild_perm_notice) VALUES ('" + docount + "','" + Character.Information.CharacterID + "','0','0','1','','1','1','1','1','1')"); //Load our new guild LoadPlayerGuildInfo(true); //Private packet client.Send(Packet.Guild_Create(Character.Network.Guild)); //Public spawn packet Send(Packet.SendGuildInfo2(this.Character)); } } catch (Exception ex) { Console.WriteLine("Guild creation error: " + ex); Systems.Debugger.Write(ex); } }
void CharacterRequest() { try { //Open packet reader PacketReader Reader = new PacketReader(PacketInformation.buffer); //Get targeted player information Systems sys = GetPlayer(Character.Network.TargetID); if (this.Character.State.UnionApply && sys.Character.State.UnionApply) { if (Reader.Byte() == 1 && Reader.Byte() == 0) { //Need to sniff decline packet info Character.State.UnionApply = false; sys.Character.State.UnionApply = false; } else { //Check for null and set unique id for union and insert our own guild. if (sys.Character.Network.Guild.Unions == null) { int uniqueid = MsSQL.GetRowsCount("SELECT * FROM guild_unions"); sys.Character.Network.Guild.UniqueUnion = uniqueid + 1; MsSQL.InsertData("INSERT INTO guild_unions (union_leader, union_guildid, union_unique_id) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.UniqueUnion + "')"); } //Update database MsSQL.InsertData("INSERT INTO guild_unions (union_leader, union_guildid, union_unique_id) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.UniqueUnion + "')"); //Send union packet to newly joined player client.Send(Packet.UnionInfo(this)); //Send update packet to all guilds in union foreach (int member in Character.Network.Guild.Members) { //Make sure the member is there if (member != 0) { //If the user is not the newly invited member get player info Systems tomember = GetPlayerMainid(member); //Send guild update packet if (tomember != null) { if (!tomember.Character.Network.Guild.SingleSend) { if (Character.Information.CharacterID != tomember.Character.Information.CharacterID) { tomember.Character.Network.Guild.SingleSend = true; tomember.client.Send(Packet.GuildUpdate(Character, 14, 0, 0, 0)); } } } } } foreach (int member in Character.Network.Guild.UnionMembers) { //Make sure the member is there if (member != 0) { //If the user is not the newly invited member get player info Systems tomember = GetPlayerMainid(member); //Send guild update packet if (tomember != null) { if (!tomember.Character.Network.Guild.SingleSend) { tomember.Character.Network.Guild.SingleSend = true; tomember.client.Send(Packet.GuildUpdate(Character, 14, 0, 0, 0)); } } } } //Disable the bool again foreach (int member in Character.Network.Guild.Members) { //Make sure member isnt null if (member != 0) { //Get guildmember details Systems guildmember = GetPlayerMainid(member); //Make sure guildmember isnt null if (guildmember != null) { //Disable bool to allow resend new packets. guildmember.Character.Network.Guild.SingleSend = false; } } } //Disable the bool again foreach (int member in Character.Network.Guild.UnionMembers) { //Make sure member isnt null if (member != 0) { //Get guildmember details Systems guildmember = GetPlayerMainid(member); //Make sure guildmember isnt null if (guildmember != null) { //Disable bool to allow resend new packets. guildmember.Character.Network.Guild.SingleSend = false; } } } //Reset bools Character.State.UnionApply = false; sys.Character.State.UnionApply = false; } } //------------------------------------- [ Exchange invite ] -------------------------------------// else if (this.Character.State.Exchanging && sys.Character.State.Exchanging) { if (Reader.Byte() == 1 && Reader.Byte() == 0) { sys.client.Send(Packet.Exchange_Cancel()); Character.State.Exchanging = false; sys.Character.State.Exchanging = false; } else { sys.client.Send(Packet.OpenExhangeWindow(1, this.Character.Information.UniqueID)); client.Send(Packet.OpenExhangeWindow(sys.Character.Information.UniqueID)); Character.Network.Exchange.Window = true; Character.Network.Exchange.ItemList = new List <DarkEmu_GameServer.Global.slotItem>(); sys.Character.Network.Exchange.Window = true; sys.Character.Network.Exchange.ItemList = new List <DarkEmu_GameServer.Global.slotItem>(); } } //------------------------------------- [ Guild invite ] -------------------------------------// else if (this.Character.State.GuildInvite && sys.Character.State.GuildInvite) { //If byte equals 2 the type is denied if (Reader.Byte() == 2) { //Denied request Character.State.GuildInvite = false; sys.Character.State.GuildInvite = false; //Send refused packet to sender sys.client.Send(Packet.IngameMessages(SERVER_GUILD, IngameMessages.UIIT_MSG_GUILDERR_JOIN_GUILD_REFUSED)); } //If not denied we start adding the new member else { //Invite guild member (Add member count + 1). int guildmemberadd = sys.Character.Network.Guild.Members.Count + 1; //Update database MsSQL.InsertData("INSERT INTO guild_members (guild_id, guild_member_id, guild_rank, guild_points, guild_fortress, guild_grant, guild_perm_join, guild_perm_withdraw, guild_perm_union, guild_perm_storage, guild_perm_notice) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + Character.Information.CharacterID + "','10','0','1','" + "" + "','0','0','0','0','0')"); MsSQL.UpdateData("UPDATE guild SET guild_members_t='" + guildmemberadd + "' WHERE guild_name='" + sys.Character.Network.Guild.Name + "'"); //Reload new member and load character data for guildinfo LoadPlayerGuildInfo(true); //Send packets to network and spawned players foreach (int member in Character.Network.Guild.Members) { //Make sure the member is there if (member != 0) { //We dont send this info to the invited user. if (member != Character.Information.CharacterID) { //If the user is not the newly invited member get player info Systems tomember = GetPlayerMainid(member); //Send guild update packet tomember.LoadPlayerGuildInfo(true); tomember.client.Send(Packet.GuildUpdate(Character, 1, Character.Information.CharacterID, 0, 0)); tomember.client.Send(Packet.GuildSetOnline(Character.Network.Guild, Character.Information.UniqueID)); tomember.client.Send(Packet.GuildUpdate(Character, 6, Character.Information.CharacterID, 0, 0)); } //Send information to the invited player else { //Send guild data packets to invited client.Send(Packet.SendGuildStart()); client.Send(Packet.SendGuildInfo(Character.Network.Guild)); client.Send(Packet.SendGuildEnd()); //Load union data for new invited player LoadUnions(); } } } //Set bools to false for new invite Character.State.GuildInvite = false; sys.Character.State.GuildInvite = false; } } //------------------------------------- [ Party invite ] -------------------------------------// else { //If invitation is accepted if (Reader.Byte() == 1 && Reader.Byte() == 1) { //First we set our main checks (Check if player is in party or not). if (Character.Network.Party != null) { return; } //Set bools for check Character.Information.CheckParty = true; sys.Character.Information.CheckParty = true; //Set main party information party JoiningParty = sys.Character.Network.Party; //Check party type members allowed need message if full if (JoiningParty.Type == 4 && JoiningParty.Members.Count > 3) { //Send party is full message to player client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MESSAGES, IngameMessages.UIIT_MSG_PARTYERR_ALREADY_FULL)); return; } if (JoiningParty.Type == 5 && JoiningParty.Members.Count > 7) { //Send party is full message to player client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MESSAGES, IngameMessages.UIIT_MSG_PARTYERR_ALREADY_FULL)); return; } //If the current count == 0 then add party and add me if (JoiningParty.Members.Count == 0) { //Add ourselfs to the party list JoiningParty.Members.Add(sys.Character.Information.UniqueID); //Add our client to the party list JoiningParty.MembersClient.Add(sys.client); //Set party id JoiningParty.ptid = Party.Count + 1; //Set party network info sys.Character.Network.Party = JoiningParty; //Send permissions sys.client.Send(Packet.Party_Member(sys.Character.Information.UniqueID)); //Send party data to leader sys.client.Send(Packet.Party_DataMember(JoiningParty)); //Send party data packet to leader (Other player that joined). sys.client.Send(Packet.Party_Data(2, Character.Information.UniqueID)); //Add invited member to the list JoiningParty.Members.Add(Character.Information.UniqueID); JoiningParty.MembersClient.Add(client); //Set party info for invited member Character.Network.Party = JoiningParty; //Send permissions client.Send(Packet.PartyOwnerInformation(Character.Information.UniqueID)); //Send party data client.Send(Packet.Party_DataMember(JoiningParty)); //return return; } //If there are more members in the current party else { //Repeat for each member using count for (byte b = 0; b <= JoiningParty.Members.Count - 1; b++) { //Get player information from [b] Systems others = GetPlayer(JoiningParty.Members[b]); //Send party data to member others.client.Send(Packet.Party_Data(2, Character.Information.UniqueID)); } //Add the invited member to list JoiningParty.Members.Add(Character.Information.UniqueID); //Add the invited client to the list JoiningParty.MembersClient.Add(client); //Set party Character.Network.Party = JoiningParty; //Send permissions client.Send(Packet.PartyOwnerInformation(Character.Information.UniqueID)); //Send party data client.Send(Packet.Party_DataMember(JoiningParty)); return; } } //If denied request else { //Send denied message to the player joining client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MEMBER, IngameMessages.UIIT_MSG_PARTYERR_JOIN_PARTY_REFUSED)); //Set both bools to false so inviting can be done again sys.Character.Information.CheckParty = false; Character.Information.CheckParty = false; } } } //Catch bad exception errors catch (Exception ex) { //Write information to the console Console.WriteLine("Request error: {0}", ex); //Write information to the debug log Debugger.Write(ex); } }
void DonateGP() { //First we write our function inside a catcher try { //Max level of guild wont allow new gp donations. if (Character.Network.Guild.Level == 5) { //Send error message to client client.Send(Packet.IngameMessages(SERVER_GUILD_PROMOTE_MSG, IngameMessages.UIIT_MSG_GUILD_LACK_GP)); return; } //Open our packet reader PacketReader reader = new PacketReader(PacketInformation.buffer); //Read donated gp amount (int). int donatedgp = reader.Int32(); //Close packet reader reader.Close(); //Anti hack checking (If donated gp higher is then the player skillpoints. if (donatedgp > Character.Information.SkillPoint) { return; } //Calculate total int totalgp = Character.Network.Guild.PointsTotal + donatedgp; //Set guild points total Character.Network.Guild.PointsTotal += donatedgp; //Set skill points minus donated amount Character.Information.SkillPoint -= donatedgp; //Set donated gp + donated skill points Character.Network.Guild.DonateGP += donatedgp; //Save our information (Skill points). SavePlayerInfo(); //Update database total guild points MsSQL.UpdateData("UPDATE guild SET guild_points='" + totalgp + "' WHERE guild_name='" + Character.Network.Guild.Name + "'"); //Update database donated player guild points amount MsSQL.UpdateData("UPDATE guild_members SET guild_points='" + Character.Network.Guild.DonateGP + "' WHERE guild_member_id='" + Character.Information.CharacterID + "'"); //Send packets to donator. client.Send(Packet.InfoUpdate(1, totalgp, 0)); //Send donated gp info PacketWriter writer = new PacketWriter(); //Add opcode writer.Create(Systems.SERVER_GUILD_DONATE_GP); //Write static byte 1 writer.Byte(1); //Write dword int value donated gp amount. writer.DWord(donatedgp); //Send bytes to client client.Send(writer.GetBytes()); //Repeat for each member in our guild foreach (int member in Character.Network.Guild.Members) { //Make sure that the member isnt null if (member != 0) { //Now we get the detailed information for each member Systems guildmember = GetPlayerMainid(member); //Make sure the guildmember is still there if (guildmember != null) { //Send guild update packets to each member (Donated gp information and % bar update). guildmember.client.Send(Packet.GuildUpdate(Character, 13, 0, 0, totalgp)); guildmember.client.Send(Packet.GuildUpdate(Character, 9, 0, 0, totalgp)); } } } } //Catch any bad exception error catch (Exception ex) { //Write information to the console Console.WriteLine("Donate GP Error {0}", ex); //Write information to the debug log. Systems.Debugger.Write(ex); } }
///////////////////////////////////////////////////////////////////////// //Formed party join response ///////////////////////////////////////////////////////////////////////// void FormedResponse() { try { //Open our packet data reader PacketReader reader = new PacketReader(PacketInformation.buffer); int Requestermodel = reader.Int32(); int Characterid = reader.Int32(); byte responsetype = reader.Byte(); reader.Close(); //Get player information Systems sys = GetPlayer(Characterid); //If the requester is not in a party yet if (sys.Character.Network.Party == null) { //If party doesnt excist anymore or is not listed anymore if (Character.Network.Party != null) { //If not formed anymore if (!Character.Network.Party.IsFormed) { //Send cannot find party message sys.client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MESSAGES, IngameMessages.UIIT_MSG_PARTYERR_CANT_FIND_PARTY)); return; } } //If party is null else { //Send cannot find party message sys.client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MESSAGES, IngameMessages.UIIT_MSG_PARTYERR_CANT_FIND_PARTY)); return; } //Accept new member if (responsetype == 1) { //Check party type members allowed need message if full if (Character.Network.Party.Type == 4 && Character.Network.Party.Members.Count > 3) { //Add msg party full return; } if (Character.Network.Party.Type == 5 && Character.Network.Party.Members.Count > 7) { //Add msg party full return; } //Send packets to creator and invited member sys.client.Send(Packet.Party_Member(sys.Character.Information.UniqueID)); client.Send(Packet.PartyOwnerInformation(Character.Information.UniqueID)); //Set bools for check Character.Information.CheckParty = true; //Bool for requester sys.Character.Information.CheckParty = true; //Add member Character.Network.Party.Members.Add(sys.Character.Information.UniqueID); Character.Network.Party.MembersClient.Add(sys.client); //Send packet for each member in party foreach (int member in Character.Network.Party.Members) { if (member != 0) { Systems mainParty = GetPlayer(member); //If the member is the owner if (mainParty != null) { if (mainParty.Character.Information.CharacterID == Character.Information.CharacterID) { //Just send update packet mainParty.client.Send(Packet.Party_DataMember(mainParty.Character.Network.Party)); } //For other members else { //Send member joined packet mainParty.client.Send(Packet.JoinResponseMessage(1)); //Send update packet mainParty.client.Send(Packet.Party_DataMember(Character.Network.Party)); //Set new party data mainParty.Character.Network.Party = Character.Network.Party; } } } } } //Refuse else { //If the party is a new party if (sys.Character.Network.Party.Members.Count < 1) { Character.Information.CheckParty = false; } else { sys.client.Send(Packet.Party_Member(sys.Character.Information.UniqueID)); Character.Information.CheckParty = false; } } } } catch (Exception ex) { Console.WriteLine("Formed response error {0}", ex); Systems.Debugger.Write(ex); } }