Esempio n. 1
0
        /// <summary>
        /// Serializes the room visits.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns>ServerMessage.</returns>
        internal static ServerMessage SerializeRoomVisits(uint userId)
        {
            var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolRoomVisitsMessageComposer"));

            serverMessage.AppendInteger(userId);

            var user = Plus.GetGame().GetClientManager().GetClientByUserId(userId);

            if (user == null || user.GetHabbo() == null)
            {
                serverMessage.AppendString("Not online");
                serverMessage.AppendInteger(0);
                return(serverMessage);
            }

            serverMessage.AppendString(user.GetHabbo().UserName);
            serverMessage.StartArray();

            foreach (var roomData in user.GetHabbo()
                     .RecentlyVisitedRooms.Select(
                         roomId => Plus.GetGame().GetRoomManager().GenerateRoomData(roomId))
                     .Where(roomData => roomData != null))
            {
                serverMessage.AppendInteger(roomData.Id);
                serverMessage.AppendString(roomData.Name);

                serverMessage.AppendInteger(0); //hour
                serverMessage.AppendInteger(0); //min

                serverMessage.SaveArray();
            }

            serverMessage.EndArray();
            return(serverMessage);
        }
Esempio n. 2
0
 /// <summary>
 /// Serializes the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 internal void Serialize(ServerMessage message)
 {
     message.StartArray();
     foreach (var clothing1 in Clothing)
     {
         var item1 = Plus.GetGame().GetClothingManager().GetClothesInFurni(clothing1);
         foreach (var clothe in item1.Clothes)
         {
             message.AppendInteger(clothe);
         }
         message.SaveArray();
     }
     message.EndArray();
     message.StartArray();
     foreach (var clothing2 in Clothing)
     {
         var item2 = Plus.GetGame().GetClothingManager().GetClothesInFurni(clothing2);
         foreach (var clothe in item2.Clothes)
         {
             message.AppendString(item2.ItemName);
         }
         message.SaveArray();
     }
     message.EndArray();
 }
Esempio n. 3
0
        public static void removeFarmingSpot(FarmingSpot thefarmingspot, GameClient Session, Room room)
        {
            if (thefarmingspot != null && Session != null)
            {
                try
                {
                    FarmingSpot expiredFarmingSpot;
                    var         item = thefarmingspot.FarmingSpotItem;

                    room.GetRoomItemHandler().RemoveFurniture(Session, item.Id, true);
                    var currentRoom = Plus.GetGame().GetRoomManager().GetRoom(thefarmingspot.roomid);
                    foreach (var Item in currentRoom.GetRoomItemHandler().FloorItems.Values)
                    {
                        if (Item.X == thefarmingspot.x && Item.Y == thefarmingspot.y && Item.RoomId == thefarmingspot.roomid && thefarmingspot.type == "carrot" && Item.BaseItem == 2946)
                        {
                            Misc.RoleplayManager.PickFarmingSpot(Item, thefarmingspot.roomid);
                        }
                        if (Item.X == thefarmingspot.x && Item.Y == thefarmingspot.y && Item.RoomId == thefarmingspot.roomid && thefarmingspot.type == "weed" && Item.BaseItem == 6699)
                        {
                            Misc.RoleplayManager.PickFarmingSpot(Item, thefarmingspot.roomid);
                        }
                    }

                    FarmingSpots.TryRemove(thefarmingspot.id, out expiredFarmingSpot);
                    expiredFarmingSpot = null;
                }
                catch
                {
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Adds the subscription.
        /// </summary>
        /// <param name="dayLength">Length of the day.</param>
        internal void AddSubscription(double dayLength)
        {
            var num = ((int)Math.Round(dayLength));

            var      clientByUserId = Plus.GetGame().GetClientManager().GetClientByUserId(_userId);
            DateTime target;
            Int64    num2;
            Int64    num3;

            if (_subscription != null)
            {
                target = Plus.UnixToDateTime(_subscription.ExpireTime).AddDays(num);
                num2   = _subscription.ActivateTime;
                num3   = _subscription.LastGiftTime;
            }
            else
            {
                target = DateTime.Now.AddDays(num);
                num2   = Plus.GetUnixTimeStamp();
                num3   = Plus.GetUnixTimeStamp();
            }
            var num4 = Plus.DateTimeToUnix(target);

            _subscription = new Subscription(2, num2, num4, num3);
            using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery(
                    string.Concat(new object[]
                                  { "REPLACE INTO users_subscriptions VALUES (", _userId, ", 2, ", num2, ", ", num4, ", ", num3, ");" }));
            clientByUserId.GetHabbo().SerializeClub();
            Plus.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(clientByUserId);
        }
Esempio n. 5
0
        private static void ClearRoomsCache()
        {
            if (Plus.GetGame() == null || Plus.GetGame().GetRoomManager() == null ||
                Plus.GetGame().GetRoomManager().LoadedRoomData == null)
            {
                return;
            }

            var toRemove = new List <uint>();

            foreach (var roomData in Plus.GetGame().GetRoomManager().LoadedRoomData)
            {
                if (roomData.Value == null || roomData.Value.UsersNow > 0)
                {
                    continue;
                }
                if ((DateTime.Now - roomData.Value.LastUsed).TotalMilliseconds < 1800000)
                {
                    continue;
                }

                toRemove.Add(roomData.Key);
            }

            foreach (var roomId in toRemove)
            {
                RoomData nullRoom;
                if (Plus.GetGame().GetRoomManager().LoadedRoomData.TryRemove(roomId, out nullRoom))
                {
                    nullRoom = null;
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Serializes the event information.
        /// </summary>
        /// <param name="roomId">The room identifier.</param>
        internal void SerializeEventInfo(uint roomId)
        {
            Room room = Plus.GetGame().GetRoomManager().GetRoom(roomId);

            if (room == null)
            {
                return;
            }
            RoomEvent @event = this.GetEvent(roomId);

            if (@event == null || @event.HasExpired)
            {
                return;
            }
            if (!this.RoomHasEvents(roomId))
            {
                return;
            }
            var serverMessage = new ServerMessage();

            serverMessage.Init(LibraryParser.OutgoingRequest("RoomEventMessageComposer"));
            serverMessage.AppendInteger(roomId);
            serverMessage.AppendInteger(room.RoomData.OwnerId);
            serverMessage.AppendString(room.RoomData.Owner);
            serverMessage.AppendInteger(1);
            serverMessage.AppendInteger(1);
            serverMessage.AppendString(@event.Name);
            serverMessage.AppendString(@event.Description);
            serverMessage.AppendInteger(0);
            serverMessage.AppendInteger(
                ((int)Math.Floor((@event.Time - Plus.GetUnixTimeStamp()) / 60.0)));

            serverMessage.AppendInteger(@event.Category);
            room.SendMessage(serverMessage);
        }
Esempio n. 7
0
        /// <summary>
        /// Called when [new friendship].
        /// </summary>
        /// <param name="friendId">The friend identifier.</param>
        internal void OnNewFriendship(uint friendId)
        {
            var            clientByUserId = Plus.GetGame().GetClientManager().GetClientByUserId(friendId);
            MessengerBuddy messengerBuddy;

            if (clientByUserId == null || clientByUserId.GetHabbo() == null)
            {
                DataRow row;
                using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
                {
                    queryReactor.SetQuery(
                        string.Format(
                            "SELECT id,username,motto,look,last_online,hide_inroom,hide_online FROM users WHERE id = {0}",
                            friendId));
                    row = queryReactor.GetRow();
                }
                messengerBuddy = new MessengerBuddy(friendId, (string)row["Username"], (string)row["look"],
                                                    (string)row["motto"], (int)row["last_online"], Plus.EnumToBool(row["hide_online"].ToString()),
                                                    Plus.EnumToBool(row["hide_inroom"].ToString()));
            }
            else
            {
                var habbo = clientByUserId.GetHabbo();
                messengerBuddy = new MessengerBuddy(friendId, habbo.UserName, habbo.Look, habbo.Motto, 0,
                                                    habbo.AppearOffline, habbo.HideInRoom);
                messengerBuddy.UpdateUser();
            }
            if (!Friends.ContainsKey(friendId))
            {
                Friends.Add(friendId, messengerBuddy);
            }
            GetClient().SendMessage(SerializeUpdate(messengerBuddy));
        }
Esempio n. 8
0
        /// <summary>
        /// Method is call when timer is finished
        /// </summary>
        /// <param name="info">The information</param>
        public void Ticked(object info)
        {
            try
            {
                if (On)
                {
                    // If there is still more to do
                    if (!Plus.GetGame().MafiaWars.Started)
                    {
                        // Inform the user of time left
                        messageCunts("[MAFIA WARS] Green team: " + Plus.GetGame().MafiaWars.MWTeams["Green"].Players.Count + "/10 | Blue team: " + Plus.GetGame().MafiaWars.MWTeams["Blue"].Players.Count + "/10");

                        try
                        {
                            // For every team in teams

                            // For every player in team.players
                        }
                        catch (Exception ex) { }
                    }
                    else
                    {
                        // lallaa
                        messageCunts("[MAFIA WARS] There is currently a game in progress!");
                    }

                    Timer.Change(30000, Timeout.Infinite);
                }
            }
            catch { }
        }
Esempio n. 9
0
        internal void ToggleStaffPick()
        {
            var roomId  = Request.GetUInteger();
            var current = Request.GetBool();
            var room    = Plus.GetGame().GetRoomManager().GetRoom(roomId);

            if (room == null)
            {
                return;
            }
            using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
            {
                var pubItem = Plus.GetGame().GetNavigator().GetPublicItem(roomId);
                if (pubItem == null) // not picked
                {
                    queryReactor.SetQuery("INSERT INTO navigator_publics (bannertype, room_id, category_parent_id) VALUES ('0', @roomId, '-2')");
                    queryReactor.AddParameter("roomId", room.RoomId);
                    queryReactor.RunQuery();
                    queryReactor.RunFastQuery("SELECT last_insert_id()");
                    var publicItemId = queryReactor.GetInteger();
                    var publicItem   = new PublicItem(publicItemId, 0, string.Empty, string.Empty, string.Empty, PublicImageType.Internal, room.RoomId, 0, -2, false, 1, string.Empty);
                    Plus.GetGame().GetNavigator().AddPublicItem(publicItem);
                }
                else // picked
                {
                    queryReactor.SetQuery("DELETE FROM navigator_publics WHERE id = @pubId");
                    queryReactor.AddParameter("pubId", pubItem.Id);
                    queryReactor.RunQuery();
                    Plus.GetGame().GetNavigator().RemovePublicItem(pubItem.Id);
                }
                room.RoomData.SerializeRoomData(Response, Session, false, true);
                Plus.GetGame().GetNavigator().LoadNewPublicRooms();
            }
        }
Esempio n. 10
0
        public void removeSameFarmingSpots()
        {
            try
            {
                var currentRoom = Plus.GetGame().GetRoomManager().GetRoom(roomid);

                foreach (var Item in currentRoom.GetRoomItemHandler().FloorItems.Values)
                {
                    if (Item.X == x && Item.Y == y && Item.RoomId == roomid && Item.BaseItem == 1737)
                    {
                        Misc.RoleplayManager.PickFarmingSpot(Item, roomid);
                    }
                    if (Item.X == x && Item.Y == y && Item.RoomId == roomid && Item.BaseItem == 2946)
                    {
                        Misc.RoleplayManager.PickFarmingSpot(Item, roomid);
                    }
                    if (Item.X == x && Item.Y == y && Item.RoomId == roomid && Item.BaseItem == 6699)
                    {
                        Misc.RoleplayManager.PickFarmingSpot(Item, roomid);
                    }
                }
            }
            catch
            {
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Composes the specified session.
        /// </summary>
        /// <param name="Session">The session.</param>
        /// <param name="Quest">The quest.</param>
        /// <returns>ServerMessage.</returns>
        internal static ServerMessage Compose(GameClient Session, Quest Quest)
        {
            int amountOfQuestsInCategory = Plus.GetGame().GetQuestManager().GetAmountOfQuestsInCategory(Quest.Category);
            int i             = (Quest == null) ? amountOfQuestsInCategory : Quest.Number;
            int i2            = (Quest == null) ? 0 : Session.GetHabbo().GetQuestProgress(Quest.Id);
            var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("QuestCompletedMessageComposer"));

            serverMessage.AppendString(Quest.Category);
            serverMessage.AppendInteger(i);
            serverMessage.AppendInteger(Quest.Name.Contains("xmas2012") ? 1 : amountOfQuestsInCategory);
            serverMessage.AppendInteger((Quest == null) ? 3 : Quest.RewardType);
            serverMessage.AppendInteger((Quest == null) ? 0u : Quest.Id);
            serverMessage.AppendBool(Quest != null && Session.GetHabbo().CurrentQuestId == Quest.Id);
            serverMessage.AppendString((Quest == null) ? string.Empty : Quest.ActionName);
            serverMessage.AppendString((Quest == null) ? string.Empty : Quest.DataBit);
            serverMessage.AppendInteger((Quest == null) ? 0 : Quest.Reward);
            serverMessage.AppendString((Quest == null) ? string.Empty : Quest.Name);
            serverMessage.AppendInteger(i2);
            serverMessage.AppendInteger((Quest == null) ? 0u : Quest.GoalData);
            serverMessage.AppendInteger((Quest == null) ? 0 : Quest.TimeUnlock);
            serverMessage.AppendString("");
            serverMessage.AppendString("");
            serverMessage.AppendBool(true);
            serverMessage.AppendBool(true);
            return(serverMessage);
        }
Esempio n. 12
0
        /// <summary>
        /// Performs the room action.
        /// </summary>
        /// <param name="modSession">The mod session.</param>
        /// <param name="roomId">The room identifier.</param>
        /// <param name="kickUsers">if set to <c>true</c> [kick users].</param>
        /// <param name="lockRoom">if set to <c>true</c> [lock room].</param>
        /// <param name="inappropriateRoom">if set to <c>true</c> [inappropriate room].</param>
        /// <param name="message">The message.</param>
        internal static void PerformRoomAction(GameClient modSession, uint roomId, bool kickUsers, bool lockRoom, bool inappropriateRoom, ServerMessage message)
        {
            Room room = Plus.GetGame().GetRoomManager().GetRoom(roomId);

            if (room == null)
            {
                return;
            }
            if (lockRoom)
            {
                room.RoomData.State = 1;
                using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
                {
                    queryReactor.RunFastQuery(string.Format("UPDATE rooms_data SET state = 'locked' WHERE id = {0}", room.RoomId));
                }
            }
            if (inappropriateRoom)
            {
                room.RoomData.Name        = "Inappropiate to Hotel Management.";
                room.RoomData.Description = "Your room description is not allowed.";
                room.ClearTags();
                room.RoomData.SerializeRoomData(message, modSession, false, true);
            }
            if (kickUsers)
            {
                room.OnRoomKick();
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Sends the ticket to moderators.
        /// </summary>
        /// <param name="ticket">The ticket.</param>
        internal static void SendTicketToModerators(SupportTicket ticket)
        {
            var message = new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolIssueMessageComposer"));

            message = ticket.Serialize(message);
            Plus.GetGame().GetClientManager().StaffAlert(message);
        }
Esempio n. 14
0
        /// <summary>
        /// Serializes the room chatlog.
        /// </summary>
        /// <param name="roomId">The room identifier.</param>
        /// <returns>ServerMessage.</returns>
        /// <exception cref="System.NullReferenceException">No room found.</exception>
        internal static ServerMessage SerializeRoomChatlog(uint roomId)
        {
            var  message = new ServerMessage();
            Room room    = Plus.GetGame().GetRoomManager().LoadRoom(roomId);

            if (room == null || room.RoomData == null)
            {
                throw new NullReferenceException("No room found.");
            }

            message.Init(LibraryParser.OutgoingRequest("ModerationToolRoomChatlogMessageComposer"));
            message.AppendByte(1); //type
            message.AppendShort(2);
            message.AppendString("roomName");
            message.AppendByte(2);
            message.AppendString(room.RoomData.Name);
            message.AppendString("roomId");
            message.AppendByte(1);
            message.AppendInteger(room.RoomData.Id);

            var tempChatlogs = room.RoomData.RoomChat.Skip(Math.Max(0, room.RoomData.RoomChat.Count() - 500)).Take(500).ToList().OrderByDescending(key => key.TimeStamp);

            message.AppendShort(tempChatlogs.Count());
            foreach (var chatLog in tempChatlogs)
            {
                chatLog.Serialize(ref message);
            }
            tempChatlogs = null;

            return(message);
        }
Esempio n. 15
0
        /// <summary>
        /// Serializes the quest.
        /// </summary>
        /// <param name="Message">The message.</param>
        /// <param name="Session">The session.</param>
        /// <param name="Quest">The quest.</param>
        /// <param name="Category">The category.</param>
        internal static void SerializeQuest(ServerMessage Message, GameClient Session, Quest Quest, string Category)
        {
            if (Message == null || Session == null)
            {
                return;
            }
            int amountOfQuestsInCategory = Plus.GetGame().GetQuestManager().GetAmountOfQuestsInCategory(Category);

            {
                int num  = (Quest == null) ? amountOfQuestsInCategory : (Quest.Number - 1);
                int num2 = (Quest == null) ? 0 : Session.GetHabbo().GetQuestProgress(Quest.Id);
                if (Quest != null && Quest.IsCompleted(num2))
                {
                    num++;
                }
                Message.AppendString(Category);
                Message.AppendInteger((Quest == null) ? 0 : (Quest.Category.Contains("xmas2012") ? 0 : num));
                Message.AppendInteger((Quest == null) ? 0 : (Quest.Category.Contains("xmas2012") ? 0 : amountOfQuestsInCategory));
                Message.AppendInteger((Quest == null) ? 3 : Quest.RewardType);
                Message.AppendInteger((Quest == null) ? 0u : Quest.Id);
                Message.AppendBool(Quest != null && Session.GetHabbo().CurrentQuestId == Quest.Id);
                Message.AppendString((Quest == null) ? string.Empty : Quest.ActionName);
                Message.AppendString((Quest == null) ? string.Empty : Quest.DataBit);
                Message.AppendInteger((Quest == null) ? 0 : Quest.Reward);
                Message.AppendString((Quest == null) ? string.Empty : Quest.Name);
                Message.AppendInteger(num2);
                Message.AppendInteger((Quest == null) ? 0u : Quest.GoalData);
                Message.AppendInteger((Quest == null) ? 0 : Quest.TimeUnlock);
                Message.AppendString("");
                Message.AppendString("");
                Message.AppendBool(true);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Processes the specified caller.
        /// </summary>
        /// <param name="caller">The caller.</param>
        internal static void Process(object caller)
        {
            if (lowPriorityProcessWatch.ElapsedMilliseconds >= 10000 || !isExecuted)
            {
                isExecuted = true;
                lowPriorityProcessWatch.Restart();

                var clientCount      = Plus.GetGame().GetClientManager().ClientCount;
                var loadedRoomsCount = Plus.GetGame().GetRoomManager().LoadedRoomsCount;
                var Uptime           = DateTime.Now - Plus.ServerStarted;

                Console.Title = "[FluxRP]  Uptime: " + Uptime.Days + " days and " + Uptime.Hours + " hours | " +
                                "Online users: " + clientCount + " | Loaded rooms: " + loadedRoomsCount;

                using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
                {
                    if (clientCount > _userPeak)
                    {
                        _userPeak = clientCount;
                    }

                    _lastDate = DateTime.Now.ToShortDateString();
                    queryReactor.RunFastQuery(string.Concat("UPDATE `server_status` SET `stamp` = '", Plus.GetUnixTimeStamp(), "', `users_online` = '", clientCount, "', `rooms_loaded` = '", loadedRoomsCount, "', `server_ver` = 'Plus Emulator', `userpeak` = ", _userPeak));
                }
            }
        }
Esempio n. 17
0
        public void removeOldPrizes()
        {
            try
            {
                var currentRoom = Plus.GetGame().GetRoomManager().GetRoom(Convert.ToUInt32(RoomId));

                foreach (var Item in currentRoom.GetRoomItemHandler().FloorItems.Values)
                {
                    if (Item.BaseItem == 761 || Item.BaseItem == 6877 || Item.BaseItem == 6876 || Item.BaseItem == 3855 || Item.BaseItem == 6878 || Item.BaseItem == 55005)
                    {
                        if (Item.X == X1 && Item.Y == Y1 && Item.RoomId == Convert.ToUInt32(RoomId))
                        {
                            Misc.RoleplayManager.PickSlotTilePrize(Item, Convert.ToUInt32(RoomId));
                        }
                        if (Item.X == X2 && Item.Y == Y2 && Item.RoomId == Convert.ToUInt32(RoomId))
                        {
                            Misc.RoleplayManager.PickSlotTilePrize(Item, Convert.ToUInt32(RoomId));
                        }
                    }
                }
            }
            catch
            {
            }
        }
Esempio n. 18
0
        internal void BanzaiEnd()
        {
            IsBanzaiActive = false;
            _room.GetGameManager().StopGame();
            _floorMap = null;
            _room.GetWiredHandler().ExecuteWired(Interaction.TriggerGameEnd);
            var winningTeam = _room.GetGameManager().GetWinningTeam();

            _room.GetGameManager().UnlockGates();
            foreach (RoomItem roomItem in BanzaiTiles.Values)
            {
                if (roomItem.Team == winningTeam)
                {
                    roomItem.InteractionCount       = 0;
                    roomItem.InteractionCountHelper = 0;
                    roomItem.UpdateNeeded           = true;
                }
                else if (roomItem.Team == Team.none)
                {
                    roomItem.ExtraData = "0";
                    roomItem.UpdateState();
                }
            }
            if (winningTeam == Team.none)
            {
                return;
            }
            foreach (var avatar in _room.GetRoomUserManager().GetRoomUsers())
            {
                if (avatar.Team != Team.none && Plus.GetUnixTimeStamp() - _timestarted > 5.0)
                {
                    Plus.GetGame()
                    .GetAchievementManager()
                    .ProgressUserAchievement(avatar.GetClient(), "ACH_BattleBallTilesLocked",
                                             avatar.LockedTilesCount, false);
                    Plus.GetGame()
                    .GetAchievementManager()
                    .ProgressUserAchievement(avatar.GetClient(), "ACH_BattleBallPlayer", 1, false);
                }

                if ((winningTeam == Team.red && avatar.CurrentEffect != 33) ||
                    (winningTeam == Team.green && avatar.CurrentEffect != 34) ||
                    (winningTeam == Team.blue && avatar.CurrentEffect != 35) ||
                    (winningTeam == Team.yellow && avatar.CurrentEffect != 36))
                {
                    continue;
                }
                if (Plus.GetUnixTimeStamp() - _timestarted > 5.0)
                {
                    Plus.GetGame()
                    .GetAchievementManager()
                    .ProgressUserAchievement(avatar.GetClient(), "ACH_BattleBallWinner", 1, false);
                }
                var waveAtWin = new ServerMessage(LibraryParser.OutgoingRequest("RoomUserActionMessageComposer"));
                waveAtWin.AppendInteger(avatar.VirtualId);
                waveAtWin.AppendInteger(1);
                _room.SendMessage(waveAtWin);
            }
            _field.Destroy();
        }
Esempio n. 19
0
        /// <summary>
        /// Called when [status changed].
        /// </summary>
        /// <param name="notification">if set to <c>true</c> [notification].</param>
        internal void OnStatusChanged(bool notification)
        {
            if (Friends == null)
            {
                return;
            }

            IEnumerable <GameClient> onlineUsers = Plus.GetGame().GetClientManager().GetClientsById(Friends.Keys);

            foreach (GameClient client in onlineUsers)
            {
                if (client == null || client.GetHabbo() == null || client.GetHabbo().GetMessenger() == null)
                {
                    continue;
                }

                client.GetHabbo().GetMessenger().UpdateFriend(_userId, client, true);
                if (client.GetHabbo() != null && client != null && notification != null)
                {
                    if (client.GetHabbo().Id != null && client.GetHabbo().Id != 0)
                    {
                        UpdateFriend(client.GetHabbo().Id, client, notification);
                    }
                }
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Gets the user data.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns>UserData.</returns>
        internal static UserData GetUserData(int userId)
        {
            DataRow   dataRow;
            uint      num;
            DataRow   row;
            DataTable table;

            using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(string.Format("SELECT * FROM users WHERE id = '{0}'", userId));
                dataRow = queryReactor.GetRow();
                Plus.GetGame().GetClientManager().LogClonesOut(Convert.ToUInt32(userId));
                if (dataRow == null)
                {
                    return(null);
                }
                num = Convert.ToUInt32(dataRow["id"]);
                if (Plus.GetGame().GetClientManager().GetClientByUserId(num) != null)
                {
                    return(null);
                }
                queryReactor.SetQuery(string.Format("SELECT job_id,job_rank FROM rp_stats WHERE id={0}", userId));
                queryReactor.GetTable();
                queryReactor.SetQuery(string.Format("SELECT * FROM users_stats WHERE id={0} LIMIT 1", num));
                row = queryReactor.GetRow();

                if (row == null)
                {
                }
                queryReactor.SetQuery("SELECT * FROM users_relationships WHERE user_id=@id");
                queryReactor.AddParameter("id", num);
                table = queryReactor.GetTable();
            }
            var achievements    = new Dictionary <string, UserAchievement>();
            var talents         = new Dictionary <int, UserTalent>();
            var favouritedRooms = new List <uint>();
            var ignores         = new List <uint>();
            var tags            = new List <string>();
            var badges          = new List <Badge>();
            var inventory       = new List <UserItem>();
            var effects         = new List <AvatarEffect>();
            var friends         = new Dictionary <uint, MessengerBuddy>();
            var requests        = new Dictionary <uint, MessengerRequest>();
            var rooms           = new HashSet <RoomData>();
            var pets            = new Dictionary <uint, Pet>();
            var quests          = new Dictionary <uint, int>();
            var bots            = new Dictionary <uint, RoomBot>();
            var group           = new HashSet <GroupUser>();
            var pollData        = new HashSet <uint>();
            var dictionary      = table.Rows.Cast <DataRow>()
                                  .ToDictionary(dataRow2 => (int)dataRow2[0],
                                                dataRow2 =>
                                                new Relationship((int)dataRow2[0], (int)dataRow2[2], Convert.ToInt32(dataRow2[3].ToString())));
            var user = HabboFactory.GenerateHabbo(dataRow, row, group);

            dataRow = null;

            return(new UserData(num, achievements, talents, favouritedRooms, ignores, tags, null, badges, inventory,
                                effects, friends, requests, rooms, pets, quests, user, bots, dictionary, pollData, 0));
        }
Esempio n. 21
0
        /// <summary>
        /// Removes the prizes ontop of tile set 2
        /// </summary>
        public void RemoveTiles2()
        {
            try
            {
                var currentRoom = Plus.GetGame().GetRoomManager().GetRoom(slot.RoomId);

                foreach (var Item in currentRoom.GetRoomItemHandler().FloorItems.Values)
                {
                    if (Item.X == SlotsManager.SlotsTilesData[Convert.ToInt32(slot.Id), 1].Tile2.X && Item.Y == SlotsManager.SlotsTilesData[Convert.ToInt32(slot.Id), 1].Tile2.Y && Item.RoomId == slot.RoomId && (Item.BaseItem == 761 || Item.BaseItem == 6877 || Item.BaseItem == 6876 || Item.BaseItem == 3855 || Item.BaseItem == 6878 || Item.BaseItem == 55005))
                    {
                        Misc.RoleplayManager.PickFarmingSpot(Item, slot.RoomId);
                    }
                    if (Item.X == SlotsManager.SlotsTilesData[Convert.ToInt32(slot.Id), 2].Tile2.X && Item.Y == SlotsManager.SlotsTilesData[Convert.ToInt32(slot.Id), 2].Tile2.Y && Item.RoomId == slot.RoomId && (Item.BaseItem == 761 || Item.BaseItem == 6877 || Item.BaseItem == 6876 || Item.BaseItem == 3855 || Item.BaseItem == 6878 || Item.BaseItem == 55005))
                    {
                        Misc.RoleplayManager.PickFarmingSpot(Item, slot.RoomId);
                    }
                    if (Item.X == SlotsManager.SlotsTilesData[Convert.ToInt32(slot.Id), 3].Tile2.X && Item.Y == SlotsManager.SlotsTilesData[Convert.ToInt32(slot.Id), 3].Tile2.Y && Item.RoomId == slot.RoomId && (Item.BaseItem == 761 || Item.BaseItem == 6877 || Item.BaseItem == 6876 || Item.BaseItem == 3855 || Item.BaseItem == 6878 || Item.BaseItem == 55005))
                    {
                        Misc.RoleplayManager.PickFarmingSpot(Item, slot.RoomId);
                    }
                    if (Item.X == SlotsManager.SlotsTilesData[Convert.ToInt32(slot.Id), 4].Tile2.X && Item.Y == SlotsManager.SlotsTilesData[Convert.ToInt32(slot.Id), 4].Tile2.Y && Item.RoomId == slot.RoomId && (Item.BaseItem == 761 || Item.BaseItem == 6877 || Item.BaseItem == 6876 || Item.BaseItem == 3855 || Item.BaseItem == 6878 || Item.BaseItem == 55005))
                    {
                        Misc.RoleplayManager.PickFarmingSpot(Item, slot.RoomId);
                    }
                    if (Item.X == SlotsManager.SlotsTilesData[Convert.ToInt32(slot.Id), 5].Tile2.X && Item.Y == SlotsManager.SlotsTilesData[Convert.ToInt32(slot.Id), 5].Tile2.Y && Item.RoomId == slot.RoomId && (Item.BaseItem == 761 || Item.BaseItem == 6877 || Item.BaseItem == 6876 || Item.BaseItem == 3855 || Item.BaseItem == 6878 || Item.BaseItem == 55005))
                    {
                        Misc.RoleplayManager.PickFarmingSpot(Item, slot.RoomId);
                    }
                }
            }
            catch
            {
            }
        }
Esempio n. 22
0
        public static void WalkToOwner(RoomUser Pet)
        {
            GameClient FollowingOwner = null;

            FollowingOwner = Plus.GetGame().GetClientManager().GetClientByUserId(Pet.BotData.OwnerId);

            if (FollowingOwner == null)
            {
                Console.WriteLine("Owner was null");
                return;
            }

            if (FollowingOwner.GetHabbo().GetRoomUser() == null)
            {
                Console.WriteLine("Owner roomuser was null");
                return;
            }

            if (FollowingOwner.GetHabbo().GetRoomUser().RoomId != Pet.RoomId)
            {
                Console.WriteLine("Owner is not in the room");
                return;
            }

            Pet.Chat(null, "Just a second master, I'm coming!", true, 0, 0);
            Pet.Move(FollowingOwner.GetHabbo().GetRoomUser().GoalX, FollowingOwner.GetHabbo().GetRoomUser().GoalY, FollowingOwner.GetHabbo().GetRoomUser().FollowingOwner.RotBody);
        }
Esempio n. 23
0
        private static void ClearUserCache()
        {
            var toRemove = new List <uint>();

            foreach (var user in Plus.UsersCached)
            {
                if (Plus.GetGame().GetClientManager().GetClientByUserId(user.Key) != null)
                {
                    continue;
                }
                if ((DateTime.Now - user.Value.LastUsed).TotalMilliseconds < 1800000)
                {
                    continue;
                }

                toRemove.Add(user.Key);
            }

            foreach (var userId in toRemove)
            {
                Habbo nullHabbo;
                if (Plus.UsersCached.TryRemove(userId, out nullHabbo))
                {
                    nullHabbo = null;
                }
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Submits the help ticket.
        /// </summary>
        internal void SubmitHelpTicket()
        {
            if (Plus.GetGame().GetModerationTool().UsersHasPendingTicket(Session.GetHabbo().Id))
            {
                var ticket = Plus.GetGame().GetModerationTool().GetPendingTicketForUser(Session.GetHabbo().Id);
                Response.Init(LibraryParser.OutgoingRequest("OpenHelpToolMessageComposer"));
                Response.AppendInteger(1);
                Response.AppendString(ticket.TicketId.ToString());
                Response.AppendString(ticket.Timestamp.ToString());
                Response.AppendString(ticket.Message);
                SendResponse();
                return;
            }
            var message      = Request.GetString();
            var category     = Request.GetInteger();
            var reportedUser = Request.GetUInteger();

            Request.GetUInteger(); // roomId

            var messageCount = Request.GetInteger();

            var chats = new List <string>();

            for (var i = 0; i < messageCount; i++)
            {
                Request.GetInteger();
                chats.Add(Request.GetString());
            }
            Plus.GetGame()
            .GetModerationTool()
            .SendNewTicket(Session, category, 7, reportedUser, message, chats);
            Response.Init(LibraryParser.OutgoingRequest("TicketUserAlert"));
            Response.AppendInteger(0);
            SendResponse();
        }
Esempio n. 25
0
        /// <summary>
        /// Method is call when timer is finished
        /// </summary>
        /// <param name="info">The information</param>
        public void Ticked(object info)
        {
            try
            {
                if (PurgeManager.Running)
                {
                    foreach (GameClient client in Plus.GetGame().GetClientManager().Clients.Values)
                    {
                        try
                        {
                            if (client == null)
                            {
                                continue;
                            }

                            client.SendWhisper("[Automatic Event Alert]: The hotel is currently under Purge Mode. All crime is legal.");
                        }
                        catch (Exception e)
                        {
                        }
                    }

                    Timer.Change(30000, Timeout.Infinite);
                }
                else
                {
                    return;
                }
            }
            catch { }
        }
Esempio n. 26
0
 internal override void OnUserLeaveRoom(GameClients.GameClient Client)
 {
     if (numCops > 0)
     {
         if (Client.GetRoleplay().JobId == 3)
         {
             numCops -= 1;
         }
         bool noCops = true;
         Room room35 = Plus.GetGame().GetRoomManager().GetRoom(422);
         lock (room35.GetRoomUserManager().GetRoomUsers())
         {
             foreach (RoomUser user31 in room35.GetRoomUserManager().GetRoomUsers())
             {
                 if (user31.GetClient().GetRoleplay().JobId == 3)
                 {
                     noCops = false;
                 }
             }
         }
         if (noCops)
         {
             muteChat = false;
             base.GetRoomUser().Chat(null, "Cops finally gone! If you need weed just say 'buy weed'!", false, 1);
             base.GetRoomUser().X            = 2;
             base.GetRoomUser().Y            = 15;
             base.GetRoomUser().Z            = 0;
             base.GetRoomUser().UpdateNeeded = true;
         }
     }
 }
Esempio n. 27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UserItem"/> class.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="baseItemId">The base item identifier.</param>
        /// <param name="extraData">The extra data.</param>
        /// <param name="group">The group.</param>
        /// <param name="songCode">The song code.</param>
        internal UserItem(uint id, uint baseItemId, string extraData, uint group, string songCode)
        {
            Id         = id;
            BaseItemId = baseItemId;
            ExtraData  = extraData;
            GroupId    = group;
            BaseItem   = Plus.GetGame().GetItemManager().GetItem(baseItemId);

            if (BaseItem == null)
            {
                return;
            }
            using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(string.Format("SELECT * FROM items_limited WHERE item_id={0} LIMIT 1", id));
                var row = queryReactor.GetRow();
                if (row != null)
                {
                    uint.TryParse(row[1].ToString(), out LimitedSellId);
                    uint.TryParse(row[2].ToString(), out LimitedStack);
                }
            }

            IsWallItem = (BaseItem.Type == 'i');
            SongCode   = songCode;
        }
Esempio n. 28
0
        /// <summary>
        /// Serializes the search result list flatcats.
        /// </summary>
        /// <param name="flatCatId">The flat cat identifier.</param>
        /// <param name="direct">if set to <c>true</c> [direct].</param>
        /// <param name="message">The message.</param>
        internal static void SerializeSearchResultListFlatcats(int flatCatId, bool direct, ServerMessage message)
        {
            var flatCat = Plus.GetGame().GetNavigator().GetFlatCat(flatCatId);

            if (flatCat == null)
            {
                return;
            }
            message.AppendString(string.Format("category__{0}", flatCat.Caption));
            message.AppendString(flatCat.Caption);
            message.AppendInteger(0);
            message.AppendBool(true);
            message.AppendInteger(-1);
            try
            {
                var rooms = Plus.GetGame().GetRoomManager().GetActiveRooms();
                Plus.GetGame()
                .GetNavigator()
                .SerializeNavigatorPopularRoomsNews(ref message, rooms, flatCatId, direct);
            }
            catch
            {
                message.AppendInteger(0);
            }
        }
Esempio n. 29
0
        void FreeAllConvicts()
        {
            lock (Plus.GetGame().GetClientManager().Clients.Values)
            {
                foreach (GameClient client in Plus.GetGame().GetClientManager().Clients.Values)
                {
                    if (client == null || client.GetHabbo() == null || client.GetRoleplay() == null || !client.GetRoleplay().Jailed)
                    {
                        continue;
                    }
                    UpdateUserLook(client);

                    client.GetRoleplay().Jailed    = false;
                    client.GetRoleplay().JailTimer = 0;
                    client.GetRoleplay().SaveStatusComponents("jailed");
                    client.SendWhisper("Você escapou da prisão!");

                    HabboHotel.Rooms.RoomUser RUser = client.GetHabbo().GetRoomUser();
                    if (RUser == null)
                    {
                        continue;
                    }
                    RUser.SetPos(23, 19, 0.2);
                    RUser.ClearMovement();
                }
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Serializes the user information.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns>ServerMessage.</returns>
        /// <exception cref="System.NullReferenceException">User not found in database.</exception>
        internal static ServerMessage SerializeUserInfo(uint userId)
        {
            {
                ServerMessage result;
                using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
                {
                    queryReactor.SetQuery("SELECT id, username, online, mail, ip_last, look , rank , trade_lock , trade_lock_expire FROM users WHERE id = " + userId);
                    DataRow row = queryReactor.GetRow();
                    queryReactor.SetQuery("SELECT reg_timestamp, login_timestamp, cfhs, cfhs_abusive, cautions, bans FROM users_info WHERE user_id = " + userId);
                    DataRow row2 = queryReactor.GetRow();
                    if (row == null)
                    {
                        throw new NullReferenceException("User not found in database.");
                    }
                    var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolUserToolMessageComposer"));
                    serverMessage.AppendInteger(Convert.ToUInt32(row["id"]));
                    serverMessage.AppendString((string)row["username"]);
                    serverMessage.AppendString((string)row["look"]);
                    if (row2 != null)
                    {
                        serverMessage.AppendInteger((int)Math.Ceiling((Plus.GetUnixTimeStamp() - (double)row2["reg_timestamp"]) / 60.0));

                        serverMessage.AppendInteger((int)Math.Ceiling((Plus.GetUnixTimeStamp() - (double)row2["login_timestamp"]) / 60.0));
                    }
                    else
                    {
                        serverMessage.AppendInteger(0);
                        serverMessage.AppendInteger(0);
                    }
                    serverMessage.AppendBool(Plus.GetGame().GetClientManager().GetClientByUserId(Convert.ToUInt32(row["id"])) != null);
                    if (row2 != null)
                    {
                        serverMessage.AppendInteger((int)row2["cfhs"]);
                        serverMessage.AppendInteger((int)row2["cfhs_abusive"]);
                        serverMessage.AppendInteger((int)row2["cautions"]);
                        serverMessage.AppendInteger((int)row2["bans"]);
                    }
                    else
                    {
                        serverMessage.AppendInteger(0);
                        serverMessage.AppendInteger(0);
                        serverMessage.AppendInteger(0);
                        serverMessage.AppendInteger(0);
                    }
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendString((row["trade_lock"].ToString() == "1") ? Plus.UnixToDateTime(int.Parse(row["trade_lock_expire"].ToString())).ToLongDateString() : "Not trade-locked");
                    Random _random = new Random();
                    string fakeip  = string.Format("{0}.{1}.{2}.{3}", _random.Next(0, 255), _random.Next(0, 255), _random.Next(0, 255), _random.Next(0, 255));
                    serverMessage.AppendString(((uint)row["rank"] < 6u) ? ((string)row["ip_last"]) : fakeip);
                    serverMessage.AppendInteger(Convert.ToUInt32(row["id"]));
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendString(string.Format("E-Mail:         {0}", row["mail"]));
                    uint Rank = (uint)row["rank"];
                    serverMessage.AppendString((Rank == 12 ? string.Format("Rank ID:        {0}", 1) : string.Format("Rank ID:        {0}", Rank)));

                    result = serverMessage;
                }
                return(result);
            }
        }