[Plus EMU R1] Pets Don't Save

Status
Not open for further replies.

Bran

habcrush.pw
Mar 13, 2017
1,789
1,609
hey yall, do basically I use Plus Emu R1 (2017 swfs) and you can buy pets and everything completely fine but when you leave or unload the room the pet disappears like it completely disappears out the inventory aswell..? does anybody know a fix for this?
 

Joe

Well-Known Member
Jun 10, 2012
4,172
1,955
I 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.
 

harambe

Donator
Dec 3, 2018
154
115
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);
        }
    }
}
 

Bran

habcrush.pw
Mar 13, 2017
1,789
1,609
thank u !!! i was gunna try that but didn't know weather too or not
Post automatically merged:

I 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.
prefer R1 just my personal preference :)
Post automatically merged:

that fails when i try & rebuild lol
 
Last edited:
  • Like
Reactions: Joe

Rebel

Spilling the tea, can't you read?🍵
Dec 24, 2015
186
161
Would you like to post how you fixed it if the code above doesn’t build?
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.
 

Joe

Well-Known Member
Jun 10, 2012
4,172
1,955
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.
Thanks. For future reference if anybody else has this issue I’m pretty sure it’s a query error.
 
Status
Not open for further replies.

Users who are viewing this thread

Top