[Plus Emulator] Command Erase Chatlog

Marko97

M97 Project based Plus EMU
Aug 7, 2013
99
45
Hi,
Today I will share with you a mini command made by me.
This command perform the erase for chatlogs.

1. Go to HabboHotel/Rooms/Chat/Commands/Administrator and create a new class called: EraseChatlogCommand.cs and paste this:
Code:
using Plus.HabboHotel.GameClients;
using Plus.Database.Interfaces;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Administrator
{
    class EraseChatlogCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_erasechatlog"; }
        }

        public string Parameters
        {
            get { return ""; }
        }

        public string Description
        {
            get { return "Erase the chatlog."; }
        }

        public void Execute(GameClient Session, Room Room, string[] Params)
        {
            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("TRUNCATE chatlogs");
            }

            Session.SendNotification("Chatlog erased.");
        }
    }
}

2. Go to HabboHotel/Rooms/Chat/Commands/CommandManager.cs and after
Code:
this.Register("update", new UpdateCommand());
add this:
Code:
this.Register("erasechatlog", new EraseChatlogCommand());
:
3. In your database run this MySQL Query:
Code:
INSERT INTO `permissions_commands` (`command`, `group_id`, `subscription_id`) VALUES ('command_erasechatlog', '1', '1');
Note: You can change the rank and Vip rank modifying '1' (Rank), '1' (Vip rank) at your leisure.

Done! To launch the command use :erasechatlog.

IF YOU WANT DELETE ONLY ROOM MESSAGGES YOU CAN FOLLOW THIS:

1. Go to HabboHotel/Rooms/Chat/Commands/Administrator and create a new class called: EraseRoomChatlogCommand.cs and paste this:
Code:
using Plus.HabboHotel.GameClients;
using Plus.Database.Interfaces;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Administrator
{
    class EraseRoomChatlogCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_eraseroomchatlog"; }
        }

        public string Parameters
        {
            get { return ""; }
        }

        public string Description
        {
            get { return "Erase the room chatlog."; }
        }

        public void Execute(GameClient Session, Room Room, string[] Params)
        {
            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("DELETE FROM `chatlogs` WHERE `room_id` = @RoomId");
                dbClient.AddParameter("RoomId", Session.GetHabbo().CurrentRoom.Id);
                dbClient.RunQuery();
            }

            Session.SendNotification("All messagges in " + Session.GetHabbo().CurrentRoom.Name + "'s room have been deleted.");
        }
    }
}
2. Go to HabboHotel/Rooms/Chat/Commands/CommandManager.cs and after
Code:
this.Register("update", new UpdateCommand());
add this:
Code:
this.Register("eraseroomchatlog", new EraseRoomChatlogCommand());
3. In your database run this MySQL Query:
Code:
INSERT INTO `permissions_commands` (`command`, `group_id`, `subscription_id`) VALUES ('command_eraseroomchatlog', '1', '1');
Note: You can change the rank and Vip rank modifying '1' (Rank), '1' (Vip rank) at your leisure.
 
Last edited:

Txc

Member
Jan 26, 2017
84
45
The concept is nice but I feel like its a low quality command. Instead of truncating the chatlogs completely, it'd be better if you coded it to erase the chatlogs of the current room. I probably won't use this because I have no use for it but always nice to see people making contributions.
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,199
3,934
A larger hotel would suffer if a staff member decided to use this. Maybe per room basis would work better.

Nice share though nonetheless.
 

Mystical

Member
Feb 13, 2018
63
16
Would reccomend using this when 0 users are online. As it seems like it would lag out the hotel pretty badly.
 

Marko97

M97 Project based Plus EMU
Aug 7, 2013
99
45
The concept is nice but I feel like its a low quality command. Instead of truncating the chatlogs completely, it'd be better if you coded it to erase the chatlogs of the current room. I probably won't use this because I have no use for it but always nice to see people making contributions.
1. Go to HabboHotel/Rooms/Chat/Commands/Administrator and create a new class called: EraseRoomChatlogCommand.cs and paste this:
Code:
using Plus.HabboHotel.GameClients;
using Plus.Database.Interfaces;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Administrator
{
    class EraseRoomChatlogCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_eraseroomchatlog"; }
        }

        public string Parameters
        {
            get { return ""; }
        }

        public string Description
        {
            get { return "Erase the room chatlog."; }
        }

        public void Execute(GameClient Session, Room Room, string[] Params)
        {
            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("DELETE FROM `chatlogs` WHERE `room_id` = @RoomId");
                dbClient.AddParameter("RoomId", Session.GetHabbo().CurrentRoom.Id);
                dbClient.RunQuery();
            }

            Session.SendNotification("All messagges in " + Session.GetHabbo().CurrentRoom.Name + "'s room have been deleted.");
        }
    }
}
2. Go to HabboHotel/Rooms/Chat/Commands/CommandManager.cs and after
Code:
this.Register("update", new UpdateCommand());
add this:
Code:
this.Register("eraseroomchatlog", new EraseRoomChatlogCommand());
3. In your database run this MySQL Query:
Code:
INSERT INTO `permissions_commands` (`command`, `group_id`, `subscription_id`) VALUES ('command_eraseroomchatlog', '1', '1');
Note: You can change the rank and Vip rank modifying '1' (Rank), '1' (Vip rank) at your leisure.
 

JynX

Posting Freak
Feb 6, 2016
710
438
1. Go to HabboHotel/Rooms/Chat/Commands/Administrator and create a new class called: EraseRoomChatlogCommand.cs and paste this:
Code:
using Plus.HabboHotel.GameClients;
using Plus.Database.Interfaces;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Administrator
{
    class EraseRoomChatlogCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_eraseroomchatlog"; }
        }

        public string Parameters
        {
            get { return ""; }
        }

        public string Description
        {
            get { return "Erase the room chatlog."; }
        }

        public void Execute(GameClient Session, Room Room, string[] Params)
        {
            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("DELETE FROM `chatlogs` WHERE `room_id` = @RoomId");
                dbClient.AddParameter("RoomId", Session.GetHabbo().CurrentRoom.Id);
                dbClient.RunQuery();
            }

            Session.SendNotification("All messagges in " + Session.GetHabbo().CurrentRoom.Name + "'s room have been deleted.");
        }
    }
}
2. Go to HabboHotel/Rooms/Chat/Commands/CommandManager.cs and after
Code:
this.Register("update", new UpdateCommand());
add this:
Code:
this.Register("eraseroomchatlog", new EraseRoomChatlogCommand());
3. In your database run this MySQL Query:
Code:
INSERT INTO `permissions_commands` (`command`, `group_id`, `subscription_id`) VALUES ('command_eraseroomchatlog', '1', '1');
Note: You can change the rank and Vip rank modifying '1' (Rank), '1' (Vip rank) at your leisure.
Just out of preference you could just use the "Room" variable that is passed to the execute function instead of doing Session.GetHabbo().CurrentRoom.Name.
 

ZaneyRetros

i am dead
Jul 27, 2015
211
105
This would be useful for smaller hotels with 6-7 users, however for Habboon or other large hotels this wouldn't be used as in Habboon there is a lot of support tickets coming in at once, would be better if it was made if you could say something like :erase 50, therefore it would erase 50 messages within that room only. If not you could make it something like :erase all, therefore it would erase all the messages in the room you're in.

Many Regards,
Zane
 

Marko97

M97 Project based Plus EMU
Aug 7, 2013
99
45
This would be useful for smaller hotels with 6-7 users, however for Habboon or other large hotels this wouldn't be used as in Habboon there is a lot of support tickets coming in at once, would be better if it was made if you could say something like :erase 50, therefore it would erase 50 messages within that room only. If not you could make it something like :erase all, therefore it would erase all the messages in the room you're in.

Many Regards,
Zane
You can edit this query
Code:
dbClient.SetQuery("DELETE FROM `chatlogs` WHERE `room_id` = @RoomId");
with this:
Code:
dbClient.SetQuery("DELETE FROM `chatlogs` WHERE `room_id` = @RoomId LIMIT 50 ORDER BY `timestamp`");
For example, if you want delete only last 50 messages write LIMIT 50 else if you want delete only last 100 messages write LIMIT 100.
 

ZaneyRetros

i am dead
Jul 27, 2015
211
105
You can edit this query
Code:
dbClient.SetQuery("DELETE FROM `chatlogs` WHERE `room_id` = @RoomId");
with this:
Code:
dbClient.SetQuery("DELETE FROM `chatlogs` WHERE `room_id` = @RoomId LIMIT 50 ORDER BY `timestamp`");
For example, if you want delete only last 50 messages write LIMIT 50 else if you want delete only last 100 messages write LIMIT 100.

Thank you, sorry for the late reply have been busy.

Many Regards,
Zane
 

Users who are viewing this thread

Top