Degree of Protection (PlusEmu)

RobinLA

New Member
Nov 20, 2020
8
0
Hello everyone,

I have a little problem.
I get the following error - it says, that "RoleplayUser.Client" cannot reach 'cause the degree of protection.
But I don't understand why...

Here's the error:
You must be registered for see images attach


And these are the codes:

Habbo.cs
C#:
public IWebSocketConnection WebSocketConnection
        {
            get
            {
                if (PlusEnvironment.GetGame().GetWebEventManager() != null)
                    return PlusEnvironment.GetGame().GetWebEventManager().GetUsersConnection(RoleplayUser.Client);
                else
                    return null;
            }
        }


RoleplayUser.cs
C#:
namespace Bobba.HabboRoleplay.Web
{
    public class RoleplayUser
    {
        // Client Info
        GameClient Client;

        public RoleplayUser(GameClient Client)
        {
            // Client Info
            this.Client = Client;
        }
    }
}

Hope, somepne can help me.
 

RobinLA

New Member
Nov 20, 2020
8
0
C# class members are private by default, you need to make Client public -> public GameClient Client;
I already tried this, but it isn't working.

You mean like this? :
C#:
namespace Bobba.HabboRoleplay.Web
{
    public class RoleplayUser
    {
        // Client Info
        public GameClient Client;

        public RoleplayUser(GameClient Client)
        {
            // Client Info
            this.Client = Client;
        }
    }
}

Then I got in this code:

C#:
public IWebSocketConnection WebSocketConnection
        {
            get
            {
                if (PlusEnvironment.GetGame().GetWebEventManager() != null)
                    return PlusEnvironment.GetGame().GetWebEventManager().GetUsersConnection(RoleplayUser.Client);
                else
                    return null;
            }
        }
this error:
You must be registered for see images attach

English: The non-static field, method, or property "RoleplayUser.Client" must have an object reference.

And I saw the same code in the HoloRP Emulator (Plus) and there is also "GameClient client" and not "public GameClient Client" and it works.
And the C# Class RoleplayUser is already public - so that's the reason why I don't know what's the problem/why it isn't working..
 

CosmoPeak

PeakRP.com
May 15, 2016
271
268
You're currently trying to access a static variable Client on RoleplayUser, which is incorrect.

You need an instance of RoleplayUser to get Client from it. There isn't much code to go off, so it's hard to tell what you've got at the moment.
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
Rather than trying to implement this like the Habbo class is, I would implement this as a member of the Habbo.cs file.

The reason for this is you already have your GameClient, and Player instances. Really the RP is just an extension of a Habbo.

In Habbo.cs I would have a reference to RoleplayUser

Code:
public class Habbo{

      public RoleplayUser RP {get; set;} = new RoleplayUser(); //You can also create a new instance in the constructor if you want to pass in parameters, probably a good idea to store the user id in the class so you can just pass the individual class to methods that utilize it.

}
 

Users who are viewing this thread

Top