Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Plus Emu Commands

Joined
Jan 23, 2011
Messages
446
Reaction score
99
I've been bored recently & started coding some commands for plus emu,

I'm sure some of you will find these useful.

Commands:
hug
balance
bancount

Enjoy,

Code:
public void balance()
        {
            int Credits = Session.GetHabbo().Credits;
            int Pixels = Session.GetHabbo().ActivityPoints;
            uint Rank = Session.GetHabbo().Rank;
            string Output = String.Empty;


            using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().getQueryreactor())
            {
                Adapter.runFastQuery("SELECT credits, activity_points, rank FROM users WHERE username = @Me");
                Adapter.addParameter("Me", Session.GetHabbo().Username);


                DataTable Table = Adapter.getTable();
                if (Table != null)
                {
                    Output += "Account Balance for " + Session.GetHabbo().Username + "\r";
                    Output += "--------------------------------\r";
                    Output += "Credits: " + Credits.ToString() + "\r";
                    Output += "Pixels: " + Pixels.ToString() + "\r";
                    Output += "Rank: " + Rank.ToString() + "\r";


                    Session.SendNotifWithScroll(Output);
                }
            }
        }

Code:
public void hug(string[] Params)
        {
            string text = MergeParams(Params, 1);


            Habbo Habbo1 = this.Session.GetHabbo();
            if (Habbo1.CurrentRoom != null)
            {
                RoomUser User1 = Habbo1.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Habbo1.Id);
                if (User1 != null)
                {
                    RoomUser User2 = Habbo1.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(text);
                    if (User2 == null)
                    {
                        this.Session.SendWhisper("Open your eyes! " + text + " is not in the room.");
                        return;
                    }
                    else if (new Vector2D(User1.Coordinate.X, User1.Coordinate.Y).GetDistanceSquared(new Vector2D(User2.Coordinate.X, User2.Coordinate.Y)) > 2)
                    {
                        this.Session.SendWhisper("The user is too far away, try getting closer.");
                        return;
                    }
                    User1.Chat(User1.GetClient(), "*Hugs " + text + "*", true, 0);
                    User1.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ActivateCustomEffect(9);
                }
            }
        }

Code:
 public void bancount()
        {
            int Count = 0;
            using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().getQueryreactor())
            {
                Adapter.runFastQuery("SELECT id FROM bans");
                DataTable BanTable = Adapter.getTable();
                if (BanTable != null)
                {
                    Count = BanTable.Rows.Count;
                }
                Session.SendNotif(PlusEnvironment.HotelName + " Has saved you from Disguised & Dillon " + Count.ToString() + " times!");
            }
        }
 
Newbie Spellweaver
Joined
Apr 22, 2014
Messages
81
Reaction score
6
Can you Code mus Commands like updatemotto, giveitem?
 
Newbie Spellweaver
Joined
Aug 3, 2015
Messages
64
Reaction score
26
I'm a little bit confused as to why you set variables for all the info, then do a query to get the same information.. and why not just do a count query for the bans?

These in my opinion aren't very well coded, and can be improved.
 
Joined
Jan 23, 2011
Messages
446
Reaction score
99
Can you Code mus Commands like updatemotto, giveitem?

Code:
internal void giveitem()
        {
            Room TargetRoom = Session.GetHabbo().CurrentRoom;
            Room User = TargetRoomUser = null;
            TargetRoom = PlusEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);


            if (TargetRoom == null)
            {
                return;
            }


            TargetRoomUser = TargetRoom.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);


            if (TargetRoomUser == null)
            {
                return;
            }


            try
            {
                TargetRoomUser.CarryItem(int.Parse(Params[1]));
            }


            catch { }


            return;
        }

not tested.
 
Newbie Spellweaver
Joined
Jan 18, 2016
Messages
12
Reaction score
14
@Disguised why not check if the user is present in the client manager and then output his data and if the user is not present, then you'd get the data from the database?
 
Newbie Spellweaver
Joined
Jan 31, 2015
Messages
29
Reaction score
4
Can you add the command forceheight(fh) that helps in stacking?
 
git bisect -m
Loyal Member
Joined
Sep 2, 2011
Messages
2,173
Reaction score
917
@Disguised why not check if the user is present in the client manager and then output his data and if the user is not present, then you'd get the data from the database?

Simply need to check if is in the room.



PHP:
public void balance() {

  string Output = String.Empty;

  Output += "Account Balance for " + Session.GetHabbo().Username + "\r";
  Output += "--------------------------------\r";
  Output += "Credits: " + Session.GetHabbo().Credits + "\r";
  Output += "Pixels: " + Session.GetHabbo().ActivityPoints + "\r";
  Output += "Rank: " + Session.GetHabbo().Rank + "\r";

  Session.SendNotifWithScroll(Output);
}

PHP:
public void hug(string[] Params) {

  string text = MergeParams(Params, 1);

  Habbo huggerHabbo = this.Session.GetHabbo();

  if (huggerHabbo.CurrentRoom == null)
    return;

  RoomUser huggerRoomUser = huggerHabbo.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(huggerHabbo.Id); 
  // I don't know if in Phoenix this is the best implementation
  // I think exists other way to get the currentUser Room. Maybe something like huggerHabb.CurrentRoom();
  // Obs: I don't have Phx Source

  if (huggerRoomUser == null)
    return;

  // Does this Text is filtered?
  RoomUser huggedRoomUser = Habbo1.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(text);

  if (huggedRoomUser == null) {
    this.Session.SendWhisper("Open your eyes! " + text + " is not in the room.");
    return;
  }
  else if (new Vector2D(huggerRoomUser.Coordinate.X, huggerRoomUser.Coordinate.Y).GetDistanceSquared(new Vector2D(huggedRoomUser.Coordinate.X, huggedRoomUser.Coordinate.Y)) > 2) {
    this.Session.SendWhisper("The user is too far away, try getting closer.");
    return;
  }

  huggerRoomUser.Chat(huggerRoomUser.GetClient(), "*Hugs " + text + "*", true, 0);
  huggerRoomUser.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ActivateCustomEffect(9);
}



I did some improvements, feel free to use it. (Edited in Atom, so i don't know if will work)
 
Newbie Spellweaver
Joined
Jan 18, 2016
Messages
12
Reaction score
14
Code:
public void balance()
{
    string Username = MergeParams(Params, 1);
    string Output = String.Empty;
    Output += "Account Balance for " + Username + "\r";
    Output += "--------------------------------\r";
    if (Session == null) {
        using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().getQueryreactor())
        {
            Adapter.runFastQuery("SELECT credits, activity_points, rank FROM users WHERE username = [USER=411303]username[/USER]");
            Adapter.addParameter("username", Username);
            DataTable Table = Adapter.getTable();
            if (Table != null)
            {
                foreach (DataRow row in Table.Rows)
                {
                    Output += "Credits: " + row["credits"].ToString() + "\r";
                    Output += "Pixels: " + row["activity_points"].ToString() + "\r";
                    Output += "Rank: " + row["rank"].ToString() + "\r";
                }
            }
        }
    } else {
        Output += "Credits: " + Session.GetHabbo().Credits + "\r";
        Output += "Pixels: " + Session.GetHabbo().ActivityPoints + "\r";
        Output += "Rank: " + Session.GetHabbo().Rank + "\r";
    }
    Session.SendNotifWithScroll(Output);
}
If you want to be able to check offline users. \o/
 
git bisect -m
Loyal Member
Joined
Sep 2, 2011
Messages
2,173
Reaction score
917
Code:
public void balance()
{
    string Username = MergeParams(Params, 1);
    string Output = String.Empty;
    Output += "Account Balance for " + Username + "\r";
    Output += "--------------------------------\r";
    if (Session == null) {
        using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().getQueryreactor())
        {
            Adapter.runFastQuery("SELECT credits, activity_points, rank FROM users WHERE username = @[I][B][URL="http://forum.ragezone.com/members/411303.html"]username[/URL][/B][/I]");
            Adapter.addParameter("username", Username);
            DataTable Table = Adapter.getTable();
            if (Table != null)
            {
                foreach (DataRow row in Table.Rows)
                {
                    Output += "Credits: " + row["credits"].ToString() + "\r";
                    Output += "Pixels: " + row["activity_points"].ToString() + "\r";
                    Output += "Rank: " + row["rank"].ToString() + "\r";
                }
            }
        }
    } else {
        Output += "Credits: " + Session.GetHabbo().Credits + "\r";
        Output += "Pixels: " + Session.GetHabbo().ActivityPoints + "\r";
        Output += "Rank: " + Session.GetHabbo().Rank + "\r";
    }
    Session.SendNotifWithScroll(Output);
}
If you want to be able to check offline users. \o/

Weird and Horrible code. Doesn't need do Query in Phx for that. Phoenix has Cached Users, when Phoenix Starts retrieve basic data of everyone.

Balance is good for you, if you're staff you can check other users balance with Mod Tools.
 
Newbie Spellweaver
Joined
Jan 18, 2016
Messages
12
Reaction score
14
Weird and Horrible code. Doesn't need do Query in Phx for that. Phoenix has Cached Users, when Phoenix Starts retrieve basic data of everyone.

Balance is good for you, if you're staff you can check other users balance with Mod Tools.
Why would you ever need to cache every single user on start up? That would be memory overload if you have like 1 million users..
Code:
public void balance()
{
    string Username = MergeParams(Params, 1);
    string Output = String.Empty;
    GameClient User = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Username);
    Output += "Account Balance for " + Username + "\r";
    Output += "--------------------------------\r";
    if (User == null) {
        using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().getQueryreactor())
        {
            Adapter.runFastQuery("SELECT credits, activity_points, rank FROM users WHERE username = [USER=411303]username[/USER]");
            Adapter.addParameter("username", Username);
            DataTable Table = Adapter.getTable();
            if (Table != null)
            {
                foreach (DataRow row in Table.Rows)
                {
                    Output += "Credits: " + row["credits"].ToString() + "\r";
                    Output += "Pixels: " + row["activity_points"].ToString() + "\r";
                    Output += "Rank: " + row["rank"].ToString() + "\r";
                }
            }
        }
    } else {
        Output += "Credits: " + User.GetHabbo().Credits + "\r";
        Output += "Pixels: " + User.GetHabbo().ActivityPoints + "\r";
        Output += "Rank: " + User.GetHabbo().Rank + "\r";
    }
    Session.SendNotifWithScroll(Output);
}
 
Last edited:
Newbie Spellweaver
Joined
Jan 31, 2015
Messages
29
Reaction score
4
@Ramy Elguindy, Probably is but there's not really a point as you can just edit it in phpmyadmin
There is a point, this command help in making wonderfull rooms, im not talking about editing the stack height of the furni itself and im talking about editing the height of dropping the furni in room
 
git bisect -m
Loyal Member
Joined
Sep 2, 2011
Messages
2,173
Reaction score
917
Why would you ever need to cache every single user on start up? That would be memory overload if you have like 1 million users..
Code:
public void balance()
{
    string Username = MergeParams(Params, 1);
    string Output = String.Empty;
    GameClient User = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Username);
    Output += "Account Balance for " + Username + "\r";
    Output += "--------------------------------\r";
    if (User == null) {
        using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().getQueryreactor())
        {
            Adapter.runFastQuery("SELECT credits, activity_points, rank FROM users WHERE username = @[I][B][URL="http://forum.ragezone.com/members/411303.html"]username[/URL][/B][/I]");
            Adapter.addParameter("username", Username);
            DataTable Table = Adapter.getTable();
            if (Table != null)
            {
                foreach (DataRow row in Table.Rows)
                {
                    Output += "Credits: " + row["credits"].ToString() + "\r";
                    Output += "Pixels: " + row["activity_points"].ToString() + "\r";
                    Output += "Rank: " + row["rank"].ToString() + "\r";
                }
            }
        }
    } else {
        Output += "Credits: " + User.GetHabbo().Credits + "\r";
        Output += "Pixels: " + User.GetHabbo().ActivityPoints + "\r";
        Output += "Rank: " + User.GetHabbo().Rank + "\r";
    }
    Session.SendNotifWithScroll(Output);
}

Simple, if your users Table has not useless columns, doing a basic user cache is great, and will spend low time (depending of your hardware, and users table size).

The trick is users tables have only the necessary data about the users, emulators like Azure and Mercury has a "hundred" of columns, useless, specific user information need to be stored in other tables.
The way is the Emulator get the basic user data: username, id, e-mail, rank, credits, pixels, last online, last ip.
This is basic information.

You know that every emulator a specific user has friends, also users want to open other users profile that show basic informations.
Emulators like Azure does caching only when someone log in, and the data is stored only for him.

Azure needs to do heavy queries to obtain friends data, and other things.

In Yupi in want to improve cache system.

Storing only basic user data, if stored in decent way can be helpful, but use some RAM, this is not problem if you're in a server with decent Hardware specs.
A good way is maybe check the limit of RAM, storing the cache in cycles into threads, storing only necessary data about some users,
is good also make a "ranking" system for cache system, if some user cached is not requested regularly these data will be flushed, remaining only data about users that are online (that's important) and about users data that are accessed regularly.

An important thing for Online Users data is a regularly enqueue for synchronise data, since Emulator is the "onliest software" that change users data after user registration and login. (if your cms doesn't have shop and these things.. That is really useless, because if you know how to do a good catalogue these addons for your CMS are useless).

You need know a little about Software Architecture by Layers. In a "good" way that no one emulator of this forums in Habbo section has, is good using software concepts like "software architecture by layers", remaining the MVCP (Model, View, Controller, Persistence).

Is good in a Habbo Emulator the:
1. View Layer <=> Communication
2. Controller Layer <=> Handle Data
3. Model Layer <=> Stores Data (Models)
4. Persistence <=> Save Data in Database
And also a extra layer called
5. QoE/QoC Layer, these two layers are really important! Quality of Execution (The Software need's to regularly check if has no memory leaks, and if the useless data is being flushed, also if the data is regularly updated), And the Quality of Context Layer, that is necessary to the Software knows which best Execution he can get inside his Context.

We can see a little (worse) example in Ragnarok Emulators. They Have Multiple View Layers (Map, Game, Users)

Also other PERFECT implementation is the famous TCP/IP Protocol, where we have TCP and UDP and XTP (example) in top-layer and IP in low-layer, the 7 layers of Internet (public OSI/ISO Model).

Sorry of being off-topic. But you need know what you're saying in this point.

Obviously is bad caching every data of users, but if you're using C# you can easily fill only a part of the data in the User Model Instance,
and filling the rest when is necessary. Isn't needed fill every single data of all users in Emulator Startup, but the basics is good.

Since for me is more important the Emulator Managing in a better way the memory, and not a Fast Startup.

Fast != Quality. The 4 Layers of PMBOK Project Restrictions:
1. Scope
2. Time
3. Budget
4. Quality

Cheers, and a good day!
 
Joined
Apr 17, 2012
Messages
508
Reaction score
77
Some of the commands that are coded are "useless" in my eyes. Before you code something you must ask yourself the question would this be rewarding if I add it? I actually don't think "bancount" is a very needed command, same like the "about/info" commands. Some people forget about that the emulator is focused on the users and they don't care what server you're using for example.

Another disadvantage is that bad code can cause bad performance, security problems etc. and also have a negative effect to the usability for the users, more useless commands giving a bad summary.

And for giving a good example of coding custom commands I would say "empty" because in a Habbo Retro your inventory get very big fast because you can buy more items then on the real Habbo, if everything is free its logic. Or convertcredits is also an good example of how to code USEFULL commands.

These tips would help you :)
 
Newbie Spellweaver
Joined
Jan 27, 2016
Messages
47
Reaction score
1
How Can I Add A Faceless Command? :/ Cause faceless is not in my Command tab thingy Plus The SPULL PULL SPUSH PUSH Commands :/
 
Back
Top