Esempio n. 1
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. 2
0
        /// <summary>
        /// Saves the specified room identifier.
        /// </summary>
        /// <param name="queryChunk"></param>
        /// <param name="id">Auto increment</param>
        internal void Save(uint RoomId)
        {

            if(!IsString(Message))
            {
                return;
            }

            if (CheckIfItIsAllreadyExist_text.Contains(Message) && CheckIfItIsAllreadyExist_timestamp.Contains(Plus.DateTimeToUnix(TimeStamp)))
            {
                //Console.WriteLine("[INFO] -> Chatlogs Duplicate attempt!");
            }
            else
            {
                using (var dbClient = Plus.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("INSERT INTO users_chatlogs (user_id, room_id, message, timestamp) VALUES (@user, @room, @message, @time)");
                    dbClient.AddParameter("user", UserId);
                    dbClient.AddParameter("room", RoomId);
                    dbClient.AddParameter("message", Message);
                    dbClient.AddParameter("time", Plus.DateTimeToUnix(TimeStamp));
                    dbClient.RunQuery();
                    CheckIfItIsAllreadyExist_text.Add(Message);
                    CheckIfItIsAllreadyExist_timestamp.Add(Plus.DateTimeToUnix(TimeStamp));
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Runs the database update.
 /// </summary>
 internal void RunDbUpdate()
 {
     try
     {
         if (_mRemovedItems.Count <= 0 && _mAddedItems.Count <= 0 && _inventoryPets.Count <= 0)
         {
             return;
         }
         var queryChunk = new QueryChunk();
         if (_mAddedItems.Count > 0)
         {
             foreach (UserItem userItem in _mAddedItems.Values)
             {
                 queryChunk.AddQuery(string.Format("UPDATE items_rooms SET user_id='{0}', room_id='0' WHERE id='{1}'", UserId, userItem.Id));
             }
             _mAddedItems.Clear();
         }
         if (_mRemovedItems.Count > 0)
         {
             try
             {
                 foreach (UserItem userItem2 in _mRemovedItems.Values)
                 {
                     using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
                         GetClient()
                         .GetHabbo()
                         .CurrentRoom.GetRoomItemHandler()
                         .SaveFurniture(queryReactor);
                     if (SongDisks.Contains(userItem2.Id))
                     {
                         SongDisks.Remove(userItem2.Id);
                     }
                 }
             }
             catch (Exception)
             {
             }
             _mRemovedItems.Clear();
         }
         foreach (Pet current in _inventoryPets.Values)
         {
             if (current.DbState == DatabaseUpdateState.NeedsUpdate)
             {
                 queryChunk.AddParameter(string.Format("{0}name", current.PetId), current.Name);
                 queryChunk.AddParameter(string.Format("{0}race", current.PetId), current.Race);
                 queryChunk.AddParameter(string.Format("{0}color", current.PetId), current.Color);
                 queryChunk.AddQuery(string.Concat(new object[]
                 {
                     "UPDATE bots SET room_id = ",
                     current.RoomId,
                     ", name = @",
                     current.PetId,
                     "name, x = ",
                     current.X,
                     ", Y = ",
                     current.Y,
                     ", Z = ",
                     current.Z,
                     " WHERE id = ",
                     current.PetId
                 }));
                 queryChunk.AddQuery(string.Concat(new object[]
                 {
                     "UPDATE pets_data SET race = @",
                     current.PetId,
                     "race, color = @",
                     current.PetId,
                     "color, type = ",
                     current.Type,
                     ", experience = ",
                     current.Experience,
                     ", energy = ",
                     current.Energy,
                     ", nutrition = ",
                     current.Nutrition,
                     ", respect = ",
                     current.Respect,
                     ", createstamp = '",
                     current.CreationStamp,
                     "', lasthealth_stamp = ",
                     Plus.DateTimeToUnix(current.LastHealth),
                     ", untilgrown_stamp = ",
                     Plus.DateTimeToUnix(current.UntilGrown),
                     " WHERE id = ",
                     current.PetId
                 }));
             }
             current.DbState = DatabaseUpdateState.Updated;
         }
         using (var queryreactor2 = Plus.GetDatabaseManager().GetQueryReactor())
             queryChunk.Execute(queryreactor2);
     }
     catch (Exception ex)
     {
         Logging.LogCacheError(string.Format("FATAL ERROR DURING USER INVENTORY DB UPDATE: {0}", ex));
     }
 }