INACTIVE Hariak Emulator - From Scratch - Clean&Stable - MongoDB + MySQL

Status
Not open for further replies.

Quackster

a devbest user says what
Aug 22, 2010
1,763
1,235
Do me a favour and don't mix all your database queries throughout your entire source code, otherwise you're just doing what every other server has done since since the dawn of Habbo emulation.

For example, in my C++ server all of my database access is moved to database access objects/dao files.

 
Last edited:

Seriosk

Programmer;
Oct 29, 2016
256
105
I no longer support this development, seeing this arrogance spew out of you (again) just made me remember why I avoided you in the first place. Please try to be more considerate to the people who take time to give you feedback to help you on your project.

Sorry, but good luck.
I wasn't aware you were supporting it in the first place. Anyhow, good day.

Some new news,
Hello. Today I have some exciting but minor news about the progress of Hariak. I decided to move away from the default permission system layout and change the way it actually works, extending the functionality and ease of usage. Below is a simple screenshot of how it works in a basic understanding, but I'll go in to detail more about it below.

Since DevBest has recently been having issues displaying images via its proxy, here is the link to directly view it


2e51a8d5c40b49e9a6676752f9da8ebc.png


In emulators, especially RP emulators I saw people hard coding code such as the following..
Code:
if (Session.GetHabbo().Username == "SomeUsername")
{
}

And they would use that as a authentication to the command in a way, but what happens if you fired a staff member with that username, would you go through all the usernames and such and change it? That would get pretty annoying after a while, hopefully this new permission system brings ease of use, and hopefully the extended functionality gets used in the right way.

Lets get one thing straight, empty columns and columns that == '0' are ignored, meaning its skipped in the for each loop operating. If you don't know what that means, it means if you don't want this column to actually be checked, then you can simply just put a 0 or leave it empty, not null hasn't been checked for any column except permission_name and id. Below I have written a few examples of how the extended functionality could help some people.

I want to let them have this permission if their motto equals to 'helloworld' without the quotes, simple..
Code:
{'motto'='helloworld'}
With the custom column setting, you can check if any column, even on another table equals to that.

How does the checking if columns of other tables equal something work?
The other table must have a column called 'id' and the 'id' must equal to the users id. I haven't added any support for custom primary key names but maybe before release that could come, really not sure yet.

How does it ultimately check if a user has this command?
If any restriction is passed, so if any rule equals to true.

What if I want multiple sets of rules on the same permission?
You can have multiple records with the same permission_name

Not everything has been thought through, but I am sure its extended functionality will help much more than previous emulators have.

Forgot to mention how you could check multiple columns, here is the syntax for it:
Code:
{'motto'='something'}{'another_column'='somevalue'}
 
Do me a favour and don't mix all your database queries throughout your entire source code, otherwise you're just doing what every other server has done since since the dawn of Habbo emulation.

For example, in my C++ server all of my database access is moved to database access objects/dao files.

I was thinking of doing something like this and storing all queries in some kind of database layer as I was planning on better indexing all my queries some time soon, its also an awesome way to find all your queries without having to use 'find all references' of a method in visual studio. Thanks!!

News => 24/03/2017
Decided to move all components belonging to Player into its own little class, it seemed less messy that way.

Code:
namespace Hariak_Emulator.Emulator.Base.Game.Habbo.Players.Players
{
    using Components.Clothing;
    using Components.Ignore;
    using Components.Navigation;
    using Effects;

    internal sealed class PlayerComponentHandler
    {
        private readonly PlayerConnection _playerConnection;
        private readonly PlayerSearchComponent _searchesComponent;
        private readonly PlayerIgnoreComponent _ignoreComponent;
        private readonly PlayerClothingComponent _clothingComponent;
        private readonly PlayerEffectComponent _effectComponent;

        internal PlayerComponentHandler(PlayerConnection playerConnection)
        {
            _playerConnection = playerConnection;

            _searchesComponent = new PlayerSearchComponent(_playerConnection);
            _searchesComponent.InitializeComponent();

            _ignoreComponent = new PlayerIgnoreComponent(_playerConnection);
            _ignoreComponent.InitializeComponent();

            _clothingComponent = new PlayerClothingComponent(_playerConnection);
            _clothingComponent.InitializeComponent();

            _effectComponent = new PlayerEffectComponent(_playerConnection);
            _effectComponent.InitializeComponent();
        }

        internal PlayerEffectComponent EffectComponent => _effectComponent;
    }
}

And seeing as PlayerData is a base class off PlayerConnection, I'm using casting to get the base controller.

Loading component handler class:
Code:
_componentHandler = new PlayerComponentHandler((PlayerConnection)this);

It may seem useless for 4 components, but there are many more components to come
Permissions, Inventory, Badges, maybe even a groups one (unsure yet).

Created an easy method to send notifications and whispers to anyone with a certain permission.
Code:
internal void SendNotificationForPermission(string message, string permission, bool isWhisper = false)
        {
            foreach (var playerConnection in _players.Values.Where(playerConnection => playerConnection.Utilities.CanUsePermission(permission)))
            {
                if (isWhisper)
                {
                    playerConnection.SendWhisper(message);
                }
                else
                {
                    playerConnection.SendNotification(message);
                }
            }
        }

Players can now easily be grabbed by column with these simple methods:
Code:
private IEnumerable<GameClient> GetPlayerConnectionsByColumn(string columnName, string columnValue)
{
    return _players.Values.Where(playerConnection => playerConnection != null && playerConnection.SelectColumn(columnName) == columnValue).ToArray();
}

internal GameClient GetPlayerConnectionByColumn(string columnName, string columnValue)
{
    return GetPlayerConnectionsByColumn(columnName, columnValue).First();
}

private string GetColumnByUserId(int userId, string columnName)
{
    try
    {
        var playerConnectionByColumn = GetPlayerConnectionByColumn("id", userId.ToString());

        if (playerConnectionByColumn != null)
        {
            return playerConnectionByColumn.SelectColumn(columnName);
        }

        using (var databaseConnection = Hariak.HariakServer.Database.NewDatabaseConnection)
        {
            databaseConnection.SetQuery("SELECT `" + columnName + "` FROM `users` WHERE `id` = @userId");
            databaseConnection.AppendParameter("userId", userId);

            return databaseConnection.ExecuteSingleString();
        }
    }
    catch (Exception)
    {
        return "Unknown Column Value";
    }
}

internal string GetUsernameByUserId(int userId)
{
    return GetColumnByUserId(userId, "username");
}
 
Last edited:
Status
Not open for further replies.

Users who are viewing this thread

Top