Plus Emu Commands

Results 1 to 15 of 15
  1. #1
    lol Disguised is offline
    MemberRank
    Jan 2011 Join Date
    521Posts

    thumbs up Plus Emu Commands

    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!");
                }
            }


  2. #2
    Member Juicex3 is offline
    MemberRank
    Apr 2014 Join Date
    81Posts

    Re: Plus Emu Commands

    Can you Code mus Commands like updatemotto, giveitem?

  3. #3
    Member Charlotte Potts is offline
    MemberRank
    Aug 2015 Join Date
    YorkshireLocation
    64Posts

    Re: Plus Emu Commands

    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.

  4. #4
    lol Disguised is offline
    MemberRank
    Jan 2011 Join Date
    521Posts

    Re: Plus Emu Commands

    Quote Originally Posted by Juicex3 View Post
    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.

  5. #5
    Apprentice ppntn is offline
    MemberRank
    Jan 2016 Join Date
    LondonLocation
    12Posts

    Re: Plus Emu Commands

    @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?

  6. #6
    Enthusiast Ramy Elguindy is offline
    MemberRank
    Jan 2015 Join Date
    29Posts

    Re: Plus Emu Commands

    Can you add the command forceheight(fh) that helps in stacking?

  7. #7
    Enthusiast Leafy is offline
    MemberRank
    Dec 2011 Join Date
    AustraliaLocation
    30Posts

    Re: Plus Emu Commands

    Quote Originally Posted by Ramy Elguindy View Post
    Can you add the command forceheight(fh) that helps in stacking?
    @Ramy Elguindy, Probably is but there's not really a point as you can just edit it in phpmyadmin

  8. #8
    git bisect -m ovflowd is offline
    MemberRank
    Sep 2011 Join Date
    2,191Posts

    Re: Plus Emu Commands

    Quote Originally Posted by ppntn View Post
    @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.

    - - - Updated - - -

    PHP Code:
    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 Code:
    public void hug(string[] Params) {

      
    string text MergeParams(Params1);

      
    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.XhuggerRoomUser.Coordinate.Y).GetDistanceSquared(new Vector2D(huggedRoomUser.Coordinate.XhuggedRoomUser.Coordinate.Y)) > 2) {
        
    this.Session.SendWhisper("The user is too far away, try getting closer.");
        return;
      }

      
    huggerRoomUser.Chat(huggerRoomUser.GetClient(), "*Hugs " text "*"true0);
      
    huggerRoomUser.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ActivateCustomEffect(9);

    - - - Updated - - -

    I did some improvements, feel free to use it. (Edited in Atom, so i don't know if will work)

  9. #9
    Apprentice ppntn is offline
    MemberRank
    Jan 2016 Join Date
    LondonLocation
    12Posts

    Re: Plus Emu Commands

    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 = @username");
                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/

  10. #10
    git bisect -m ovflowd is offline
    MemberRank
    Sep 2011 Join Date
    2,191Posts

    Re: Plus Emu Commands

    Quote Originally Posted by ppntn View Post
    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 = @username");
                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.

  11. #11
    Apprentice ppntn is offline
    MemberRank
    Jan 2016 Join Date
    LondonLocation
    12Posts

    Re: Plus Emu Commands

    Quote Originally Posted by ovflowd View Post
    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 = @username");
                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 by ppntn; 28-01-16 at 04:07 AM. Reason: Redid code

  12. #12
    Enthusiast Ramy Elguindy is offline
    MemberRank
    Jan 2015 Join Date
    29Posts

    Re: Plus Emu Commands

    Quote Originally Posted by Leafy View Post
    @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

  13. #13
    git bisect -m ovflowd is offline
    MemberRank
    Sep 2011 Join Date
    2,191Posts

    Re: Plus Emu Commands

    Quote Originally Posted by ppntn View Post
    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 = @username");
                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!

  14. #14
    Account Upgraded | Title Enabled! streamhotel is offline
    MemberRank
    Apr 2012 Join Date
    EarthLocation
    511Posts

    Re: Plus Emu Commands

    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 :)

  15. #15
    Enthusiast Johan is offline
    MemberRank
    Jan 2016 Join Date
    47Posts

    Re: Plus Emu Commands

    How Can I Add A Faceless Command? :/ Cause faceless is not in my Command tab thingy Plus The SPULL PULL SPUSH PUSH Commands :/



Advertisement