示例#1
0
        /// <summary>
        ///     Called when [new friendship].
        /// </summary>
        /// <param name="friendId">The friend identifier.</param>
        internal void OnNewFriendship(uint friendId)
        {
            GameClient clientByUserId = Yupi.GetGame().GetClientManager().GetClientByUserId(friendId);

            MessengerBuddy messengerBuddy;

            if (clientByUserId?.GetHabbo() == null)
            {
                using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    queryReactor.SetQuery($"SELECT id,username,motto,look,last_online,hide_inroom,hide_online FROM users WHERE id = {friendId}");

                    DataRow row = queryReactor.GetRow();

                    messengerBuddy = new MessengerBuddy(friendId, (string)row["username"], (string)row["look"], (string)row["motto"], Yupi.EnumToBool(row["hide_online"].ToString()), Yupi.EnumToBool(row["hide_inroom"].ToString()));
                }
            }
            else
            {
                Habbo habbo = clientByUserId.GetHabbo();

                messengerBuddy = new MessengerBuddy(friendId, habbo.UserName, habbo.Look, habbo.Motto, habbo.AppearOffline, habbo.HideInRoom);

                messengerBuddy.UpdateUser();
            }

            if (!Friends.ContainsKey(friendId))
            {
                Friends.Add(friendId, messengerBuddy);
            }

            GetClient().SendMessage(SerializeUpdate(messengerBuddy));
        }
示例#2
0
        internal void OnNewFriendship(uint friendID)
        {
            GameClient     clientByUserID = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(friendID);
            MessengerBuddy messengerBuddy;

            if (clientByUserID == null || clientByUserID.GetHabbo() == null)
            {
                DataRow row;
                using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    queryreactor.setQuery("SELECT id,username,motto,look,last_online,hide_inroom,hide_online FROM users WHERE id = " + friendID);
                    row = queryreactor.getRow();
                }
                messengerBuddy = new MessengerBuddy(friendID, (string)row["username"], (string)row["look"], (string)row["motto"], (int)row["last_online"], CyberEnvironment.EnumToBool(row["hide_online"].ToString()), CyberEnvironment.EnumToBool(row["hide_inroom"].ToString()));
            }
            else
            {
                Habbo habbo = clientByUserID.GetHabbo();
                messengerBuddy = new MessengerBuddy(friendID, habbo.Username, habbo.Look, habbo.Motto, 0, habbo.AppearOffline, habbo.HideInRoom);
                messengerBuddy.UpdateUser(clientByUserID);
            }
            if (!this.friends.ContainsKey(friendID))
            {
                this.friends.Add(friendID, messengerBuddy);
            }
            this.GetClient().SendMessage(this.SerializeUpdate(messengerBuddy));
        }
示例#3
0
        internal ServerMessage SerializeUpdate(MessengerBuddy friend)
        {
            ServerMessage serverMessage = new ServerMessage(Outgoing.FriendUpdateMessageComposer);

            serverMessage.AppendInt32(0);
            serverMessage.AppendInt32(1);
            serverMessage.AppendInt32(0);
            friend.Serialize(serverMessage, this.GetClient());
            serverMessage.AppendBoolean(false);
            return(serverMessage);
        }
示例#4
0
        /// <summary>
        ///     Serializes the update.
        /// </summary>
        /// <param name="friend">The friend.</param>
        /// <returns>ServerMessage.</returns>
        internal ServerMessage SerializeUpdate(MessengerBuddy friend)
        {
            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("FriendUpdateMessageComposer"));

            serverMessage.AppendInteger(0);
            serverMessage.AppendInteger(1);
            serverMessage.AppendInteger(0);
            friend.Serialize(serverMessage, GetClient());
            serverMessage.AppendBool(false);

            return(serverMessage);
        }
        public FriendListUpdateComposer(GameClient Session, MessengerBuddy Buddy)
            : base(ServerPacketHeader.FriendListUpdateMessageComposer)
        {
            WriteInteger(1);            //Category Count
            WriteInteger(1);
            WriteString("Grupos");
            WriteInteger(1);            //Updates Count
            WriteInteger(0);            //Update

            Relationship Relationship = Session.GetHabbo().Relationships.FirstOrDefault(x => x.Value.UserId == Convert.ToInt32(Buddy.UserId)).Value;
            int          y            = Relationship == null ? 0 : Relationship.Type;

            WriteInteger(Buddy.UserId);
            WriteString(Buddy.mUsername);
            WriteInteger(1);
            if (!Buddy.mAppearOffline || Session.GetHabbo().GetPermissions().HasRight("mod_tool"))
            {
                WriteBoolean(Buddy.IsOnline);
            }
            else
            {
                WriteBoolean(false);
            }

            if (!Buddy.mHideInroom || Session.GetHabbo().GetPermissions().HasRight("mod_tool"))
            {
                WriteBoolean(Buddy.InRoom);
            }
            else
            {
                WriteBoolean(false);
            }

            WriteString(Buddy.mLook);    //Habbo.IsOnline ? Habbo.Look : "");
            WriteInteger(0);             // categoryid
            WriteString(Buddy.mMotto);
            WriteString(string.Empty);   // Facebook username
            WriteString(string.Empty);
            WriteBoolean(true);          // Allows offline messaging
            WriteBoolean(false);         // ?
            WriteBoolean(false);         // Uses phone
            WriteShort(y);
        }
示例#6
0
 public FriendListUpdateComposer(Habbo habbo, MessengerBuddy Buddy)
     : base(ServerPacketHeader.FriendListUpdateMessageComposer)
 {
     this.Habbo = habbo;
     this.Buddy = Buddy;
 }
示例#7
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().GetMessenger() == null)
            {
                return;
            }

            int User = Packet.PopInt();
            int Type = Packet.PopInt();

            if (!Session.GetHabbo().GetMessenger().FriendshipExists(User))
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Ops, você só pode estabelecer um relacionamento aonde existe uma amizade."));
                return;
            }

            if (Type < 0 || Type > 3)
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Ops, você escolheu um relacionamento invalido."));
                return;
            }

            if (Session.GetHabbo().Relationships.Count > 2000)
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Sentimos muito, esta limitado a 2000 relacionamenos."));
                return;
            }

            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                if (Type == 0)
                {
                    dbClient.SetQuery("SELECT `id` FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    int Id = dbClient.getInteger();

                    dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    dbClient.RunQuery();

                    if (Session.GetHabbo().Relationships.ContainsKey(User))
                    {
                        Session.GetHabbo().Relationships.Remove(User);
                    }
                }
                else
                {
                    dbClient.SetQuery("SELECT id FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    int Id = dbClient.getInteger();

                    if (Id > 0)
                    {
                        dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                        dbClient.AddParameter("target", User);
                        dbClient.RunQuery();

                        if (Session.GetHabbo().Relationships.ContainsKey(Id))
                        {
                            Session.GetHabbo().Relationships.Remove(Id);
                        }
                    }

                    dbClient.SetQuery("INSERT INTO `user_relationships` (`user_id`,`target`,`type`) VALUES ('" + Session.GetHabbo().Id + "', @target, @type)");
                    dbClient.AddParameter("target", User);
                    dbClient.AddParameter("type", Type);
                    int newId = Convert.ToInt32(dbClient.InsertQuery());

                    if (!Session.GetHabbo().Relationships.ContainsKey(User))
                    {
                        Session.GetHabbo().Relationships.Add(User, new Relationship(newId, User, Type));
                    }
                }

                GameClient Client = CloudServer.GetGame().GetClientManager().GetClientByUserID(User);
                if (Client != null)
                {
                    Session.GetHabbo().GetMessenger().UpdateFriend(User, Client, true);
                }
                else
                {
                    Habbo Habbo = CloudServer.GetHabboById(User);
                    if (Habbo != null)
                    {
                        MessengerBuddy Buddy = null;
                        if (Session.GetHabbo().GetMessenger().TryGetFriend(User, out Buddy))
                        {
                            Session.SendMessage(new FriendListUpdateComposer(Session, Buddy));
                        }
                    }
                }
            }
        }
示例#8
0
        /// <summary>
        /// Loads bot friendships
        /// </summary>
        internal void LoadBotFriendships()
        {
            BotFriendShips = new ConcurrentDictionary <int, RoleplayBot>();

            DataTable BotFriends = null;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `bot_id` FROM `rp_bots_friendships` WHERE `user_id` = '" + Client.GetHabbo().Id + "'");
                BotFriends = dbClient.getTable();

                if (BotFriends == null)
                {
                    return;
                }

                foreach (DataRow BotUser in BotFriends.Rows)
                {
                    int BotId = Convert.ToInt32(BotUser["bot_id"]);

                    RoleplayBot Botfriend = RoleplayBotManager.GetCachedBotById(BotId);

                    if (Botfriend == null)
                    {
                        return;
                    }

                    MessengerBuddy newfriend = new MessengerBuddy(Botfriend.Id + RoleplayBotManager.BotFriendMultiplyer,
                                                                  Botfriend.Name,
                                                                  Botfriend.Figure,
                                                                  Botfriend.Motto, 0, false, true, true);

                    int addid = Botfriend.Id + RoleplayBotManager.BotFriendMultiplyer;

                    if (Client.GetHabbo() == null)
                    {
                        return;
                    }

                    if (Client.GetHabbo().GetMessenger() == null)
                    {
                        return;
                    }

                    if (Client.GetHabbo().GetMessenger()._friends == null)
                    {
                        return;
                    }

                    if (!Client.GetHabbo().GetMessenger()._friends.ContainsKey(addid))
                    {
                        Client.GetHabbo().GetMessenger()._friends.Add(addid, newfriend);
                    }

                    if (!BotFriendShips.ContainsKey(Botfriend.Id))
                    {
                        BotFriendShips.TryAdd(Botfriend.Id, Botfriend);
                    }

                    Client.SendMessage(Client.GetHabbo().GetMessenger().SerializeUpdate(newfriend));
                }
            }
        }
示例#9
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (session == null || session.GetHabbo() == null || session.GetHabbo().GetMessenger() == null)
            {
                return;
            }

            var user = packet.PopInt();
            var type = packet.PopInt();

            if (!session.GetHabbo().GetMessenger().FriendshipExists(user))
            {
                session.SendPacket(new BroadcastMessageAlertComposer("Oops, you can only set a relationship where a friendship exists."));
                return;
            }

            if (type < 0 || type > 3)
            {
                session.SendPacket(new BroadcastMessageAlertComposer("Oops, you've chosen an invalid relationship type."));
                return;
            }

            if (session.GetHabbo().Relationships.Count > 2000)
            {
                session.SendPacket(new BroadcastMessageAlertComposer("Sorry, you're limited to a total of 2000 relationships."));
                return;
            }

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                if (type == 0)
                {
                    dbClient.SetQuery("SELECT `id` FROM `user_relationships` WHERE `user_id` = '" + session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", user);
                    var id = dbClient.GetInteger();

                    dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", user);
                    dbClient.RunQuery();

                    if (session.GetHabbo().Relationships.ContainsKey(user))
                    {
                        session.GetHabbo().Relationships.Remove(user);
                    }
                }
                else
                {
                    dbClient.SetQuery("SELECT `id` FROM `user_relationships` WHERE `user_id` = '" + session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", user);
                    var id = dbClient.GetInteger();

                    if (id > 0)
                    {
                        dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                        dbClient.AddParameter("target", user);
                        dbClient.RunQuery();

                        if (session.GetHabbo().Relationships.ContainsKey(id))
                        {
                            session.GetHabbo().Relationships.Remove(id);
                        }
                    }

                    dbClient.SetQuery("INSERT INTO `user_relationships` (`user_id`,`target`,`type`) VALUES ('" + session.GetHabbo().Id + "', @target, @type)");
                    dbClient.AddParameter("target", user);
                    dbClient.AddParameter("type", type);
                    var newId = Convert.ToInt32(dbClient.InsertQuery());

                    if (!session.GetHabbo().Relationships.ContainsKey(user))
                    {
                        session.GetHabbo().Relationships.Add(user, new Relationship(newId, user, type));
                    }
                }

                var client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(user);
                if (client != null)
                {
                    session.GetHabbo().GetMessenger().UpdateFriend(user, client, true);
                }
                else
                {
                    var habbo = PlusEnvironment.GetHabboById(user);
                    if (habbo != null)
                    {
                        MessengerBuddy buddy = null;
                        if (session.GetHabbo().GetMessenger().TryGetFriend(user, out buddy))
                        {
                            session.SendPacket(new FriendListUpdateComposer(session, buddy));
                        }
                    }
                }
            }
        }
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().GetMessenger() == null)
            {
                return;
            }

            int User = Packet.PopInt();
            int Type = Packet.PopInt();

            if (!Session.GetHabbo().GetMessenger().FriendshipExists(User))
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Oeps! Je kunt alleen vrienden toevoegen aan je relatie status."));
                return;
            }

            if (Type < 0 || Type > 3)
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Oeps! Er een onbekende fout opgetreden bij het kiezen van een relatie status."));
                return;
            }

            if (Session.GetHabbo().Relationships.Count > 2000)
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Oeps! Je hebt het relatie status limiet overstreden (2000)."));
                return;
            }

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                if (Type == 0)
                {
                    dbClient.SetQuery("SELECT `id` FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    int Id = dbClient.getInteger();

                    dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    dbClient.RunQuery();

                    if (Session.GetHabbo().Relationships.ContainsKey(User))
                    {
                        Session.GetHabbo().Relationships.Remove(User);
                    }
                }
                else
                {
                    dbClient.SetQuery("SELECT id FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    int Id = dbClient.getInteger();

                    if (Id > 0)
                    {
                        dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                        dbClient.AddParameter("target", User);
                        dbClient.RunQuery();

                        if (Session.GetHabbo().Relationships.ContainsKey(Id))
                        {
                            Session.GetHabbo().Relationships.Remove(Id);
                        }
                    }

                    dbClient.SetQuery("INSERT INTO `user_relationships` (`user_id`,`target`,`type`) VALUES ('" + Session.GetHabbo().Id + "', @target, @type)");
                    dbClient.AddParameter("target", User);
                    dbClient.AddParameter("type", Type);
                    int newId = Convert.ToInt32(dbClient.InsertQuery());
                    QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RelatieStatus", 1);

                    if (!Session.GetHabbo().Relationships.ContainsKey(User))
                    {
                        Session.GetHabbo().Relationships.Add(User, new Relationship(newId, User, Type));
                    }
                }

                GameClient Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(User);
                if (Client != null)
                {
                    Session.GetHabbo().GetMessenger().UpdateFriend(User, Client, true);
                }
                else
                {
                    Habbo Habbo = QuasarEnvironment.GetHabboById(User);
                    if (Habbo != null)
                    {
                        MessengerBuddy Buddy = null;
                        if (Session.GetHabbo().GetMessenger().TryGetFriend(User, out Buddy))
                        {
                            Session.SendMessage(new FriendListUpdateComposer(Session, Buddy));
                        }
                    }
                }
            }
        }
示例#11
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().GetMessenger() == null)
            {
                return;
            }

            int User = Packet.PopInt();
            int Type = Packet.PopInt();

            if (!Session.GetHabbo().GetMessenger().FriendshipExists(User))
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Oops, you can only set a relationship where a friendship exists."));
                return;
            }

            if (Type < 0 || Type > 3)
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Oops, you've chosen an invalid relationship type."));
                return;
            }

            if (Session.GetHabbo().Relationships.Count > 2000)
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Sorry, you're limited to a total of 2000 relationships."));
                return;
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                if (Type == 0)
                {
                    dbClient.SetQuery("SELECT `id` FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    int Id = dbClient.getInteger();

                    dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    dbClient.RunQuery();

                    if (Session.GetHabbo().Relationships.ContainsKey(User))
                    {
                        Session.GetHabbo().Relationships.Remove(User);
                    }
                }
                else
                {
                    dbClient.SetQuery("SELECT id FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    int Id = dbClient.getInteger();

                    if (Id > 0)
                    {
                        dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                        dbClient.AddParameter("target", User);
                        dbClient.RunQuery();

                        if (Session.GetHabbo().Relationships.ContainsKey(Id))
                        {
                            Session.GetHabbo().Relationships.Remove(Id);
                        }
                    }

                    dbClient.SetQuery("INSERT INTO `user_relationships` (`user_id`,`target`,`type`) VALUES ('" + Session.GetHabbo().Id + "', @target, @type)");
                    dbClient.AddParameter("target", User);
                    dbClient.AddParameter("type", Type);
                    int newId = Convert.ToInt32(dbClient.InsertQuery());

                    if (!Session.GetHabbo().Relationships.ContainsKey(User))
                    {
                        Session.GetHabbo().Relationships.Add(User, new Relationship(newId, User, Type));
                    }
                }

                GameClient Client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(User);
                if (Client != null)
                {
                    Session.GetHabbo().GetMessenger().UpdateFriend(User, Client, true);
                }
                else
                {
                    Habbo Habbo = PlusEnvironment.GetHabboById(User);
                    if (Habbo != null)
                    {
                        MessengerBuddy Buddy = null;
                        if (Session.GetHabbo().GetMessenger().TryGetFriend(User, out Buddy))
                        {
                            Session.SendMessage(new FriendListUpdateComposer(Session, Buddy));
                        }
                    }
                }
            }
        }
示例#12
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().GetMessenger() == null)
            {
                return;
            }

            int User = Packet.PopInt();
            int Type = Packet.PopInt();

            if (!Session.GetHabbo().GetMessenger().FriendshipExists(User))
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Oops, Solo puedes poner una relacion primeramente siendo amigos."));
                return;
            }

            if (Type < 0 || Type > 3)
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Oops, Ha elegido un tipo de relacion no valido."));
                return;
            }

            if (Session.GetHabbo().Relationships.Count > 2000)
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Lo sentimos, el limite de relaciones es 2000"));
                return;
            }

            using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                if (Type == 0)
                {
                    dbClient.SetQuery("SELECT `id` FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    int Id = dbClient.getInteger();

                    dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    dbClient.RunQuery();

                    if (Session.GetHabbo().Relationships.ContainsKey(User))
                    {
                        Session.GetHabbo().Relationships.Remove(User);
                    }
                }
                else
                {
                    dbClient.SetQuery("SELECT id FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    int Id = dbClient.getInteger();

                    if (Id > 0)
                    {
                        dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                        dbClient.AddParameter("target", User);
                        dbClient.RunQuery();

                        if (Session.GetHabbo().Relationships.ContainsKey(User))
                        {
                            Session.GetHabbo().Relationships.Remove(User);
                        }
                    }

                    dbClient.SetQuery("INSERT INTO `user_relationships` (`user_id`,`target`,`type`) VALUES ('" + Session.GetHabbo().Id + "', @target, @type)");
                    dbClient.AddParameter("target", User);
                    dbClient.AddParameter("type", Type);
                    int newId = Convert.ToInt32(dbClient.InsertQuery());

                    if (!Session.GetHabbo().Relationships.ContainsKey(User))
                    {
                        Session.GetHabbo().Relationships.Add(User, new Relationship(newId, User, Type));
                    }
                }

                GameClient Client = RavenEnvironment.GetGame().GetClientManager().GetClientByUserID(User);
                if (Client != null)
                {
                    Session.GetHabbo().GetMessenger().UpdateFriend(User, Client, true);
                }
                else
                {
                    Habbo Habbo = RavenEnvironment.GetHabboById(User);
                    if (Habbo != null)
                    {
                        MessengerBuddy Buddy = null;
                        if (Session.GetHabbo().GetMessenger().TryGetFriend(User, out Buddy))
                        {
                            Session.SendMessage(new FriendListUpdateComposer(Session, Buddy));
                        }
                    }
                }
            }
        }