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 Emulator] Useful commands

u20

Newbie Spellweaver
Joined
Sep 27, 2016
Messages
26
Reaction score
5
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:
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 @[I][B][URL="http://forum.ragezone.com/members/1333411810.html"]WAL[/URL][/B][/I]l_pos @[I][B][URL="http://forum.ragezone.com/members/2000143930.html"]rot[/URL][/B][/I] @[I][B][URL="http://forum.ragezone.com/members/424837.html"]eXtra[/URL][/B][/I]_data, @[I][B][URL="http://forum.ragezone.com/members/1333415425.html"]Limited[/URL][/B][/I]_number, @[I][B][URL="http://forum.ragezone.com/members/1333415425.html"]Limited[/URL][/B][/I]_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
:laugh:.

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 = @[I][B][URL="http://forum.ragezone.com/members/1333478952.html"]model[/URL][/B][/I] WHERE id = @[I][B][URL="http://forum.ragezone.com/members/19862.html"]id[/URL][/B][/I] LIMIT 1;");
                    dbClient.AddParameter( @[I][B][URL="http://forum.ragezone.com/members/1333478952.html"]model[/URL][/B][/I]", room.ModelName);
                    dbClient.AddParameter( @[I][B][URL="http://forum.ragezone.com/members/19862.html"]id[/URL][/B][/I]", _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

d0d7f5fc9db6ae20e8087da1ec30499f - [Plus Emulator] Useful commands - RaGEZONE Forums

The id is 13112, then I go in my room and copy the model:
765ad429d777a6031fbdabe059897353 - [Plus Emulator] Useful commands - RaGEZONE Forums

and, finally, I use the copy command, and the result is that:
2b953813901b69f7009bcf15e6921fc9 - [Plus Emulator] Useful commands - RaGEZONE Forums
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!
 

Attachments

You must be registered for see attachments list
Last edited:
Junior Spellweaver
Joined
Aug 25, 2016
Messages
100
Reaction score
15
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.
 

Lex

Newbie Spellweaver
Joined
Dec 3, 2016
Messages
26
Reaction score
3
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:

u20

Newbie Spellweaver
Joined
Sep 27, 2016
Messages
26
Reaction score
5
@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 = @[URL="http://forum.ragezone.com/members/1333478952.html"]model[/URL] WHERE id = @[URL="http://forum.ragezone.com/members/19862.html"]id[/URL] LIMIT 1;");
                    dbClient.AddParameter("@[URL="http://forum.ragezone.com/members/1333478952.html"]model[/URL]", room.ModelName);
                    dbClient.AddParameter("@[URL="http://forum.ragezone.com/members/19862.html"]id[/URL]", _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:

Lex

Newbie Spellweaver
Joined
Dec 3, 2016
Messages
26
Reaction score
3
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)
 

u20

Newbie Spellweaver
Joined
Sep 27, 2016
Messages
26
Reaction score
5
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..................................).
 

Lex

Newbie Spellweaver
Joined
Dec 3, 2016
Messages
26
Reaction score
3
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)?
 

u20

Newbie Spellweaver
Joined
Sep 27, 2016
Messages
26
Reaction score
5
@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, @[URL="http://forum.ragezone.com/members/1333411810.html"]WAL[/URL]l_pos, @[URL="http://forum.ragezone.com/members/2000143930.html"]rot[/URL], @[URL="http://forum.ragezone.com/members/424837.html"]eXtra[/URL]_data, @[URL="http://forum.ragezone.com/members/1333415425.html"]Limited[/URL]_number, @[URL="http://forum.ragezone.com/members/1333415425.html"]Limited[/URL]_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
 

Lex

Newbie Spellweaver
Joined
Dec 3, 2016
Messages
26
Reaction score
3
This is how my items table look like. I think that's the problem..
 
Newbie Spellweaver
Joined
Nov 29, 2012
Messages
42
Reaction score
4
Hello, the error says that: no overhead for the 'SetFloorItem' method accepts 10 arguments. How do I solve this?
OkHFWnB - [Plus Emulator] Useful commands - RaGEZONE Forums
 

Attachments

You must be registered for see attachments list
Newbie Spellweaver
Joined
Mar 22, 2013
Messages
56
Reaction score
9
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 = [USER=1333478952]model[/USER] WHERE id = [USER=19862]id[/USER] 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 [USER=1333411810]WAL[/USER]l_pos [USER=2000143930]rot[/USER] [USER=424837]eXtra[/USER]_data [USER=1333415425]Limited[/USER]_number [USER=1333415425]Limited[/USER]_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());
                }
            }
 
Newbie Spellweaver
Joined
Dec 9, 2014
Messages
43
Reaction score
1
f85435845cde4c78f2ffb0bf8222fa89 - [Plus Emulator] Useful commands - RaGEZONE Forums

u20, how do I fix this?
 

Attachments

You must be registered for see attachments list
Back
Top