コード例 #1
0
        public void Parse(Player session, ClientPacket packet)
        {
            var userId = packet.PopInt();

            packet.PopBoolean(); //IsMe?

            var targetData = HabboFactory.GetHabboById(userId);

            if (targetData == null)
            {
                session.SendNotification("An error occured whilst finding that user's profile.");
                return;
            }

            var groups = Program.GameContext.GetGroupManager().GetGroupsForUser(targetData.Id);

            int friendCount;

            using (var dbClient = Program.DatabaseManager.GetQueryReactor())
            {
                dbClient.SetQuery("SELECT COUNT(0) FROM `messenger_friendships` WHERE (`user_one_id` = @userid OR `user_two_id` = @userid)");
                dbClient.AddParameter("userid", userId);
                friendCount = dbClient.GetInteger();
            }

            session.SendPacket(new ProfileInformationComposer(targetData, session, groups, friendCount));
        }
コード例 #2
0
        public void Parse(Player session, ClientPacket packet)
        {
            var groupId = packet.PopInt();
            var userId  = packet.PopInt();

            if (!Program.GameContext.GetGroupManager().TryGetGroup(groupId, out var group))
            {
                return;
            }

            if (session.GetHabbo().Id != group.CreatorId && !group.IsAdmin(session.GetHabbo().Id) && !session.GetHabbo().GetPermissions().HasRight("fuse_group_accept_any"))
            {
                return;
            }

            if (!group.HasRequest(userId))
            {
                return;
            }

            var habbo = HabboFactory.GetHabboById(userId);

            if (habbo == null)
            {
                session.SendNotification("Oops, an error occurred whilst finding this user.");
                return;
            }

            group.HandleRequest(userId, true);

            session.SendPacket(new GroupMemberUpdatedComposer(groupId, habbo, 4));
        }
コード例 #3
0
        private List <ChatlogEntry> GetChatlogs(RoomData roomData, double timeEnter, double timeExit)
        {
            var chats = new List <ChatlogEntry>();

            using (var dbClient = Program.DatabaseManager.GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `user_id`, `timestamp`, `message` FROM `chatlogs` WHERE `room_id` = " + roomData.Id + " AND `timestamp` > " + timeEnter + " AND `timestamp` < " + timeExit + " ORDER BY `timestamp` DESC LIMIT 100");
                var data = dbClient.GetTable();

                if (data != null)
                {
                    foreach (DataRow row in data.Rows)
                    {
                        var habbo = HabboFactory.GetHabboById(Convert.ToInt32(row["user_id"]));

                        if (habbo != null)
                        {
                            chats.Add(new ChatlogEntry(Convert.ToInt32(row["user_id"]), roomData.Id, Convert.ToString(row["message"]), Convert.ToDouble(row["timestamp"]), habbo));
                        }
                    }
                }
            }

            return(chats);
        }
コード例 #4
0
        public void Parse(Player session, ClientPacket packet)
        {
            var userId = packet.PopInt();
            var habbo  = HabboFactory.GetHabboById(userId);

            if (habbo == null)
            {
                return;
            }

            session.SendPacket(new HabboUserBadgesComposer(habbo));
        }
コード例 #5
0
        public void Parse(Player session, ClientPacket packet)
        {
            if (session == null || session.GetHabbo() == null || !session.GetHabbo().GetPermissions().HasRight("mod_trade_lock"))
            {
                return;
            }

            var userId  = packet.PopInt();
            var message = packet.PopString();
            var days    = packet.PopInt() / 1440.0;

            packet.PopString(); //unk1
            packet.PopString(); //unk2

            var length = UnixUtilities.GetNow() + days * 86400;

            var habbo = HabboFactory.GetHabboById(userId);

            if (habbo == null)
            {
                session.SendWhisper("An error occoured whilst finding that user in the database.");
                return;
            }

            if (habbo.GetPermissions().HasRight("mod_trade_lock") && !session.GetHabbo().GetPermissions().HasRight("mod_trade_lock_any"))
            {
                session.SendWhisper("Oops, you cannot trade lock another user ranked 5 or higher.");
                return;
            }

            if (days < 1)
            {
                days = 1;
            }

            if (days > 365)
            {
                days = 365;
            }

            using (var dbClient = Program.DatabaseManager.GetQueryReactor())
            {
                dbClient.RunQuery("UPDATE `user_info` SET `trading_locked` = '" + length + "', `trading_locks_count` = `trading_locks_count` + '1' WHERE `user_id` = '" + habbo.Id + "' LIMIT 1");
            }

            if (habbo.GetClient() != null)
            {
                habbo.TradingLockExpiry = length;
                habbo.GetClient().SendNotification("You have been trade banned for " + days + " day(s)!\r\rReason:\r\r" + message);
            }
        }
コード例 #6
0
        public void Parse(Player session, ClientPacket packet)
        {
            var habbo = HabboFactory.GetHabboById(packet.PopInt());

            if (habbo == null)
            {
                return;
            }

            var rand = new Random();

            habbo.Relationships = habbo.Relationships.OrderBy(x => rand.Next()).ToDictionary(item => item.Key, item => item.Value);

            session.SendPacket(new GetRelationshipsComposer(habbo));
        }
コード例 #7
0
        public void Parse(Player session, ClientPacket packet)
        {
            if (session == null || session.GetHabbo() == null)
            {
                return;
            }

            if (!session.GetHabbo().GetPermissions().HasRight("mod_tool"))
            {
                return;
            }

            var data = HabboFactory.GetHabboById(packet.PopInt());

            if (data == null)
            {
                session.SendNotification("Unable to load info for user.");
                return;
            }

            Program.GameContext.GetChatManager().GetLogs().FlushAndSave();

            var chatlogs = new List <KeyValuePair <RoomData, List <ChatlogEntry> > >();

            using (var dbClient = Program.DatabaseManager.GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `room_id`,`entry_timestamp`,`exit_timestamp` FROM `user_roomvisits` WHERE `user_id` = '" + data.Id + "' ORDER BY `entry_timestamp` DESC LIMIT 7");
                var getLogs = dbClient.GetTable();

                if (getLogs != null)
                {
                    foreach (DataRow row in getLogs.Rows)
                    {
                        if (!RoomFactory.TryGetData(Convert.ToInt32(row["room_id"]), out var roomData))
                        {
                            continue;
                        }

                        var timestampExit = Convert.ToDouble(row["exit_timestamp"]) <= 0 ? UnixUtilities.GetNow() : Convert.ToDouble(row["exit_timestamp"]);

                        chatlogs.Add(new KeyValuePair <RoomData, List <ChatlogEntry> >(roomData, GetChatlogs(roomData, Convert.ToDouble(row["entry_timestamp"]), timestampExit)));
                    }
                }

                session.SendPacket(new ModeratorUserChatlogComposer(data, chatlogs));
            }
        }
コード例 #8
0
        public void Parse(Player session, ClientPacket packet)
        {
            if (session == null || session.GetHabbo() == null)
            {
                return;
            }

            if (!session.GetHabbo().GetPermissions().HasRight("mod_tool"))
            {
                return;
            }

            packet.PopInt(); //junk
            var roomId = packet.PopInt();

            if (!Program.GameContext.GetRoomManager().TryGetRoom(roomId, out var room))
            {
                return;
            }

            Program.GameContext.GetChatManager().GetLogs().FlushAndSave();

            var chats = new List <ChatlogEntry>();

            using (var dbClient = Program.DatabaseManager.GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `chatlogs` WHERE `room_id` = @id ORDER BY `id` DESC LIMIT 100");
                dbClient.AddParameter("id", roomId);
                var data = dbClient.GetTable();

                if (data != null)
                {
                    foreach (DataRow row in data.Rows)
                    {
                        var habbo = HabboFactory.GetHabboById(Convert.ToInt32(row["user_id"]));

                        if (habbo != null)
                        {
                            chats.Add(new ChatlogEntry(Convert.ToInt32(row["user_id"]), roomId, Convert.ToString(row["message"]), Convert.ToDouble(row["timestamp"]), habbo));
                        }
                    }
                }
            }

            session.SendPacket(new ModeratorRoomChatlogComposer(room, chats));
        }
コード例 #9
0
        public void Parse(Player session, ClientPacket packet)
        {
            var groupId = packet.PopInt();
            var userId  = packet.PopInt();

            if (!Program.GameContext.GetGroupManager().TryGetGroup(groupId, out var group))
            {
                return;
            }

            if (session.GetHabbo().Id != group.CreatorId || !group.IsMember(userId))
            {
                return;
            }

            var habbo = HabboFactory.GetHabboById(userId);

            if (habbo == null)
            {
                session.SendNotification("Oops, an error occurred whilst finding this user.");
                return;
            }

            group.MakeAdmin(userId);

            if (Program.GameContext.GetRoomManager().TryGetRoom(group.RoomId, out var room))
            {
                var user = room.GetRoomUserManager().GetRoomUserByHabbo(userId);
                if (user != null)
                {
                    if (!user.Statusses.ContainsKey("flatctrl 3"))
                    {
                        user.SetStatus("flatctrl 3");
                    }

                    user.UpdateNeeded = true;
                    if (user.GetClient() != null)
                    {
                        user.GetClient().SendPacket(new YouAreControllerComposer(3));
                    }
                }
            }

            session.SendPacket(new GroupMemberUpdatedComposer(groupId, habbo, 1));
        }
コード例 #10
0
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0)
            {
                return(false);
            }

            var Owner = HabboFactory.GetHabboById(Item.UserID);

            if (Owner == null || !Owner.GetPermissions().HasRight("room_item_wired_rewards"))
            {
                return(false);
            }

            var Player = (Habbo)Params[0];

            if (Player == null || Player.GetClient() == null)
            {
                return(false);
            }

            var User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);

            if (User == null)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(StringData))
            {
                return(false);
            }

            if (Player.GetBadgeComponent().HasBadge(StringData))
            {
                Player.GetClient().SendPacket(new WhisperComposer(User.VirtualId, "Oops, it appears you have already recieved this badge!", 0, User.LastBubble));
            }
            else
            {
                Player.GetBadgeComponent().GiveBadge(StringData, true, Player.GetClient());
                Player.GetClient().SendNotification("You have recieved a badge!");
            }

            return(true);
        }
コード例 #11
0
        public void Parse(Player session, ClientPacket packet)
        {
            var ignoredUsers = new List <string>();

            foreach (var userId in new List <int>(session.GetHabbo().GetIgnores().IgnoredUserIds()))
            {
                var player = HabboFactory.GetHabboById(userId);
                if (player != null)
                {
                    if (!ignoredUsers.Contains(player.Username))
                    {
                        ignoredUsers.Add(player.Username);
                    }
                }
            }

            session.SendPacket(new IgnoredUsersComposer(ignoredUsers));
        }
コード例 #12
0
        public void Parse(Player session, ClientPacket packet)
        {
            if (session?.GetHabbo() == null || !session.GetHabbo().GetPermissions().HasRight("mod_mute"))
            {
                return;
            }

            var userId = packet.PopInt();

            packet.PopString(); //message
            double length = packet.PopInt() * 60;

            packet.PopString(); //unk1
            packet.PopString(); //unk2

            var habbo = HabboFactory.GetHabboById(userId);

            if (habbo == null)
            {
                session.SendWhisper("An error occoured whilst finding that user in the database.");
                return;
            }

            if (habbo.GetPermissions().HasRight("mod_mute") && !session.GetHabbo().GetPermissions().HasRight("mod_mute_any"))
            {
                session.SendWhisper("Oops, you cannot mute that user.");
                return;
            }

            using (var dbClient = Program.DatabaseManager.GetQueryReactor())
            {
                dbClient.RunQuery("UPDATE `users` SET `time_muted` = '" + length + "' WHERE `id` = '" + habbo.Id + "' LIMIT 1");
            }

            if (habbo.GetClient() != null)
            {
                habbo.TimeMuted = length;
                habbo.GetClient().SendNotification("You have been muted by a moderator for " + length + " seconds!");
            }
        }
コード例 #13
0
        public void Parse(Player session, ClientPacket packet)
        {
            if (session?.GetHabbo() == null)
            {
                return;
            }

            // Run a quick check to see if we have any existing tickets.
            if (Program.GameContext.GetModerationManager().UserHasTickets(session.GetHabbo().Id))
            {
                var pendingTicket = Program.GameContext.GetModerationManager().GetTicketBySenderId(session.GetHabbo().Id);
                if (pendingTicket != null)
                {
                    session.SendPacket(new CallForHelpPendingCallsComposer(pendingTicket));
                    return;
                }
            }

            var chats = new List <string>();

            var message        = StringUtilities.Escape(packet.PopString().Trim());
            var category       = packet.PopInt();
            var reportedUserId = packet.PopInt();
            var type           = packet.PopInt();// Unsure on what this actually is.

            var reportedUser = HabboFactory.GetHabboById(reportedUserId);

            if (reportedUser == null)
            {
                // User doesn't exist.
                return;
            }

            var messagecount = packet.PopInt();

            for (var i = 0; i < messagecount; i++)
            {
                packet.PopInt();
                chats.Add(packet.PopString());
            }

            var ticket = new ModerationTicket(1, type, category, UnixUtilities.GetNow(), 1, session.GetHabbo(), reportedUser, message, session.GetHabbo().CurrentRoom, chats);

            if (!Program.GameContext.GetModerationManager().TryAddTicket(ticket))
            {
                return;
            }

            using (var dbClient = Program.DatabaseManager.GetQueryReactor())
            {
                // TODO: Come back to this.

                /*dbClient.SetQuery("INSERT INTO `moderation_tickets` (`score`,`type`,`status`,`sender_id`,`reported_id`,`moderator_id`,`message`,`room_id`,`room_name`,`timestamp`) VALUES (1, '" + Category + "', 'open', '" + Session.GetHabbo().Id + "', '" + ReportedUserId + "', '0', @message, '0', '', '" + UnixTimestamp.GetNow() + "')");
                 * dbClient.AddParameter("message", Message);
                 * dbClient.RunQuery();*/

                dbClient.RunQuery("UPDATE `user_info` SET `cfhs` = `cfhs` + '1' WHERE `user_id` = '" + session.GetHabbo().Id + "' LIMIT 1");
            }

            Program.GameContext.PlayerController.ModAlert("A new support ticket has been submitted!");
            Program.GameContext.PlayerController.SendPacket(new ModeratorSupportTicketComposer(session.GetHabbo().Id, ticket), "mod_tool");
        }
コード例 #14
0
        public void Parse(Player session, ClientPacket packet)
        {
            if (session == null || session.GetHabbo() == null || !session.GetHabbo().GetPermissions().HasRight("mod_soft_ban"))
            {
                return;
            }

            var userId  = packet.PopInt();
            var message = packet.PopString();
            var length  = packet.PopInt() * 3600 + UnixUtilities.GetNow();

            packet.PopString(); //unk1
            packet.PopString(); //unk2
            var ipBan      = packet.PopBoolean();
            var machineBan = packet.PopBoolean();

            if (machineBan)
            {
                ipBan = false;
            }

            var habbo = HabboFactory.GetHabboById(userId);

            if (habbo == null)
            {
                session.SendWhisper("An error occoured whilst finding that user in the database.");
                return;
            }

            if (habbo.GetPermissions().HasRight("mod_tool") && !session.GetHabbo().GetPermissions().HasRight("mod_ban_any"))
            {
                session.SendWhisper("Oops, you cannot ban that user.");
                return;
            }

            message = message != null ? message : "No reason specified.";

            using (var dbClient = Program.DatabaseManager.GetQueryReactor())
            {
                dbClient.RunQuery("UPDATE `user_info` SET `bans` = `bans` + '1' WHERE `user_id` = '" + habbo.Id + "' LIMIT 1");
            }

            if (ipBan == false && machineBan == false)
            {
                Program.GameContext.GetModerationManager().BanUser(session.GetHabbo().Username, ModerationBanType.Username, habbo.Username, message, length);
            }
            else if (ipBan)
            {
                Program.GameContext.GetModerationManager().BanUser(session.GetHabbo().Username, ModerationBanType.IP, habbo.Username, message, length);
            }
            else
            {
                Program.GameContext.GetModerationManager().BanUser(session.GetHabbo().Username, ModerationBanType.IP, habbo.Username, message, length);
                Program.GameContext.GetModerationManager().BanUser(session.GetHabbo().Username, ModerationBanType.Username, habbo.Username, message, length);
                Program.GameContext.GetModerationManager().BanUser(session.GetHabbo().Username, ModerationBanType.Machine, habbo.Username, message, length);
            }

            var targetClient = Program.GameContext.PlayerController.GetClientByUsername(habbo.Username);

            if (targetClient != null)
            {
                targetClient.Disconnect();
            }
        }
コード例 #15
0
        public void Parse(Player 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 = Program.DatabaseManager.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);

                    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 = Program.GameContext.PlayerController.GetClientByUserId(user);
                if (client != null)
                {
                    session.GetHabbo().GetMessenger().UpdateFriend(user, client, true);
                }
                else
                {
                    var habbo = HabboFactory.GetHabboById(user);
                    if (habbo != null)
                    {
                        if (session.GetHabbo().GetMessenger().TryGetFriend(user, out var buddy))
                        {
                            session.SendPacket(new FriendListUpdateComposer(session, buddy));
                        }
                    }
                }
            }
        }