/// <summary> /// Adds the subscription. /// </summary> /// <param name="dayLength">Length of the day.</param> internal void AddSubscription(double dayLength) { Console.WriteLine("Olá, sou eu!"); int dayTime = Convert.ToInt32(Math.Round(dayLength)); GameClient Session = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(UserID); DateTime Target; Int64 Expire; Int64 LastGift; if (_subscription != null) { Target = PlusEnvironment.UnixTimeStampToDateTime(_subscription.ExpireTime).AddDays(dayTime); Expire = _subscription.ActivateTime; LastGift = _subscription.LastGiftTime; } else { Target = DateTime.Now.AddDays(dayTime); Expire = (long)PlusEnvironment.GetUnixTimestamp(); LastGift = (long)PlusEnvironment.GetUnixTimestamp(); } long UnixTimestamp = PlusEnvironment.DateTimeToUnixTimeStamp(Target); _subscription = new SubscriptionData(2, Expire, UnixTimestamp, LastGift); using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("REPLACE INTO `user_subscriptions` VALUES (@userid, '2', @expiry, @timestamp, @lastgift)"); dbClient.AddParameter("userid", UserID); dbClient.AddParameter("expiry", Expire); dbClient.AddParameter("timestamp", UnixTimestamp); dbClient.AddParameter("lastgift", LastGift); dbClient.RunQuery(); } Session.SendMessage(new ScrSendUserInfoComposer(Session)); }