Replace PickUpPetEvent.cs
Code:using System; using System.Linq; using System.Text; using System.Collections.Generic; using Plus.HabboHotel.Rooms.AI; using Plus.HabboHotel.Rooms; using Plus.Communication.Packets.Outgoing.Inventory.Pets; using System.Drawing; using Plus.HabboHotel.GameClients; using Plus.Communication.Packets.Outgoing.Rooms.Engine; using Plus.Database.Interfaces; namespace Plus.Communication.Packets.Incoming.Rooms.AI.Pets { class PickUpPetEvent : IPacketEvent { public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().InRoom) return; if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().GetInventoryComponent() == null) return; Room Room; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room)) return; int PetId = Packet.PopInt(); RoomUser Pet = null; if (!Room.GetRoomUserManager().TryGetPet(PetId, out Pet)) { //Check kick rights, just because it seems most appropriate. if ((!Room.CheckRights(Session) && Room.WhoCanKick != 2 && Room.Group == null) || (Room.Group != null && !Room.CheckRights(Session, false, true))) return; //Okay so, we've established we have no pets in this room by this virtual Id, let us check out users, maybe they're creeping as a pet?! RoomUser TargetUser = Session.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(PetId); if (TargetUser == null) return; //Check some values first, please! if (TargetUser.GetClient() == null || TargetUser.GetClient().GetHabbo() == null) return; //Update the targets PetId. TargetUser.GetClient().GetHabbo().PetId = 0; //Quickly remove the old user instance. Room.SendPacket(new UserRemoveComposer(TargetUser.VirtualId)); //Add the new one, they won't even notice a thing!!11 8-) Room.SendPacket(new UsersComposer(TargetUser)); return; } if (Session.GetHabbo().Id != Pet.PetData.OwnerId && !Room.CheckRights(Session, true, false)) { Session.SendWhisper("You can only pickup your own pets, to kick a pet you must have room rights."); return; } //Only if user is riding horse duuuh if (Pet.RidingHorse) { RoomUser UserRiding = Room.GetRoomUserManager().GetRoomUserByVirtualId(Pet.HorseID); if (UserRiding != null) { //Set user is not longer riding a horse UserRiding.RidingHorse = false; //Set user effect to normal UserRiding.ApplyEffect(-1); UserRiding.MoveTo(new Point(UserRiding.X + 1, UserRiding.Y + 1)); } else Pet.RidingHorse = false; } Pet.PetData.RoomId = 0; Pet.PetData.PlacedInRoom = false; Pet pet = Pet.PetData; if (pet != null) { using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("UPDATE `bots` SET `room_id` = '0', `x` = '0', `Y` = '0', `Z` = '0' WHERE `id` = '" + pet.PetId + "' LIMIT 1"); dbClient.RunQuery("UPDATE `bots_petdata` SET `experience` = '" + pet.experience + "', `energy` = '" + pet.Energy + "', `nutrition` = '" + pet.Nutrition + "', `respect` = '" + pet.Respect + "' WHERE `id` = '" + pet.PetId + "' LIMIT 1"); } Session.GetHabbo().GetInventoryComponent().TryAddPet(Pet.PetData); Session.SendPacket(new PetInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetPets())); } if (pet.OwnerId != Session.GetHabbo().Id) { GameClient Target = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(pet.OwnerId); if (Target != null) { Target.GetHabbo().GetInventoryComponent().TryAddPet(Pet.PetData); Session.SendPacket(new PetInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetPets())); Room.GetRoomUserManager().RemoveBot(Pet.VirtualId, false); Target.SendPacket(new PetInventoryComposer(Target.GetHabbo().GetInventoryComponent().GetPets())); return; } } Session.SendPacket(new PetInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetPets())); Room.GetRoomUserManager().RemoveBot(Pet.VirtualId, false); } } }
prefer R1 just my personal preferenceI remember having this problem and fixing it as it was a problem with the query in the emulator, not 100% sure though as I recommend R2/R3.
Would you like to post how you fixed it if the code above doesn’t build?Problem fixed, thankfully we use the same Plus EMU release.
Tbh I gave him all my main related pet files in the emulator, in a WinRAR and had him replace his with mine. Easiest way, because I had that problem in 2015 just don't remember how I fixed it but it was due to the emulator, not DB.Would you like to post how you fixed it if the code above doesn’t build?
Thanks. For future reference if anybody else has this issue I’m pretty sure it’s a query error.Tbh I gave him all my main related pet files in the emulator, in a WinRAR and had him replace his with mine. Easiest way, because I had that problem in 2015 just don't remember how I fixed it but it was due to the emulator, not DB.