public void Parse(GameClient session, ClientPacket packet) { string petName = packet.PopString(); if (petName.Length < 2) { session.SendPacket(new CheckPetNameComposer(2, "2")); return; } if (petName.Length > 15) { session.SendPacket(new CheckPetNameComposer(1, "15")); return; } if (!PlusEnvironment.IsValidAlphaNumeric(petName)) { session.SendPacket(new CheckPetNameComposer(3, string.Empty)); return; } if (PlusEnvironment.GetGame().GetChatManager().GetFilter().IsFiltered(petName)) { session.SendPacket(new CheckPetNameComposer(4, string.Empty)); return; } session.SendPacket(new CheckPetNameComposer(0, string.Empty)); }
public void Parse(GameClient Session, ClientPacket Packet) { string PetName = Packet.PopString(); if (PetName.Length < 2) { Session.SendPacket(new CheckPetNameComposer(2, "2")); return; } else if (PetName.Length > 15) { Session.SendPacket(new CheckPetNameComposer(1, "15")); return; } else if (!PlusEnvironment.IsValidAlphaNumeric(PetName)) { Session.SendPacket(new CheckPetNameComposer(3, "")); return; } else if (PlusEnvironment.GetGame().GetChatManager().GetFilter().IsFiltered(PetName)) { Session.SendPacket(new CheckPetNameComposer(4, "")); return; } Session.SendPacket(new CheckPetNameComposer(0, "")); }
public static bool CheckPetName(string PetName) { if (PetName.Length < 1 || PetName.Length > 16) { return(false); } if (!PlusEnvironment.IsValidAlphaNumeric(PetName)) { return(false); } return(true); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom) return; Room Room = Session.GetHabbo().CurrentRoom; if (Room == null) return; int ItemId = Packet.PopInt(); Item Item = Room.GetRoomItemHandler().GetItem(ItemId); if (Item == null || Item.Data == null || Item.UserID != Session.GetHabbo().Id || Item.Data.InteractionType != InteractionType.GNOME_BOX) return; string PetName = Packet.PopString(); if (string.IsNullOrEmpty(PetName)) { Session.SendPacket(new CheckGnomeNameComposer(PetName, 1)); return; } if (!PlusEnvironment.IsValidAlphaNumeric(PetName)) { Session.SendPacket(new CheckGnomeNameComposer(PetName, 1)); return; } int X = Item.GetX; int Y = Item.GetY; //Quickly delete it from the database. using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @ItemId LIMIT 1"); dbClient.AddParameter("ItemId", Item.Id); dbClient.RunQuery(); } //Remove the item. Room.GetRoomItemHandler().RemoveFurniture(Session, Item.Id); //Apparently we need this for success. Session.SendPacket(new CheckGnomeNameComposer(PetName, 0)); //Create the pet here. Pet Pet = PetUtility.CreatePet(Session.GetHabbo().Id, PetName, 26, "30", "ffffff"); if (Pet == null) { Session.SendNotification("Oops, an error occoured. Please report this!"); return; } List<RandomSpeech> RndSpeechList = new List<RandomSpeech>(); List<BotResponse> BotResponse = new List<BotResponse>(); Pet.RoomId = Session.GetHabbo().CurrentRoomId; Pet.GnomeClothing = RandomClothing(); //Update the pets gnome clothing. using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `bots_petdata` SET `gnome_clothing` = @GnomeClothing WHERE `id` = @PetId LIMIT 1"); dbClient.AddParameter("GnomeClothing", Pet.GnomeClothing); dbClient.AddParameter("PetId", Pet.PetId); dbClient.RunQuery(); } //Make a RoomUser of the pet. RoomUser PetUser = Room.GetRoomUserManager().DeployBot(new RoomBot(Pet.PetId, Pet.RoomId, "pet", "freeroam", Pet.Name, "", Pet.Look, X, Y, 0, 0, 0, 0, 0, 0, ref RndSpeechList, "", 0, Pet.OwnerId, false, 0, false, 0), Pet); //Give the food. ItemData PetFood = null; if (PlusEnvironment.GetGame().GetItemManager().GetItem(320, out PetFood)) { Item Food = ItemFactory.CreateSingleItemNullable(PetFood, Session.GetHabbo(), "", ""); if (Food != null) { Session.GetHabbo().GetInventoryComponent().TryAddItem(Food); Session.SendPacket(new FurniListNotificationComposer(Food.Id, 1)); } } }
public void Parse(GameClient session, ClientPacket packet) { if (session?.GetHabbo() == null || !session.GetHabbo().InRoom) { return; } var room = session.GetHabbo().CurrentRoom; if (room == null) { return; } var itemId = packet.PopInt(); var item = room.GetRoomItemHandler().GetItem(itemId); if (item?.Data == null || item.UserId != session.GetHabbo().Id || item.Data.InteractionType != InteractionType.GnomeBox) { return; } var petName = packet.PopString(); if (string.IsNullOrEmpty(petName)) { session.SendPacket(new CheckGnomeNameComposer(petName, 1)); return; } if (!PlusEnvironment.IsValidAlphaNumeric(petName)) { session.SendPacket(new CheckGnomeNameComposer(petName, 1)); return; } //Quickly delete it from the database. using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @ItemId LIMIT 1"); dbClient.AddParameter("ItemId", item.Id); dbClient.RunQuery(); } //Remove the item. room.GetRoomItemHandler().RemoveFurniture(session, item.Id); //Apparently we need this for success. session.SendPacket(new CheckGnomeNameComposer(petName, 0)); //Create the pet here. var pet = PetUtility.CreatePet(session.GetHabbo().Id, petName, 26, "30", "ffffff"); if (pet == null) { session.SendNotification("Oops, an error occoured. Please report this!"); return; } pet.RoomId = session.GetHabbo().CurrentRoomId; pet.GnomeClothing = RandomClothing(); using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `bots_petdata` SET `gnome_clothing` = @GnomeClothing WHERE `id` = @PetId LIMIT 1"); dbClient.AddParameter("GnomeClothing", pet.GnomeClothing); dbClient.AddParameter("PetId", pet.PetId); dbClient.RunQuery(); } ItemData petFood; if (!PlusEnvironment.GetGame().GetItemManager().GetItem(320, out petFood)) { return; } var food = ItemFactory.CreateSingleItemNullable(petFood, session.GetHabbo(), ""); if (food == null) { return; } session.GetHabbo().GetInventoryComponent().TryAddItem(food); session.SendPacket(new FurniListNotificationComposer(food.Id, 1)); }
public void Parse(GameClient session, ClientPacket packet) { if (session == null || session.GetHabbo() == null || !session.GetHabbo().InRoom) { return; } Room room = session.GetHabbo().CurrentRoom; if (room == null) { return; } int itemId = packet.PopInt(); Item item = room.GetRoomItemHandler().GetItem(itemId); if (item == null || item.Data == null || item.UserID != session.GetHabbo().Id || item.Data.InteractionType != InteractionType.GNOME_BOX) { return; } string petName = packet.PopString(); if (string.IsNullOrEmpty(petName)) { session.SendPacket(new CheckGnomeNameComposer(petName, 1)); return; } if (!PlusEnvironment.IsValidAlphaNumeric(petName)) { session.SendPacket(new CheckGnomeNameComposer(petName, 1)); return; } int x = item.GetX; int y = item.GetY; //Quickly delete it from the database. using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @ItemId LIMIT 1"); dbClient.AddParameter("ItemId", item.Id); dbClient.RunQuery(); } //Remove the item. room.GetRoomItemHandler().RemoveFurniture(session, item.Id); //Apparently we need this for success. session.SendPacket(new CheckGnomeNameComposer(petName, 0)); //Create the pet here. Pet pet = PetUtility.CreatePet(session.GetHabbo().Id, petName, 26, "30", "ffffff"); if (pet == null) { session.SendNotification("Oops, an error occoured. Please report this!"); return; } List <RandomSpeech> rndSpeechList = new List <RandomSpeech>(); pet.RoomId = session.GetHabbo().CurrentRoomId; pet.GnomeClothing = RandomClothing(); //Update the pets gnome clothing. using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `bots_petdata` SET `gnome_clothing` = @GnomeClothing WHERE `id` = @PetId LIMIT 1"); dbClient.AddParameter("GnomeClothing", pet.GnomeClothing); dbClient.AddParameter("PetId", pet.PetId); dbClient.RunQuery(); } //Make a RoomUser of the pet. room.GetRoomUserManager().DeployBot(new RoomBot(pet.PetId, pet.RoomId, "pet", "freeroam", pet.Name, "", pet.Look, x, y, 0, 0, 0, 0, 0, 0, ref rndSpeechList, "", 0, pet.OwnerId, false, 0, false, 0), pet); //Give the food. if (PlusEnvironment.GetGame().GetItemManager().GetItem(320, out ItemData petFood)) { Item food = ItemFactory.CreateSingleItemNullable(petFood, session.GetHabbo(), "", ""); if (food != null) { session.GetHabbo().GetInventoryComponent().TryAddItem(food); session.SendPacket(new FurniListNotificationComposer(food.Id, 1)); } } }