[PLUS Emu] Mimic Command target user offline

Marko97

M97 Project based Plus EMU
Aug 7, 2013
99
45
Hello!
I've remade the mimic command to work also the target user is offline.

Go in the class MimicCommand.cs and replace all with:
Code:
using System;
using Plus.Communication.Packets.Outgoing.Rooms.Engine;
using Plus.Database.Interfaces;
using Plus.Communication.Packets.Outgoing.Rooms.Avatar;
using System.Data;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
    class MimicCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_mimic"; }
        }

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

        public string Description
        {
            get { return "Copia il look dell'utente."; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Choose the user which you want copy the look.", 34);
                return;
            }

            DataRow UserData = null;
            string Username = Params[1];

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `look`,`gender`,`allow_mimic` FROM users WHERE `username` = @Username LIMIT 1");
                dbClient.AddParameter("Username", Username);
                UserData = dbClient.GetRow();
            }

            if (UserData == null)
            {
                Session.SendWhisper("User not exists.", 34);
                return;
            }

            var TargetAllowMimic = Convert.ToInt32(UserData["allow_mimic"]);
            var TargetGender = Convert.ToString(UserData["gender"]);
            var TargetLook = Convert.ToString(UserData["look"]);

            if (TargetAllowMimic == 0)
            {
                Session.SendWhisper("You can't copy this look because the target user doesn't authorize it.", 34);
                return;
            }

            Session.GetHabbo().Gender = TargetGender;
            Session.GetHabbo().Look = TargetLook;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `users` SET `gender` = @gender, `look` = @look WHERE `id` = @id LIMIT 1");
                dbClient.AddParameter("gender", TargetGender);
                dbClient.AddParameter("look", TargetLook);
                dbClient.AddParameter("id", Session.GetHabbo().Id);
                dbClient.RunQuery();
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (User != null)
            {
                Session.SendPacket(new AvatarAspectUpdateComposer(Session.GetHabbo().Look, Session.GetHabbo().Gender));
                Session.SendPacket(new UserChangeComposer(User, true));
                Room.SendPacket(new UserChangeComposer(User, false));
            }
        }
    }
}

Credits:
Creator of this class for the command, me for remade the command.
 

Joe

Well-Known Member
Jun 10, 2012
4,170
1,954
Never mind, I fixed it. Changed SendPacket to SendMessage and changed GetRow to getRow.

Code:
using System;
using Plus.Communication.Packets.Outgoing.Rooms.Engine;
using Plus.Database.Interfaces;
using Plus.Communication.Packets.Outgoing.Rooms.Avatar;
using System.Data;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
    class MimicCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_mimic"; }
        }

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

        public string Description
        {
            get { return "Copia il look dell'utente."; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Choose the user which you want copy the look.", 34);
                return;
            }

            DataRow UserData = null;
            string Username = Params[1];

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `look`,`gender`,`allow_mimic` FROM users WHERE `username` = @Username LIMIT 1");
                dbClient.AddParameter("Username", Username);
                UserData = dbClient.getRow();
            }

            if (UserData == null)
            {
                Session.SendWhisper("User not exists.", 34);
                return;
            }

            var TargetAllowMimic = Convert.ToInt32(UserData["allow_mimic"]);
            var TargetGender = Convert.ToString(UserData["gender"]);
            var TargetLook = Convert.ToString(UserData["look"]);

            if (TargetAllowMimic == 0)
            {
                Session.SendWhisper("You can't copy this look because the target user doesn't authorize it.", 34);
                return;
            }

            Session.GetHabbo().Gender = TargetGender;
            Session.GetHabbo().Look = TargetLook;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `users` SET `gender` = @gender, `look` = @look WHERE `id` = @id LIMIT 1");
                dbClient.AddParameter("gender", TargetGender);
                dbClient.AddParameter("look", TargetLook);
                dbClient.AddParameter("id", Session.GetHabbo().Id);
                dbClient.RunQuery();
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (User != null)
            {
                Session.SendMessage(new AvatarAspectUpdateComposer(Session.GetHabbo().Look, Session.GetHabbo().Gender));
                Session.SendMessage(new UserChangeComposer(User, true));
                Room.SendMessage(new UserChangeComposer(User, false));
            }
        }
    }
}
 

yoyok

Member
Apr 24, 2013
197
24
It would be better if there is also a check for rank 3/4 and higher to not allow the users for copying a staff member his look.
 

Blasteh

big tits
Apr 3, 2013
1,156
521
It would be better if there is also a check for rank 3/4 and higher to not allow the users for copying a staff member his look.
As JMG said, :disablemimic would work, but for instance, you could just modify this to be something like :supermimic and make it for staff / VIP users. That is personally what I'm going to be doing.
 

Joe

Well-Known Member
Jun 10, 2012
4,170
1,954
As JMG said, :disablemimic would work, but for instance, you could just modify this to be something like :supermimic and make it for staff / VIP users. That is personally what I'm going to be doing.
Not sure what's wrong with allowing everybody to be able to mimic people whether they're offline or not.

Obviously people who don't want to be choose to turn theirs off.
 

Users who are viewing this thread

Top