[Plus Emulator] Useful commands

Results 1 to 12 of 12
  1. #1
    Enthusiast u20 is offline
    MemberRank
    Sep 2016 Join Date
    26Posts

    smile [Plus Emulator] Useful commands

    Hi people. I think that I created two commands that, maybe, are useful.

    So, I advice you that I'm italian and the sentences are in italian, but I'll explain how they work.

    The first command allow the admin to copy room items that you select by the parameter in the command.

    So I explain how to add it, maybe you can provide a better way of this command, I'm not really good.

    However, go in your habbo.cs and add this public bool:

    PHP Code:
    public bool copy false
    then, go into your roomitemhandling, search for

    Code:
     using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())            {
                    dbClient.RunQuery("UPDATE `items` SET `room_id` = '" + _room.RoomId + "', `x` = '" + Item.GetX + "', `y` = '" + Item.GetY + "', `z` = '" + Item.GetZ + "', `rot` = '" + Item.Rotation + "' WHERE `id` = '" + Item.Id + "' LIMIT 1");
                }
    and replace with that:

    Code:
      if(!Session.GetHabbo().copy)            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `items` SET `room_id` = '" + _room.RoomId + "', `x` = '" + Item.GetX + "', `y` = '" + Item.GetY + "', `z` = '" + Item.GetZ + "', `rot` = '" + Item.Rotation + "' WHERE `id` = '" + Item.Id + "' LIMIT 1");
                }
                else
                {
                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("INSERT INTO `items` (base_item,user_id,room_id,x,y,z,wall_pos,rot,extra_data,`limited_number`,`limited_stack`) VALUES (@did,@uid,@rid,@x,@y,@z @WALl_pos @rot @eXtra_data, @Limited_number, @Limited_stack)");
                        dbClient.AddParameter("did", Item.BaseItem);
                        dbClient.AddParameter("uid", Session.GetHabbo().Id);
                        dbClient.AddParameter("rid", Session.GetHabbo().CurrentRoomId);
                        dbClient.AddParameter("x", Item.GetX);
                        dbClient.AddParameter("y", Item.GetY);
                        dbClient.AddParameter("z", Item.GetZ);
                        dbClient.AddParameter("wall_pos", Item.wallCoord);
                        dbClient.AddParameter("rot", Item.Rotation);
                        dbClient.AddParameter("extra_data", Item.ExtraData);
                        dbClient.AddParameter("limited_number", Item.LimitedNo);
                        dbClient.AddParameter("limited_stack", Item.LimitedTot);
                        Item.Id = Convert.ToInt32(dbClient.InsertQuery());
                    }
                }
    Ok, now we can go into our commandmanager.cs and add the command:

    Code:
    this.Register("copiaroom", new CopyRoom());
    now, create a new class "copyroom.cs" into your command's folder, and paste:

    Code:
    using System;using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Plus.HabboHotel.GameClients;
    using Plus.HabboHotel.Items;
    using Plus.Database.Interfaces;
    using System.Data;
    using Plus.HabboHotel.Rooms;
    using Plus.Communication.Packets.Outgoing.Rooms.Session;
    
    
    namespace Plus.HabboHotel.Rooms.Chat.Commands.Administrator
    {
        class CopyRoom : IChatCommand
        {
            public string Description
            {
                get
                {
                    return "Copia una stanza";
                }
            }
    
    
            public string Parameters
            {
                get
                {
                    return "%id%";
                }
            }
    
    
            public string PermissionRequired
            {
                get
                {
                    return "command_massgive";
                }
            }
    
    
            public void Execute(GameClient Session, Room Room, string[] Params)
            {
                if (Params.Length == 1)
                {
                    Session.SendWhisper("Inserisci l'ID della stanza!");
                    return;
                }
                Room _room = Session.GetHabbo().CurrentRoom;
                Room room = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(Convert.ToInt32(Params[1]));
                if (_room.GetRoomItemHandler().GetWallAndFloor.Count() > 0)
                {
                    Session.SendWhisper("Per poter copiare una stanza bisogna che in questa stanza non ci siano furni.");
                    return;
                }
                else if(_room.Model != room.Model)
                {
                    Session.SendWhisper("Non puoi copiare due stanze con model diversi. Digita :copiamodel %roomid% per copiarne il model");
                    return;
                }
                else
                {
                    Session.GetHabbo().copy = true;
                    foreach(Item item in room.GetRoomItemHandler().GetFloor)
                    {
                        _room.GetRoomItemHandler().SetFloorItem(Session, item, item.GetX, item.GetY, item.Rotation, true, false, false, false, false);
                    }
                    foreach(Item item2 in room.GetRoomItemHandler().GetWall)
                    {
                        _room.GetRoomItemHandler().SetWallItem(Session, item2);
                    }
                    List<RoomUser> UsersToReturn = Room.GetRoomUserManager().GetRoomUsers().ToList();
                    PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(_room, true);
                    PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(Room, true);
                    
                    foreach (RoomUser User in UsersToReturn)
                    {
                        if (User == null || User.GetClient() == null)
                            continue;
    
    
                        User.GetClient().SendMessage(new RoomForwardComposer(_room.Id));
                    }
                    // u20 :-( I'm in your heart
                }
                Session.GetHabbo().copy = false;
            }
        }
    }

    Oh, I used the parameter "command_give" because I won't to create anothe row in permissions_commands. Obviously, you can change that. You can change all the command too
    .

    However, the command check two things:
    1) the items in the current room, they must be 0, or the command will return a whisper that say "you can use the command because there is some item";
    2) check the modeldata. Yeah, if the room_1_model != room_2_model it doesn't work, so I created a second command "copymodel" (what a fantasy!)


    So, going into our commandmanager, add that

    Code:
    this.Register("copiamodel", new CopiaModel());
    then, create a class "copiamodel.cs", or how you call that and paste:
    Code:
    using System;using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Plus.HabboHotel.GameClients;
    using Plus.Database.Interfaces;
    using Plus.Communication.Packets.Outgoing.Rooms.Session;
    
    
    namespace Plus.HabboHotel.Rooms.Chat.Commands.Administrator
    {
        class CopiaModel : IChatCommand
        {
            public string Description
            {
                get
                {
                    return "Copia il model di una stana";
                }
            }
    
    
            public string Parameters
            {
                get
                {
                    return "%roomdi%";
                }
            }
    
    
            public string PermissionRequired
            {
                get
                {
                    return "command_massgive";
                }
            }
    
    
            public void Execute(GameClient Session, Room Room, string[] Params)
            {
                if (Params.Length == 1)
                {
                    Session.SendWhisper("Inserisci l'ID della stanza!");
                    return;
                }
                Room _room = Session.GetHabbo().CurrentRoom;
                Room room = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(Convert.ToInt32(Params[1]));
    
    
                if(_room.Model != room.Model)
                {
                   using(IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("UPDATE rooms SET model_name = @model WHERE id = @id LIMIT 1;");
                        dbClient.AddParameter( @model", room.ModelName);
                        dbClient.AddParameter( @id", _room.Id);
                        dbClient.RunQuery();
                    }
                }
                PlusEnvironment.GetGame().GetRoomManager().GetModel(room.ModelName);
                List<RoomUser> UsersToReturn = Room.GetRoomUserManager().GetRoomUsers().ToList();
                PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(_room, true);
                PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(Room, true);
                
                foreach (RoomUser User in UsersToReturn)
                {
                    if (User == null || User.GetClient() == null)
                        continue;
    
    
                    User.GetClient().SendMessage(new RoomForwardComposer(_room.Id));
                }
    
    
            }
        }
    }
    Perfect, now all is done.
    I've some examples.
    Instead, I need to copy this room

    Spoiler:



    The id is 13112, then I go in my room and copy the model:
    Spoiler:


    and, finally, I use the copy command, and the result is that:
    Spoiler:



    I think that a problem is that I use the INSERT query to duplicate the items. I think that it's wrong. But I don't have any other idea ^-^. If you can advice me something I will love u <3

    oh I forgot that u can use the command in this way:
    "copiaroom %ROOMID%
    "copiamodel %ROOMID%

    happy new yearrrrr!
    Last edited by u20; 06-01-17 at 11:52 PM.


  2. #2
    Valued Member Mackors is offline
    MemberRank
    Aug 2016 Join Date
    100Posts

    Re: [Plus Emulator] Useful commands

    Great release! However, you'll need to use a better and secure method to insert it.

    This idea is creative, let's hope to see more from you.

  3. #3
    Enthusiast Lex is offline
    MemberRank
    Dec 2016 Join Date
    26Posts

    Re: [Plus Emulator] Useful commands

    I was looking for a copyroomcommand, so thank you for that! Maybe it is possible to make one command of it (first make the new room model, and then place the furni in it). Anyway, great release.
    Last edited by Lex; 07-01-17 at 11:58 AM.

  4. #4
    Enthusiast u20 is offline
    MemberRank
    Sep 2016 Join Date
    26Posts

    Re: [Plus Emulator] Useful commands

    @Lex you can do that simply adding a second params. Like that
    Code:
    if(Params[1].ToString() == "model"){
    Room room = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(Convert.ToInt32(Params[2]));
    
    
                if(_room.Model != room.Model)
                {
                   using(IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("UPDATE rooms SET model_name = @model WHERE id = @id LIMIT 1;");
                        dbClient.AddParameter("@model", room.ModelName);
                        dbClient.AddParameter("@id", _room.Id);
                        dbClient.RunQuery();
                    }
                }
                PlusEnvironment.GetGame().GetRoomManager().GetModel(room.ModelName);
                List<RoomUser> UsersToReturn = Room.GetRoomUserManager().GetRoomUsers().ToList();
                PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(_room, true);
                PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(Room, true);
                
                foreach (RoomUser User in UsersToReturn)
                {
                    if (User == null || User.GetClient() == null)
                        continue;
    
    
                    User.GetClient().SendMessage(new RoomForwardComposer(_room.Id));
                }}
    so, if I'm not wrong, if you use the command like :copyroom model %idroom% you get your model.
    @Mackors I think it's secure, instead the query of insert is secure. But I think that I can do that in cache, but I don't know yet ahah. However, thank u :)
    Last edited by u20; 07-01-17 at 11:49 AM.

  5. #5
    Enthusiast Lex is offline
    MemberRank
    Dec 2016 Join Date
    26Posts

    Re: [Plus Emulator] Useful commands

    I've tried, but the copyfurni command doesn't work for me. My setflooritems has not that many arguments ( one less actually). What is your parameter definition for Setflooritem?

    (I didn't make one command of it, this is just the tutorial)

  6. #6
    Enthusiast u20 is offline
    MemberRank
    Sep 2016 Join Date
    26Posts

    Re: [Plus Emulator] Useful commands

    oh, yeah, I saw that in roomitemhandling there are two setflooritem (don't ask me why).

    One is that:
    Code:
    public bool SetFloorItem(Item Item, int newX, int newY, Double newZ)
    and the other is that
    Code:
    public bool SetFloorItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage, bool updateRoomUserStatuses = false, bool IgnoreUser = false)
    I just renamed the first setflooritem to setflooritem2 and then fixed the errors that I got. Remember that in the command you must use the setflooritem(gameclient session, item item..................................).

  7. #7
    Enthusiast Lex is offline
    MemberRank
    Dec 2016 Join Date
    26Posts

    Re: [Plus Emulator] Useful commands

    The copyroommodel command works fine for me (I've added an extra check (if room == null) sendwhisper room does not exist) and return).
    The copyroomfurni (that how I named it :P) doesn't work for me. The room reloads, but there are no furni in the room at all. There are also happening some strange things in the room that I want to copy (shuffling/disappearing furni).

    What could it be?

    To be sure: For instance, I want to copy the furni of room_id 5. I need to say the command in my own room with the room_id 5 right. Or do I have to stand in the room which I want to copy and say copyroom to roomID (my room ID)?

  8. #8
    Enthusiast u20 is offline
    MemberRank
    Sep 2016 Join Date
    26Posts

    Re: [Plus Emulator] Useful commands

    @Lex check your MySQL error logs. I think that you have some errors.
    Code:
         dbClient.SetQuery("INSERT INTO `items` (base_item,user_id,room_id,x,y,z,wall_pos,rot,extra_data,`limited_number`,`limited_stack`) VALUES (@did,@uid,@rid,@x,@y,@z, @WALl_pos, @rot, @eXtra_data, @Limited_number, @Limited_stack)");
                        dbClient.AddParameter("did", Item.BaseItem);
                        dbClient.AddParameter("uid", Session.GetHabbo().Id);
                        dbClient.AddParameter("rid", Session.GetHabbo().CurrentRoomId);
                        dbClient.AddParameter("x", Item.GetX);
                        dbClient.AddParameter("y", Item.GetY);
                        dbClient.AddParameter("z", Item.GetZ);
                        dbClient.AddParameter("wall_pos", Item.wallCoord);
                        dbClient.AddParameter("rot", Item.Rotation);
                        dbClient.AddParameter("extra_data", Item.ExtraData);
                        dbClient.AddParameter("limited_number", Item.LimitedNo);
                        dbClient.AddParameter("limited_stack", Item.LimitedTot);
                        Item.Id = Convert.ToInt32(dbClient.InsertQuery());
    This is the query. However, if you see some edits in your original room, reload it with unload command. You need to use your copyroomcommand in your new room :).

    I saw that some heights are strange when you use the command.. I'm looking to fix it

  9. #9
    Enthusiast Lex is offline
    MemberRank
    Dec 2016 Join Date
    26Posts

    Re: [Plus Emulator] Useful commands

    This is how my items table look like. I think that's the problem..
    Image - TinyPic - Gratis foto's delen en afbeeldingen & video's hosten

  10. #10
    Enthusiast Alexsander Lima is offline
    MemberRank
    Nov 2012 Join Date
    42Posts

    Re: [Plus Emulator] Useful commands

    Hello, the error says that: no overhead for the 'SetFloorItem' method accepts 10 arguments. How do I solve this?

  11. #11
    Member DJGOMEZV is offline
    MemberRank
    Mar 2013 Join Date
    56Posts

    Re: [Plus Emulator] Useful commands

    I saw that the code had some errors, here I leave the fixs with the sql to update the wallpaper and floor:


    CopyRoom.cs:


    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using Plus.HabboHotel.GameClients;
    using Plus.HabboHotel.Items;
    using Plus.Database.Interfaces;
    using Plus.Communication.Packets.Outgoing.Rooms.Session;
    
    
    namespace Plus.HabboHotel.Rooms.Chat.Commands.Administrator
    {
        class CopyRoom : IChatCommand
        {
            public string PermissionRequired
            {
                get { return "command_copyroom"; }
            }
    
    
            public string Parameters
            {
                get { return "%roomid%"; }
            }
    
    
            public string Description
            {
                get { return "Copia una stanza."; }
            }
    
    
            public void Execute(GameClient Session, Room Room, string[] Params)
            {
                if (Params.Length == 1)
                {
                    Session.SendWhisper("Inserisci l'ID della stanza!");
                    return;
                }
                Room _room = Session.GetHabbo().CurrentRoom;
                Room room = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(Convert.ToInt32(Params[1]));
                if (_room.GetRoomItemHandler().GetWallAndFloor.Count() > 0)
                {
                    Session.SendWhisper("Per poter copiare una stanza bisogna che in questa stanza non ci siano furni.");
                    return;
                }
                else if (_room.Model != room.Model)
                {
                    Session.SendWhisper("Non puoi copiare due stanze con model diversi. Digita :copiamodel %roomid% per copiarne il model");
                    return;
                }
                else
                {
                    Session.GetHabbo().copy = true;
                    foreach (Item item in room.GetRoomItemHandler().GetFloor)
                    {
                        _room.GetRoomItemHandler().SetFloorItem(Session, item, item.GetX, item.GetY, item.Rotation, true, false, false, false);
                    }
                    foreach (Item item2 in room.GetRoomItemHandler().GetWall)
                    {
                        _room.GetRoomItemHandler().SetWallItem(Session, item2);
                    }
                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.RunQuery("UPDATE `rooms` SET `wallpaper` = '" + room.Wallpaper + "', `floor` = '" + room.Floor + "' WHERE `id` = '" + Session.GetHabbo().CurrentRoomId + "' LIMIT 1");
                    }
                    List<RoomUser> UsersToReturn = Room.GetRoomUserManager().GetRoomUsers().ToList();
                    PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(_room, true);
                    PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(Room, true);
    
    
                    foreach (RoomUser User in UsersToReturn)
                    {
                        if (User == null || User.GetClient() == null)
                            continue;
                        User.GetClient().SendMessage(new RoomForwardComposer(_room.Id));
                    }
                }
                Session.GetHabbo().copy = false;
            }
        }
    }

    CopyModel.cs:


    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using Cloud.HabboHotel.GameClients;
    using Cloud.Database.Interfaces;
    using Cloud.Communication.Packets.Outgoing.Rooms.Session;
    
    
    namespace Cloud.HabboHotel.Rooms.Chat.Commands.Administrator
    {
        class CopyModel : IChatCommand
        {
            public string PermissionRequired
            {
                get { return "command_copyroom"; }
            }
    
    
            public string Parameters
            {
                get { return "%roomid%"; }
            }
    
    
            public string Description
            {
                get { return "Copia il model di una stana."; }
            }
    
    
    
    
            public void Execute(GameClient Session, Room Room, string[] Params)
            {
                if (Params.Length == 1)
                {
                    Session.SendWhisper("Inserisci l'ID della stanza!");
                    return;
                }
                Room _room = Session.GetHabbo().CurrentRoom;
                Room room = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(Convert.ToInt32(Params[1]));
    
    
    
    
                if (_room.Model != room.Model)
                {
                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("UPDATE rooms SET model_name = @model WHERE id = @id LIMIT 1;");
                        dbClient.AddParameter("model", room.ModelName);
                        dbClient.AddParameter("id", _room.Id);
                        dbClient.RunQuery();
                    }
                }
                PlusEnvironment.GetGame().GetRoomManager().GetModel(room.ModelName);
                List<RoomUser> UsersToReturn = Room.GetRoomUserManager().GetRoomUsers().ToList();
                PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(_room, true);
                PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(Room, true);
    
    
                foreach (RoomUser User in UsersToReturn)
                {
                    if (User == null || User.GetClient() == null)
                        continue;
    
    
    
    
                    User.GetClient().SendMessage(new RoomForwardComposer(_room.Id));
                }
    
    
    
    
            }
        }
    }

    RoomItemHandling.cs:
    Code:
                if (!Session.GetHabbo().copy) 
    			using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `items` SET `room_id` = '" + _room.RoomId + "', `x` = '" + Item.GetX + "', `y` = '" + Item.GetY + "', `z` = '" + Item.GetZ + "', `rot` = '" + Item.Rotation + "' WHERE `id` = '" + Item.Id + "' LIMIT 1");
                }
                else
                {
                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("INSERT INTO `items` (user_id,room_id,base_item,x,y,z,wall_pos,rot,extra_data,limited_number,limited_stack) VALUES (@uid,@rid,@did,@x,@y,@z @WALl_pos @rot @eXtra_data @Limited_number @Limited_stack)");
                        dbClient.AddParameter("did", Item.BaseItem);
                        dbClient.AddParameter("uid", Session.GetHabbo().Id);
                        dbClient.AddParameter("rid", Session.GetHabbo().CurrentRoomId);
                        dbClient.AddParameter("x", Item.GetX);
                        dbClient.AddParameter("y", Item.GetY);
                        dbClient.AddParameter("z", Item.GetZ);
                        dbClient.AddParameter("wall_pos", Item.wallCoord);
                        dbClient.AddParameter("rot", Item.Rotation);
                        dbClient.AddParameter("extra_data", Item.ExtraData);
                        dbClient.AddParameter("limited_number", Item.LimitedNo);
                        dbClient.AddParameter("limited_stack", Item.LimitedTot);
                        Item.Id = Convert.ToInt32(dbClient.InsertQuery());
                    }
                }

  12. #12
    Enthusiast Leon Retro is offline
    MemberRank
    Dec 2014 Join Date
    43Posts

    Re: [Plus Emulator] Useful commands


    @u20, how do I fix this?



Advertisement