[PlusEMU] Users profile not showing when offline?

rxinbows

New Member
Mar 24, 2019
13
4
We keep getting this pop-up when a user is offline on our hotel. We're running PlusEMU R1

You must be registered for see images attach
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
It's because the packet is looking for the client object of the user, instead it needs to search in the database and create a habbo structure then pass that over.
 

Hypothesis

Programmer
Jan 6, 2019
524
361
how do you do that?
Go into PlusEnvironment.cs and find class GetUsernameById and replace that entire class with this.
Code:
public static string GetUsernameById(int UserId)
        {
            string Name = "Unknown User";

            GameClient Client = GetGame().GetClientManager().GetClientByUserID(UserId);
            if (Client != null && Client.GetHabbo() != null)
                return Client.GetHabbo().Username;

            UserCache User = PlusEnvironment.GetGame().GetCacheManager().GenerateUser(UserId);
            if (User != null)
                return User.Username;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `username` FROM `users` WHERE id = @id LIMIT 1");
                dbClient.AddParameter("id", UserId);
                Name = dbClient.getString();
            }

            if (string.IsNullOrEmpty(Name))
                Name = "Unknown User";

            return Name;
        }
Next inside PlusEnvironment, you wanna find class GetHabboByUsername, you're gonna replace that entire class with this.
Code:
public static Habbo GetHabboByUsername(String UserName)
        {
            try
            {
                using (IQueryAdapter dbClient = GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `id` FROM `users` WHERE `username` = @user LIMIT 1");
                    dbClient.AddParameter("user", UserName);
                    int id = dbClient.getInteger();
                    if (id > 0)
                        return GetHabboById(Convert.ToInt32(id));
                }
                return null;
            }
            catch { return null; }
        }
Lastly, find OpenPlayerProfileEvent.cs and replace that entire class with this.
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.HabboHotel.Users;
using Plus.HabboHotel.Groups;
using Plus.Communication.Packets.Outgoing.Users;
using Plus.Database.Interfaces;


namespace Plus.Communication.Packets.Incoming.Users
{
    class OpenPlayerProfileEvent : IPacketEvent
    {
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            int userID = Packet.PopInt();
            Boolean IsMe = Packet.PopBoolean();

            Habbo targetData = PlusEnvironment.GetHabboById(userID);
            if (targetData == null)
            {
                Session.SendNotification("An error occured whilst finding that user's profile.");
                return;
            }
           
            List<Group> Groups = PlusEnvironment.GetGame().GetGroupManager().GetGroupsForUser(targetData.Id);
           
            int friendCount = 0;
            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT COUNT(0) FROM `messenger_friendships` WHERE (`user_one_id` = @userid OR `user_two_id` = @userid)");
                dbClient.AddParameter("userid", userID);
                friendCount = dbClient.getInteger();
            }

            Session.SendMessage(new ProfileInformationComposer(targetData, Session, Groups, friendCount));
        }
    }
}
After that, compile and you should be good, if it doesn't work, respond to the thread.
 

Karel

Member
May 15, 2019
80
13
You have to open it and visual studio and rebuild the solution
I think I'm stupid, but is there a important difference between release and debug? Normally I use Debug and things update well with that setting...

I don't think you've done it correctly, it should fix it. I can check over TeamViewer.
I have have copied the codes and pasted them in my emulator (I did have to capitalize getString and getInteger, but I don't think that's the problem). Then clicked Debug (Multiple Platforms) and started the client. TeamViewer would be nice, but there is probably a timedifference... I'm from Holland. If you're from America the difference is about 5 hours, but if you don't have to go to school/work it's great!
 

Users who are viewing this thread

Top