Example #1
0
        internal void BanzaiStart()
        {
            if (IsBanzaiActive)
            {
                return;
            }

            _room.GetGameManager().StartGame();
            _floorMap    = new byte[_room.GetGameMap().Model.MapSizeY, _room.GetGameMap().Model.MapSizeX];
            _field       = new GameField(_floorMap, true);
            _timestarted = Yupi.GetUnixTimeStamp();
            _room.GetGameManager().LockGates();

            for (int i = 1; i < 5; i++)
            {
                _room.GetGameManager().Points[i] = 0;
            }

            foreach (RoomItem roomItem in BanzaiTiles.Values)
            {
                roomItem.ExtraData = "1";
                roomItem.Value     = 0;
                roomItem.Team      = Team.None;
                roomItem.UpdateState();
            }

            ResetTiles();
            IsBanzaiActive = true;
            _room.GetWiredHandler().ExecuteWired(Interaction.TriggerGameStart);

            foreach (RoomUser roomUser in _room.GetRoomUserManager().GetRoomUsers())
            {
                roomUser.LockedTilesCount = 0;
            }
        }
Example #2
0
        /// <summary>
        ///     Serializes the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns>ServerMessage.</returns>
        internal ServerMessage Serialize(ServerMessage message)
        {
            message.AppendInteger(TicketId);
            message.AppendInteger(TabId);
            message.AppendInteger(Type); // type (3 or 4 for new style)
            message.AppendInteger(Category);
            message.AppendInteger((Yupi.GetUnixTimeStamp() - (int)Timestamp) * 1000);
            message.AppendInteger(Score);
            message.AppendInteger(1);
            message.AppendInteger(SenderId);
            message.AppendString(_senderName);
            message.AppendInteger(ReportedId);
            message.AppendString(_reportedName);
            message.AppendInteger(Status == TicketStatus.Picked ? ModeratorId : 0);
            message.AppendString(_modName);
            message.AppendString(Message);
            message.AppendInteger(0);

            message.AppendInteger(ReportedChats.Count);

            foreach (string str in ReportedChats)
            {
                message.AppendString(str);
                message.AppendInteger(-1);
                message.AppendInteger(-1);
            }

            return(message);
        }
Example #3
0
        public override bool Execute(GameClient session, string[] pms)
        {
            GameClient client = Yupi.GetGame().GetClientManager().GetClientByUserName(pms[0]);

            if (client == null)
            {
                session.SendWhisper(Yupi.GetLanguage().GetVar("user_not_found"));
                return(true);
            }
            if (client.GetHabbo().Rank >= session.GetHabbo().Rank)
            {
                session.SendWhisper(Yupi.GetLanguage().GetVar("user_is_higher_rank"));
                return(true);
            }
            int time;

            if (!int.TryParse(pms[1], out time))
            {
                session.SendWhisper(Yupi.GetLanguage().GetVar("enter_numbers"));
                return(true);
            }

            client.GetHabbo().FloodTime = Yupi.GetUnixTimeStamp() + Convert.ToInt32(pms[1]);
            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("FloodFilterMessageComposer"));

            serverMessage.AppendInteger(Convert.ToInt32(pms[1]));
            client.SendMessage(serverMessage);
            return(true);
        }
Example #4
0
        /// <summary>
        ///     Serializes the event information.
        /// </summary>
        /// <param name="roomId">The room identifier.</param>
        internal void SerializeEventInfo(uint roomId)
        {
            Room room = Yupi.GetGame().GetRoomManager().GetRoom(roomId);

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

            if (@event == null || @event.HasExpired)
            {
                return;
            }
            if (!RoomHasEvents(roomId))
            {
                return;
            }
            ServerMessage 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 - Yupi.GetUnixTimeStamp()) / 60.0));

            serverMessage.AppendInteger(@event.Category);
            room.SendMessage(serverMessage);
        }
Example #5
0
        public bool Execute(params object[] stuff)
        {
            int date1;
            int date2 = 0;

            string[] strArray = OtherString.Split(',');

            if (string.IsNullOrWhiteSpace(strArray[0]))
            {
                return(false);
            }

            int.TryParse(strArray[0], out date1);

            if (strArray.Length > 1)
            {
                int.TryParse(strArray[1], out date2);
            }

            if (date1 == 0)
            {
                return(false);
            }

            int currentTimestamp = Yupi.GetUnixTimeStamp();

            return(date2 < 1 ? currentTimestamp >= date1 : currentTimestamp >= date1 && currentTimestamp <= date2);
        }
Example #6
0
        /// <summary>
        ///     Activates the effect.
        /// </summary>
        /// <param name="effectId">The effect identifier.</param>
        internal void ActivateEffect(int effectId)
        {
            if (!_session.GetHabbo().InRoom)
            {
                return;
            }

            if (!HasEffect(effectId))
            {
                return;
            }

            if (effectId < 1)
            {
                ActivateCustomEffect(effectId);
            }

            if (effectId < 1)
            {
                return;
            }

            AvatarEffect avatarEffect = _effects.Last(x => x.EffectId == effectId);

            avatarEffect.Activate();

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery(
                    string.Concat("UPDATE users_effects SET is_activated = '1', activated_stamp = ",
                                  Yupi.GetUnixTimeStamp(), " WHERE user_id = ", _userId, " AND effect_id = ", effectId));

            EnableInRoom(effectId);
        }
Example #7
0
        /// <summary>
        ///     Adds the subscription.
        /// </summary>
        /// <param name="dayLength">Length of the day.</param>
        internal void AddSubscription(double dayLength)
        {
            int num = (int)Math.Round(dayLength);

            GameClient clientByUserId = Yupi.GetGame().GetClientManager().GetClientByUserId(_userId);
            DateTime   target;
            int        num2;
            int        num3;

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

            int num4 = Yupi.DateTimeToUnix(target);

            _subscription = new Subscription(2, num2, num4, num3);

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery(string.Concat("REPLACE INTO users_subscriptions VALUES (", _userId, ", 2, ",
                                                        num2, ", ", num4, ", ", num3, ");"));

            clientByUserId.GetHabbo().SerializeClub();
            Yupi.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(clientByUserId);
        }
Example #8
0
 /// <summary>
 ///     Databases the cleanup.
 /// </summary>
 /// <param name="dbClient">The database client.</param>
 private static void DatabaseCleanup(IQueryAdapter dbClient)
 {
     dbClient.RunFastQuery("UPDATE users SET online = '0' WHERE online <> '0'");
     dbClient.RunFastQuery("UPDATE rooms_data SET users_now = 0 WHERE users_now <> 0");
     dbClient.RunFastQuery(
         "UPDATE `server_status` SET status = '1', users_online = '0', rooms_loaded = '0', server_ver = 'Yupi Emulator', stamp = '" +
         Yupi.GetUnixTimeStamp() + "' LIMIT 1;");
 }
Example #9
0
        /// <summary>
        /// Determines whether this instance can talk the specified session.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="message">The message.</param>
        /// <returns><c>true</c> if this instance can talk the specified session; otherwise, <c>false</c>.</returns>
        internal static bool CanTalk(GameClient session, string message)
        {
            if (CheckForBannedPhrases(message) && session.GetHabbo().Rank < 4)
            {
                if (!Yupi.MutedUsersByFilter.ContainsKey(session.GetHabbo().Id))
                {
                    session.GetHabbo().BobbaFiltered++;
                }

                if (session.GetHabbo().BobbaFiltered < 3)
                {
                    session.SendNotif("Your language is inappropriate. If you do not change this , measures are being taken by the automated system of Habbo.");
                }
                else if (session.GetHabbo().BobbaFiltered >= 3)
                {
                    if (session.GetHabbo().BobbaFiltered == 3)
                    {
                        session.GetHabbo().BobbaFiltered = 4;
                        Yupi.MutedUsersByFilter.Add(session.GetHabbo().Id, uint.Parse((Yupi.GetUnixTimeStamp() + 300 * 60).ToString()));

                        return(false);
                    }

                    if (session.GetHabbo().BobbaFiltered == 4)
                    {
                        session.SendNotif("Now you can not talk for 5 minutes . This is because your exhibits inappropriate language in Habbo Hotel.");
                    }
                    else if (session.GetHabbo().BobbaFiltered == 5)
                    {
                        session.SendNotif("You risk a ban if you continue to scold it . This is your last warning");
                    }
                    else if (session.GetHabbo().BobbaFiltered >= 7)
                    {
                        session.GetHabbo().BobbaFiltered = 0;

                        Yupi.GetGame().GetBanManager().BanUser(session, "Auto-system-ban", 3600, "ban.", false, false);
                    }
                }
            }

            if (Yupi.MutedUsersByFilter.ContainsKey(session.GetHabbo().Id))
            {
                if (Yupi.MutedUsersByFilter[session.GetHabbo().Id] < Yupi.GetUnixTimeStamp())
                {
                    Yupi.MutedUsersByFilter.Remove(session.GetHabbo().Id);
                }
                else
                {
                    DateTime now             = DateTime.Now;
                    TimeSpan timeStillBanned = now - Yupi.UnixToDateTime(Yupi.MutedUsersByFilter[session.GetHabbo().Id]);

                    session.SendNotif("Damn! you can't talk for " + timeStillBanned.Minutes.ToString().Replace("-", "") + " minutes and " + timeStillBanned.Seconds.ToString().Replace("-", "") + " seconds.");
                    return(false);
                }
            }

            return(true);
        }
Example #10
0
        /// <summary>
        ///     Loads the bans.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void LoadBans(IQueryAdapter dbClient)
        {
            _bannedUsernames.Clear();
            _bannedIPs.Clear();
            _bannedMachines.Clear();
            dbClient.SetQuery("SELECT bantype,value,reason,expire FROM users_bans");
            DataTable table = dbClient.GetTable();
            double num = Yupi.GetUnixTimeStamp();

            foreach (DataRow dataRow in table.Rows)
            {
                string text = (string) dataRow["value"];
                string reasonMessage = (string) dataRow["reason"];
                double num2 = (double) dataRow["expire"];
                string a = (string) dataRow["bantype"];

                ModerationBanType type;

                switch (a)
                {
                    case "user":
                        type = ModerationBanType.UserName;
                        break;

                    case "ip":
                        type = ModerationBanType.Ip;
                        break;

                    default:
                        type = ModerationBanType.Machine;
                        break;
                }

                ModerationBan moderationBan = new ModerationBan(type, text, reasonMessage, num2);

                if (!(num2 > num))
                    continue;

                switch (moderationBan.Type)
                {
                    case ModerationBanType.UserName:
                        if (!_bannedUsernames.Contains(text))
                            _bannedUsernames.Add(text, moderationBan);
                        break;

                    case ModerationBanType.Ip:
                        if (!_bannedIPs.Contains(text))
                            _bannedIPs.Add(text, moderationBan);
                        break;

                    default:
                        if (!_bannedMachines.ContainsKey(text))
                            _bannedMachines.Add(text, moderationBan);
                        break;
                }
            }
        }
Example #11
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="RoomEvent" /> class.
        /// </summary>
        /// <param name="roomId">The room identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="time">The time.</param>
        /// <param name="category">The category.</param>
        internal RoomEvent(uint roomId, string name, string description, int time = 0, int category = 1)
        {
            RoomId      = roomId;
            Name        = name;
            Description = description;
            Time        = time == 0 ? Yupi.GetUnixTimeStamp() + 7200 : time;

            Category = category;
        }
Example #12
0
        /// <summary>
        ///     Serializes the club.
        /// </summary>
        internal void SerializeClub()
        {
            GameClient    client        = GetClient();
            ServerMessage serverMessage = new ServerMessage();

            serverMessage.Init(LibraryParser.OutgoingRequest("SubscriptionStatusMessageComposer"));
            serverMessage.AppendString("club_habbo");
            if (client.GetHabbo().GetSubscriptionManager().HasSubscription)
            {
                double num  = client.GetHabbo().GetSubscriptionManager().GetSubscription().ExpireTime;
                double num2 = num - Yupi.GetUnixTimeStamp();
                int    num3 = (int)Math.Ceiling(num2 / 86400.0);
                int    i    =
                    (int)
                    Math.Ceiling((Yupi.GetUnixTimeStamp() -
                                  (double)client.GetHabbo().GetSubscriptionManager().GetSubscription().ActivateTime) /
                                 86400.0);
                int num4 = num3 / 31;

                if (num4 >= 1)
                {
                    num4--;
                }

                serverMessage.AppendInteger(num3 - num4 * 31);
                serverMessage.AppendInteger(1);
                serverMessage.AppendInteger(num4);
                serverMessage.AppendInteger(1);
                serverMessage.AppendBool(true);
                serverMessage.AppendBool(true);
                serverMessage.AppendInteger(i);
                serverMessage.AppendInteger(i);
                serverMessage.AppendInteger(10);
            }
            else
            {
                serverMessage.AppendInteger(0);
                serverMessage.AppendInteger(0);
                serverMessage.AppendInteger(0);
                serverMessage.AppendInteger(0);
                serverMessage.AppendBool(false);
                serverMessage.AppendBool(false);
                serverMessage.AppendInteger(0);
                serverMessage.AppendInteger(0);
                serverMessage.AppendInteger(0);
            }

            client.SendMessage(serverMessage);

            ServerMessage serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("UserClubRightsMessageComposer"));

            serverMessage2.AppendInteger(GetSubscriptionManager().HasSubscription ? 2 : 0);
            serverMessage2.AppendInteger(Rank);
            serverMessage2.AppendBool(Rank >= Convert.ToUInt32(Yupi.GetDbConfig().DbData["ambassador.minrank"]));

            client.SendMessage(serverMessage2);
        }
Example #13
0
        /// <summary>
        ///     Serializes the offline messages.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns>ServerMessage.</returns>
        internal ServerMessage SerializeOfflineMessages(OfflineMessage message)
        {
            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ConsoleChatMessageComposer"));

            serverMessage.AppendInteger(message.FromId);
            serverMessage.AppendString(message.Message);
            serverMessage.AppendInteger((int)(Yupi.GetUnixTimeStamp() - message.Timestamp));

            return(serverMessage);
        }
Example #14
0
        /// <summary>
        ///     Adds the new event.
        /// </summary>
        /// <param name="roomId">The room identifier.</param>
        /// <param name="eventName">Name of the event.</param>
        /// <param name="eventDesc">The event desc.</param>
        /// <param name="session">The session.</param>
        /// <param name="time">The time.</param>
        /// <param name="category">The category.</param>
        internal void AddNewEvent(uint roomId, string eventName, string eventDesc, GameClient session, int time = 7200,
                                  int category = 1)
        {
            {
                if (_events.ContainsKey(roomId))
                {
                    RoomEvent roomEvent = _events[roomId];
                    roomEvent.Name        = eventName;
                    roomEvent.Description = eventDesc;
                    if (roomEvent.HasExpired)
                    {
                        roomEvent.Time = Yupi.GetUnixTimeStamp() + time;
                    }
                    else
                    {
                        roomEvent.Time += time;
                    }
                    using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                    {
                        commitableQueryReactor.SetQuery(
                            "REPLACE INTO rooms_events VALUES ('@id','@name','@desc','@time','@category')");
                        commitableQueryReactor.AddParameter("id", roomId);
                        commitableQueryReactor.AddParameter("name", eventName);
                        commitableQueryReactor.AddParameter("desc", eventDesc);
                        commitableQueryReactor.AddParameter("time", roomEvent.Time);
                        commitableQueryReactor.AddParameter("category", category);
                        commitableQueryReactor.RunQuery();
                        goto IL_17C;
                    }
                }
                using (IQueryAdapter queryreactor2 = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    queryreactor2.SetQuery(string.Concat("REPLACE INTO rooms_events VALUES (", roomId,
                                                         ", @name, @desc, ", Yupi.GetUnixTimeStamp() + 7200, ", @category)"));
                    queryreactor2.AddParameter("name", eventName);
                    queryreactor2.AddParameter("desc", eventDesc);
                    queryreactor2.AddParameter("category", category);
                    queryreactor2.RunQuery();
                }
                _events.Add(roomId, new RoomEvent(roomId, eventName, eventDesc));
IL_17C:
                Yupi.GetGame().GetRoomManager().GenerateRoomData(roomId).Event = _events[roomId];
                Room room = Yupi.GetGame().GetRoomManager().GetRoom(roomId);
                if (room != null)
                {
                    room.RoomData.Event = _events[roomId];
                }
                if (session.GetHabbo().CurrentRoomId == roomId)
                {
                    SerializeEventInfo(roomId);
                }
            }
        }
Example #15
0
        /// <summary>
        ///     Runs the database update.
        /// </summary>
        internal void RunDbUpdate()
        {
            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.RunFastQuery(
                    $"UPDATE users_stats SET achievement_score = '{AchievementPoints}' WHERE id = {Id}");
                queryReactor.RunFastQuery(
                    $"UPDATE users SET last_online = '{Yupi.GetUnixTimeStamp()}', activity_points = '{Duckets}', credits = '{Credits}', diamonds = '{Diamonds}' WHERE id = '{Id}'");
            }

            _habboinfoSaved = true;
        }
Example #16
0
        /// <summary>
        ///     Processes the thread.
        /// </summary>
        internal static void ProcessThread()
        {
            double num = Yupi.GetUnixTimeStamp();

            List <uint> list = (from current in _cacheTimer where num - current.Value >= 180.0 select current.Key).ToList();

            foreach (uint current2 in list)
            {
                Songs.Remove(current2);
                _cacheTimer.Remove(current2);
            }
        }
Example #17
0
        /// <summary>
        ///     Processes the specified caller.
        /// </summary>
        internal static void Process()
        {
            if (_lowPriorityStopWatch.ElapsedMilliseconds >= 30000 || !_isExecuted)
            {
                _isExecuted = true;

                _lowPriorityStopWatch.Restart();

                try
                {
                    int realOnlineClientCount = Yupi.GetGame().GetClientManager().GetOnlineClients();
                    int clientCount           = Yupi.GetGame().GetClientManager().ClientCount();

                    if (realOnlineClientCount != clientCount)
                    {
                        Writer.WriteLine("Number of Clients isn't Equal of Online Users. Running Analysis", "Yupi.Game",
                                         ConsoleColor.DarkYellow);
                    }

                    if (realOnlineClientCount != clientCount)
                    {
                        Yupi.GetGame().GetClientManager().RemoveNotOnlineUsers();
                    }

                    int loadedRoomsCount = Yupi.GetGame().GetRoomManager().LoadedRoomsCount;

                    DateTime dateTime = new DateTime((DateTime.Now - Yupi.ServerStarted).Ticks);

                    Console.Title = string.Concat("Yupi | Time: ", int.Parse(dateTime.ToString("dd")) - 1, "d:",
                                                  dateTime.ToString("HH"), "h:", dateTime.ToString("mm"), "m | Conn: ", clientCount, " | Users: ",
                                                  realOnlineClientCount, " | Rooms: ", loadedRoomsCount);

                    using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                    {
                        if (clientCount > _userPeak || realOnlineClientCount > _userPeak)
                        {
                            _userPeak = realOnlineClientCount;
                        }

                        commitableQueryReactor.RunFastQuery(string.Concat("UPDATE server_status SET stamp = '",
                                                                          Yupi.GetUnixTimeStamp(), "', users_online = ", realOnlineClientCount, ", rooms_loaded = ",
                                                                          loadedRoomsCount, ", server_ver = 'Yupi Emulator', userpeak = ", _userPeak));
                    }

                    Yupi.GetGame().GetNavigator().LoadNewPublicRooms();
                }
                catch (Exception e)
                {
                    ServerLogManager.LogException(e, MethodBase.GetCurrentMethod());
                }
            }
        }
Example #18
0
        /// <summary>
        ///     Sends the new ticket.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="category">The category.</param>
        /// <param name="type">The type.</param>
        /// <param name="reportedUser">The reported user.</param>
        /// <param name="message">The message.</param>
        /// <param name="messages">The messages.</param>
        internal void SendNewTicket(GameClient session, int category, int type, uint reportedUser, string message,
                                    List <string> messages)
        {
            uint id;

            if (session.GetHabbo().CurrentRoomId <= 0)
            {
                using (IQueryAdapter dbClient = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery(
                        string.Concat(
                            "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, "','", reportedUser,
                            "','0',@message,'0','','", Yupi.GetUnixTimeStamp(), "')"));
                    dbClient.AddParameter("message", message);
                    id = (uint)dbClient.InsertQuery();
                    dbClient.RunFastQuery(
                        $"UPDATE users_info SET cfhs = cfhs + 1 WHERE user_id = {session.GetHabbo().Id}");
                }

                SupportTicket ticket = new SupportTicket(id, 1, category, type, session.GetHabbo().Id, reportedUser, message, 0u,
                                                         "", Yupi.GetUnixTimeStamp(), messages);

                Tickets.Add(ticket);
                SendTicketToModerators(ticket);
            }
            else
            {
                RoomData data = Yupi.GetGame().GetRoomManager().GenerateNullableRoomData(session.GetHabbo().CurrentRoomId);

                using (IQueryAdapter dbClient = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery(
                        string.Concat(
                            "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, "','", reportedUser, "','0',@message,'",
                            data.Id, "',@name,'", Yupi.GetUnixTimeStamp(), "')"));
                    dbClient.AddParameter("message", message);
                    dbClient.AddParameter("name", data.Name);
                    id = (uint)dbClient.InsertQuery();
                    dbClient.RunFastQuery(
                        $"UPDATE users_info SET cfhs = cfhs + 1 WHERE user_id = {session.GetHabbo().Id}");
                }

                SupportTicket ticket2 = new SupportTicket(id, 1, category, type, session.GetHabbo().Id, reportedUser, message,
                                                          data.Id, data.Name, Yupi.GetUnixTimeStamp(), messages);

                Tickets.Add(ticket2);
                SendTicketToModerators(ticket2);
            }
        }
Example #19
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Quest" /> class.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <param name="category">The category.</param>
 /// <param name="number">The number.</param>
 /// <param name="goalType">Type of the goal.</param>
 /// <param name="goalData">The goal data.</param>
 /// <param name="name">The name.</param>
 /// <param name="reward">The reward.</param>
 /// <param name="dataBit">The data bit.</param>
 /// <param name="rewardType">Type of the reward.</param>
 /// <param name="timeUnlock">The time unlock.</param>
 /// <param name="timeLock">The time lock.</param>
 public Quest(int id, string category, int number, QuestType goalType, uint goalData, string name, int reward, string dataBit, int rewardType, int timeUnlock, int timeLock)
 {
     Id         = id;
     Category   = category;
     Number     = number;
     GoalType   = goalType;
     GoalData   = goalData;
     Name       = name;
     Reward     = reward;
     DataBit    = dataBit;
     RewardType = rewardType;
     TimeUnlock = timeUnlock;
     HasEnded   = timeLock >= Yupi.GetUnixTimeStamp() && timeLock > 0;
 }
Example #20
0
        /// <summary>
        /// Games the center join queue.
        /// </summary>
        internal void GameCenterJoinQueue()
        {
            ServerMessage joinQueue = new ServerMessage(LibraryParser.OutgoingRequest("GameCenterJoinGameQueueMessageComposer"));

            joinQueue.AppendInteger(18);
            Session.SendMessage(joinQueue);

            ServerMessage loadGame = new ServerMessage(LibraryParser.OutgoingRequest("GameCenterLoadGameUrlMessageComposer"));

            loadGame.AppendInteger(18);
            loadGame.AppendString(Convert.ToString(Yupi.GetUnixTimeStamp()));
            loadGame.AppendString(ServerExtraSettings.GameCenterStoriesUrl);
            Session.SendMessage(loadGame);
        }
Example #21
0
        /// <summary>
        ///     Check if the previous issue of an user was abusive
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        internal bool UsersHasAbusiveCooldown(uint id)
        {
            foreach (KeyValuePair <uint, double> item in AbusiveCooldown)
            {
                if (AbusiveCooldown.ContainsKey(id) && item.Value - Yupi.GetUnixTimeStamp() > 0)
                {
                    return(true);
                }

                AbusiveCooldown.Remove(id);
                return(false);
            }
            return(false);
        }
Example #22
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 serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolUserToolMessageComposer"));

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                if (queryReactor != null)
                {
                    queryReactor.SetQuery(
                        "SELECT id, username, mail, look, trade_lock, trade_lock_expire, rank, ip_last, " +
                        "IFNULL(cfhs, 0) cfhs, IFNULL(cfhs_abusive, 0) cfhs_abusive, IFNULL(cautions, 0) cautions, IFNULL(bans, 0) bans, " +
                        "IFNULL(reg_timestamp, 0) reg_timestamp, IFNULL(login_timestamp, 0) login_timestamp " +
                        $"FROM users left join users_info on (users.id = users_info.user_id) WHERE id = '{userId}' LIMIT 1"
                        );

                    DataRow row = queryReactor.GetRow();

                    uint id = Convert.ToUInt32(row["id"]);
                    serverMessage.AppendInteger(id);
                    serverMessage.AppendString(row["username"].ToString());
                    serverMessage.AppendString(row["look"].ToString());
                    double regTimestamp   = (double)row["reg_timestamp"];
                    double loginTimestamp = (double)row["login_timestamp"];
                    int    unixTimestamp  = Yupi.GetUnixTimeStamp();
                    serverMessage.AppendInteger(
                        (int)(regTimestamp > 0 ? Math.Ceiling((unixTimestamp - regTimestamp) / 60.0) : regTimestamp));
                    serverMessage.AppendInteger(
                        (int)
                        (loginTimestamp > 0 ? Math.Ceiling((unixTimestamp - loginTimestamp) / 60.0) : loginTimestamp));
                    serverMessage.AppendBool(true);
                    serverMessage.AppendInteger(Convert.ToInt32(row["cfhs"]));
                    serverMessage.AppendInteger(Convert.ToInt32(row["cfhs_abusive"]));
                    serverMessage.AppendInteger(Convert.ToInt32(row["cautions"]));
                    serverMessage.AppendInteger(Convert.ToInt32(row["bans"]));

                    serverMessage.AppendInteger(0);
                    uint rank = (uint)row["rank"];
                    serverMessage.AppendString(row["trade_lock"].ToString() == "1"
                        ? Yupi.UnixToDateTime(int.Parse(row["trade_lock_expire"].ToString())).ToLongDateString()
                        : "Not trade-locked");
                    serverMessage.AppendString(rank < 6 ? row["ip_last"].ToString() : "127.0.0.1");
                    serverMessage.AppendInteger(id);
                    serverMessage.AppendInteger(0);

                    serverMessage.AppendString($"E-Mail:         {row["mail"]}");
                    serverMessage.AppendString($"Rank ID:        {rank}");
                }
            }
            return(serverMessage);
        }
Example #23
0
        /// <summary>
        ///     Creates the theGroup.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="desc">The desc.</param>
        /// <param name="roomId">The room identifier.</param>
        /// <param name="badge">The badge.</param>
        /// <param name="session">The session.</param>
        /// <param name="colour1">The colour1.</param>
        /// <param name="colour2">The colour2.</param>
        /// <param name="group">The theGroup.</param>
        internal void CreateGroup(string name, string desc, uint roomId, string badge, GameClient session, int colour1,
                                  int colour2, out Group group)
        {
            Habbo user = session.GetHabbo();
            Dictionary <uint, GroupMember> emptyDictionary = new Dictionary <uint, GroupMember>();

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(
                    $"INSERT INTO groups_data (group_name, group_description, group_badge, owner_id, created, room_id, colour1, colour2) VALUES(@name,@desc,@badge,'{session.GetHabbo().Id}',UNIX_TIMESTAMP(),'{roomId}','{colour1}','{colour2}')");
                queryReactor.AddParameter("name", name);
                queryReactor.AddParameter("desc", desc);
                queryReactor.AddParameter("badge", badge);

                uint id = (uint)queryReactor.InsertQuery();

                queryReactor.RunFastQuery($"UPDATE rooms_data SET group_id='{id}' WHERE id='{roomId}' LIMIT 1");

                GroupMember memberGroup = new GroupMember(user.Id, user.UserName, user.Look, id, 2, Yupi.GetUnixTimeStamp());
                Dictionary <uint, GroupMember> dictionary = new Dictionary <uint, GroupMember> {
                    { session.GetHabbo().Id, memberGroup }
                };

                group = new Group(id, name, desc, roomId, badge, Yupi.GetUnixTimeStamp(), user.Id, colour1, colour2,
                                  dictionary, emptyDictionary, emptyDictionary, 0, 1,
                                  new GroupForum(0, string.Empty, string.Empty, 0, 0, 0, string.Empty, 0, 0, 1, 1, 2));

                Groups.Add(id, group);

                queryReactor.RunFastQuery(
                    $"INSERT INTO groups_members (group_id, user_id, rank, date_join) VALUES ('{id}','{session.GetHabbo().Id}','2','{Yupi.GetUnixTimeStamp()}')");

                Room room = Yupi.GetGame().GetRoomManager().GetRoom(roomId);

                if (room != null)
                {
                    room.RoomData.Group   = group;
                    room.RoomData.GroupId = id;
                }

                user.UserGroups.Add(memberGroup);
                group.Admins.Add(user.Id, memberGroup);

                queryReactor.RunFastQuery(
                    $"UPDATE users_stats SET favourite_group='{id}' WHERE id='{user.Id}' LIMIT 1");
                queryReactor.RunFastQuery($"DELETE FROM rooms_rights WHERE room_id='{roomId}'");
            }
        }
Example #24
0
        /// <summary>
        ///     Picks the specified p moderator identifier.
        /// </summary>
        /// <param name="pModeratorId">The p moderator identifier.</param>
        /// <param name="updateInDb">if set to <c>true</c> [update in database].</param>
        internal void Pick(uint pModeratorId, bool updateInDb)
        {
            Status      = TicketStatus.Picked;
            ModeratorId = pModeratorId;
            _modName    = Yupi.GetHabboById(pModeratorId).UserName;

            if (!updateInDb)
            {
                return;
            }

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery(
                    string.Concat("UPDATE moderation_tickets SET status = 'picked', moderator_id = ", pModeratorId,
                                  ", timestamp = '", Yupi.GetUnixTimeStamp(), "' WHERE id = ", TicketId));
        }
Example #25
0
        /// <summary>
        ///     Checks the trading.
        /// </summary>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        internal bool CheckTrading()
        {
            if (!TradeLocked)
            {
                return(true);
            }

            if (TradeLockExpire - Yupi.GetUnixTimeStamp() > 0)
            {
                return(false);
            }

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery($"UPDATE users SET trade_lock = '0' WHERE id = {Id}");

            TradeLocked = false;
            return(true);
        }
Example #26
0
        /// <summary>
        ///     Creates the pet.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="type">The type.</param>
        /// <param name="race">The race.</param>
        /// <param name="color">The color.</param>
        /// <param name="rarity">The rarity.</param>
        /// <returns>Pet.</returns>
        internal static Pet CreatePet(uint userId, string name, string type, string race, string color, int rarity = 0)
        {
            uint trace = Convert.ToUInt32(race);

            uint petId = 404u;

            Pet pet = new Pet(petId, userId, 0u, name, type, trace, 0, 100, 150, 0, Yupi.GetUnixTimeStamp(), 0, 0, 0.0,
                              false, 0, 0, -1, rarity, DateTime.Now.AddHours(36.0), DateTime.Now.AddHours(48.0), null, color)
            {
                DbState = DatabaseUpdateState.NeedsUpdate
            };

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(
                    "INSERT INTO pets_data (user_id, name, ai_type, pet_type, race_id, experience, energy, createstamp, rarity, lasthealth_stamp, untilgrown_stamp, color) " +
                    $"VALUES ('{pet.OwnerId}', @petName, 'pet', @petType, @petRace, 0, 100, UNIX_TIMESTAMP(), '{rarity}', UNIX_TIMESTAMP(now() + INTERVAL 36 HOUR), UNIX_TIMESTAMP(now() + INTERVAL 48 HOUR), @petColor)");

                queryReactor.AddParameter("petName", pet.Name);
                queryReactor.AddParameter("petType", pet.Type);
                queryReactor.AddParameter("petRace", pet.Race);
                queryReactor.AddParameter("petColor", pet.Color);

                petId = (uint)queryReactor.InsertQuery();
            }

            pet.PetId = petId;

            if (pet.Type == "pet_monster")
            {
                pet.MoplaBreed = MoplaBreed.CreateMonsterplantBreed(pet);
                pet.Name       = pet.MoplaBreed.Name;
                pet.DbState    = DatabaseUpdateState.NeedsUpdate;
            }

            GameClient clientByUserId = Yupi.GetGame().GetClientManager().GetClientByUserId(userId);

            if (clientByUserId != null)
            {
                Yupi.GetGame().GetAchievementManager().ProgressUserAchievement(clientByUserId, "ACH_PetLover", 1);
            }

            return(pet);
        }
Example #27
0
        /// <summary>
        ///     Tries the progress login achievements.
        /// </summary>
        /// <param name="session">The session.</param>
        internal void TryProgressLoginAchievements(GameClient session)
        {
            if (session.GetHabbo() == null)
            {
                return;
            }

            if (session.GetHabbo().Achievements.ContainsKey("ACH_Login"))
            {
                int daysBtwLastLogin = Yupi.GetUnixTimeStamp() - session.GetHabbo().PreviousOnline;

                if (daysBtwLastLogin >= 51840 && daysBtwLastLogin <= 112320)
                {
                    ProgressUserAchievement(session, "ACH_Login", 1, true);
                }

                return;
            }

            ProgressUserAchievement(session, "ACH_Login", 1, true);
        }
Example #28
0
        /// <summary>
        ///     Tries the progress registration achievements.
        /// </summary>
        /// <param name="session">The session.</param>
        internal void TryProgressRegistrationAchievements(GameClient session)
        {
            if (session.GetHabbo() == null)
            {
                return;
            }

            if (session.GetHabbo().Achievements.ContainsKey("ACH_RegistrationDuration"))
            {
                UserAchievement regAch = session.GetHabbo().GetAchievementData("ACH_RegistrationDuration");

                if (regAch.Level == 5)
                {
                    return;
                }

                double sinceMember = Yupi.GetUnixTimeStamp() - (int)session.GetHabbo().CreateDate;

                uint daysSinceMember = Convert.ToUInt32(Math.Round(sinceMember / 86400));

                if (daysSinceMember == regAch.Progress)
                {
                    return;
                }

                uint days = daysSinceMember - regAch.Progress;

                if (days < 1)
                {
                    return;
                }

                ProgressUserAchievement(session, "ACH_RegistrationDuration", days);

                return;
            }

            ProgressUserAchievement(session, "ACH_RegistrationDuration", 1, true);
        }
Example #29
0
        /// <summary>
        ///     Locks the trade.
        /// </summary>
        /// <param name="modSession">The mod session.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="message">The message.</param>
        /// <param name="length">The length.</param>
        internal static void LockTrade(GameClient modSession, uint userId, string message, int length)
        {
            GameClient clientByUserId = Yupi.GetGame().GetClientManager().GetClientByUserId(userId);

            if (clientByUserId == null)
            {
                return;
            }

            if (!clientByUserId.GetHabbo().CheckTrading())
            {
                length += Yupi.GetUnixTimeStamp() - clientByUserId.GetHabbo().TradeLockExpire;
            }

            clientByUserId.GetHabbo().TradeLocked     = true;
            clientByUserId.GetHabbo().TradeLockExpire = Yupi.GetUnixTimeStamp() + length;
            clientByUserId.SendNotif(message);

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery(
                    $"UPDATE users SET trade_lock = '1', trade_lock_expire = '{clientByUserId.GetHabbo().TradeLockExpire}' WHERE id = '{clientByUserId.GetHabbo().Id}'");
        }
Example #30
0
        /// <summary>
        ///     Plays the song.
        /// </summary>
        public void PlaySong()
        {
            if (SongQueuePosition >= _mPlaylist.Count)
            {
                SongQueuePosition = 0;
            }

            lock (_mPlaylist)
            {
                if (!_mPlaylist.Any())
                {
                    Stop();
                    return;
                }
            }

            lock (_mPlaylist)
                CurrentSong = _mPlaylist[SongQueuePosition];

            _mStartedPlayingTimestamp = Yupi.GetUnixTimeStamp();
            _mBroadcastNeeded         = true;
        }