Ejemplo n.º 1
0
        internal void GetGroupUsersPage(int PageCount, ServerMessage Message)
        {
            List <GroupUser> users = new List <GroupUser>();

            DataTable dTable = null;

            using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT userid, rank, joined FROM groups_users WHERE groupid = '" + Id + "' ORDER BY rank ASC LIMIT " + (PageCount * 14) + ", 14");
                dTable = dbClient.getTable();
            }

            Message.AppendInt32(dTable.Rows.Count);
            foreach (DataRow dRow in dTable.Rows)
            {
                var zUser = UsersCache.getHabboCache(Convert.ToUInt32(dRow["userid"]));
                if (zUser == null)
                {
                    Message.AppendInt32(2);
                    Message.AppendInt32(0);
                    Message.AppendString("BUGUED");
                    Message.AppendString("");
                    Message.AppendString(""); // Se ha unido el.

                    continue;
                }

                Message.AppendInt32((int)dRow["rank"]);
                Message.AppendInt32((int)dRow["userid"]);
                Message.AppendString(zUser.Username);
                Message.AppendString(zUser.Look);
                Message.AppendString((string)dRow["joined"]); // Se ha unido el.
            }
        }
Ejemplo n.º 2
0
        internal static ServerMessage SerializeRoomTool(UInt32 RoomId)
        {
            var Room = OtanixEnvironment.GetGame().GetRoomManager().GetRoom(RoomId);

            if (Room == null || Room.RoomData == null)
            {
                return(null);
            }

            Habbo Owner = UsersCache.getHabboCache(Room.RoomData.OwnerId);

            var Message = new ServerMessage(Outgoing.RoomTool);

            Message.AppendUInt(RoomId);                                               // flatId
            Message.AppendInt32(Room.RoomData.UsersNow);                              // userCount
            Message.AppendBoolean(Owner == null ? false : Owner.CurrentRoom == Room); // ownerInRoom
            Message.AppendUInt(Room.RoomData.OwnerId);                                // ownerId
            Message.AppendString(Room.RoomData.Owner);                                // ownerName
            Message.AppendBoolean(Room != null);                                      // show data?
            if (Room != null)
            {
                Message.AppendString(Room.RoomData.Name);        // roomName
                Message.AppendString(Room.RoomData.Description); // roomDesc
                Message.AppendInt32(Room.RoomData.Tags.Count);   // tagsCount

                foreach (var Tag in Room.RoomData.Tags)          // tags
                {
                    Message.AppendString(Tag);
                }
            }

            return(Message);
        }
Ejemplo n.º 3
0
        internal static ServerMessage SerializeRoomVisits(UInt32 UserId)
        {
            Habbo User = UsersCache.getHabboCache(UserId);

            ServerMessage Message = new ServerMessage(Outgoing.RoomsVisits);

            Message.AppendUInt(UserId);
            Message.AppendString(UsersCache.getUsernameById(UserId));
            if (User == null)
            {
                Message.AppendInt32(0);
            }
            else
            {
                Message.AppendInt32(User.RoomsVisited.Count);
                foreach (RoomVisits Room in User.RoomsVisited)
                {
                    // Message.AppendBoolean(Room.IsPublic);
                    Message.AppendUInt(Room.RoomId);
                    Message.AppendString(Room.RoomName);
                    Message.AppendInt32(Room.Hour);
                    Message.AppendInt32(Room.Minute);
                }
            }
            return(Message);
        }
Ejemplo n.º 4
0
        internal void ModMuteUser()
        {
            if (!Session.GetHabbo().HasFuse("fuse_mute"))
            {
                return;
            }

            var UserId      = Request.PopWiredUInt();
            var Message     = Request.PopFixedString();
            var MuteMinutes = Request.PopWiredInt32();
            // 2 str: 1,2

            Habbo TargetHabbo = UsersCache.getHabboCache(UserId);

            if (TargetHabbo == null)
            {
                return;
            }

            if (MuteMinutes == 34)
            {
                MuteMinutes = 60;
            }

            ModerationTool.MuteUser(Session, TargetHabbo, MuteMinutes, Message);
        }
Ejemplo n.º 5
0
        private void GenerateMessage(int UsersCount)
        {
            Message = new ServerMessage(Outgoing.CommunityGoalHallOfFame);
            Message.AppendString(EventName); // landing.view.competition.hof." + x + ".rankdesc.X
            Message.AppendInt32(UsersCount);
            for (int i = 0; i < UsersCount; i++)
            {
                uint UserId = TopUsers[i];
                if (UserId == 0)
                {
                    break;
                }

                Habbo User = UsersCache.getHabboCache(UserId);
                if (User == null)
                {
                    break;
                }

                Message.AppendUInt(User.Id);
                Message.AppendString(User.Username);
                Message.AppendString(User.Look);
                Message.AppendInt32(i);                  // rank
                Message.AppendUInt(User.CoinsPurchased); // piruletas
            }
        }
Ejemplo n.º 6
0
        internal void Serialize(ServerMessage Request)
        {
            Request.AppendUInt(FromUser);
            Request.AppendString(mUsername);
            var user = UsersCache.getHabboCache(mUsername);

            try { Request.AppendString((user != null) ? user.Look : ""); } catch { Request.AppendString(""); }
        }
Ejemplo n.º 7
0
        internal void Serialize(ServerMessage Message)
        {
            Habbo user = UsersCache.getHabboCache(this.ReportedId);

            Message.AppendInt32(1);                                     // length
            Message.AppendInt32(3);                                     // type: Bully
            Message.AppendInt32((DateTime.Now - startedTimer).Seconds); // timer sec
            Message.AppendBoolean(user == null);                        // false = usuario, true = null
            if (user != null)
            {
                Message.AppendString(user.Username);
                Message.AppendString(user.Look);
                Message.AppendString((user.CurrentRoom == null) ? "" : user.CurrentRoom.RoomData.Name);
            }
        }
Ejemplo n.º 8
0
        internal void OnCycle()
        {
            if (this.bullyState == BullyState.SEARCHING_USER)
            {
                if ((DateTime.Now - customTimer).Seconds >= 15)
                {
                    GameClient guardianClient = OtanixEnvironment.GetGame().GetClientManager().GetClientByUserID(this.GuardianId);
                    if (guardianClient != null)
                    {
                        ServerMessage Message3 = new ServerMessage(Outgoing.CancelAlfaAlert);
                        guardianClient.SendMessage(Message3);

                        guardianClient.GetHabbo().AlfaServiceId = 0;
                        guardianClient.GetHabbo().ExitAlfaState();
                    }

                    if (!this.nullGuardians.Contains(this.GuardianId))
                    {
                        this.nullGuardians.Add(this.GuardianId);
                    }

                    if (!this.SearchGuardian())
                    {
                        this.SerializeNoGuardians();
                        OtanixEnvironment.GetGame().GetAlfaManager().GetBullyManager().RemoveBullie(this.ReporterId);
                        return;
                    }
                }
                else if (this.NeedUpdate)
                {
                    this.NeedUpdate = false;

                    if (!this.nullGuardians.Contains(this.GuardianId))
                    {
                        this.nullGuardians.Add(this.GuardianId);
                    }

                    if (!this.SearchGuardian())
                    {
                        this.SerializeNoGuardians();
                        OtanixEnvironment.GetGame().GetAlfaManager().GetBullyManager().RemoveBullie(this.ReporterId);
                        return;
                    }
                }
            }
            else if (this.bullyState == BullyState.WAITING_RESPONSE)
            {
                if ((DateTime.Now - customTimer).Seconds >= 59)
                {
                    GameClient guardianClient = Guardian;
                    if (guardianClient != null)
                    {
                        ServerMessage Message3 = new ServerMessage(Outgoing.CancelAlfaAlert);
                        guardianClient.SendMessage(Message3);
                    }

                    this.bullySolution = BullySolution.EXIT;
                    this.bullyState    = BullyState.FINISHED;
                }
            }
            else if (this.bullyState == BullyState.FINISHED)
            {
                switch (this.bullySolution)
                {
                case BullySolution.NONE:
                case BullySolution.EXIT:
                case BullySolution.RELOAD:
                {
                    GameClient _Reporter = Reporter;
                    if (_Reporter != null)
                    {
                        OtanixEnvironment.GetGame().GetModerationTool().SendNewTicket(_Reporter, 104, (int)ReportedId, "Acoso", new string[0]);
                    }

                    break;
                }

                case BullySolution.ACCEPTABLE:
                {
                    // none (:
                    break;
                }

                case BullySolution.BULLY:
                case BullySolution.HORROR:
                {
                    Habbo habbo = UsersCache.getHabboCache(ReportedId);
                    if (habbo == null)
                    {
                        return;
                    }

                    ModerationTool.MuteUser(null, habbo, 10, "");
                    break;
                }

                    /*case BullySolution.HORROR:
                     *  {
                     *      GameClient TargetClient = OtanixEnvironment.GetGame().GetClientManager().GetClientByUserID(ReportedId);
                     *      Habbo habbo = UsersCache.getHabboCache(ReportedId);
                     *
                     *      if (habbo != null && habbo.Rank <= 1)
                     *          //OtanixEnvironment.GetGame().GetBanManager().BanUser(TargetClient, habbo.Username, "", "Baneado por los HabboAlfas.", 21600, null);
                     *      break;
                     *  }*/
                }

                GameClient guardianClient = Guardian;
                if (guardianClient != null && guardianClient.GetHabbo() != null)
                {
                    guardianClient.GetHabbo().AlfaServiceId   = 0;
                    guardianClient.GetHabbo().AlfaHelpEnabled = false;

                    if (bullySolution == BullySolution.ACCEPTABLE || bullySolution == BullySolution.BULLY || bullySolution == BullySolution.HORROR)
                    {
                        ServerMessage EndVotation = new ServerMessage(Outgoing.FinishAlfaVotation);
                        EndVotation.AppendInt32((Int32)bullySolution);
                        EndVotation.AppendInt32((Int32)bullySolution);
                        EndVotation.AppendInt32(0); // array
                        guardianClient.SendMessage(EndVotation);
                    }

                    // Con esto enviaremos al Guardián al inicio de la lista para que puedan ayudar los últimos guardianes.
                    // OtanixEnvironment.GetGame().GetAlfaManager().GetBullyManager().RemoveGuardian(GuardianId);
                    // OtanixEnvironment.GetGame().GetAlfaManager().GetBullyManager().AddGuardian(GuardianId);
                }

                if (this.AlfaChatLog.Length > 0)
                {
                    OtanixEnvironment.GetGame().GetAlfaManager().LoadAlfaLog(this.GuardianId, "BULLY", this.AlfaChatLog, (Int32)this.bullySolution);
                }

                OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(GuardianId, "ACH_GuideChatReviewer", 1);

                GameClient reporterClient = Reporter;
                if (reporterClient != null)
                {
                    ServerMessage reporterAlert = new ServerMessage(Outgoing.ResolvedAlfa);
                    reporterAlert.AppendInt32(3);
                    reporterClient.SendMessage(reporterAlert);
                }

                OtanixEnvironment.GetGame().GetAlfaManager().GetBullyManager().RemoveBullie(this.ReporterId);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Actualiza el progreso una recompensa.
        /// </summary>
        /// <param name="Session"></param>
        /// <param name="UserId"></param>
        /// <param name="AchievementGroup"></param>
        /// <param name="ProgressAmount"></param>
        /// <returns></returns>
        public bool ProgressUserAchievement(uint UserId, string AchievementGroup, int ProgressAmount)
        {
            Habbo Habbo = UsersCache.getHabboCache(UserId);

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

            GameClient Session = Habbo.GetClient();

            Achievement AchievementData = GetAchievementByName(AchievementGroup);

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

            UserAchievement UserData = Habbo.GetAchievementData(AchievementGroup);

            if (UserData == null)
            {
                UserData = new UserAchievement(AchievementGroup, 0, 0);
                Habbo.Achievements.Add(AchievementGroup, UserData);
            }

            uint TotalLevels = (uint)AchievementData.Levels.Length;

            if (UserData.Level == TotalLevels)
            {
                return(false); // ya está todo completado
            }

            uint TargetLevel = UserData.Level + 1;

            if (TargetLevel > TotalLevels)
            {
                TargetLevel = TotalLevels;
            }

            uint TargetRequeriment = AchievementData.Levels[TargetLevel - 1];

            UserData.Progress += ProgressAmount;

            if (UserData.Progress >= TargetRequeriment)
            {
                UserData.Level++;

                if (TargetLevel == 1)
                {
                    Habbo.GetBadgeComponent().GiveBadge(AchievementGroup + TargetLevel);
                }
                else
                {
                    Habbo.GetBadgeComponent().UpdateBadge(AchievementGroup + TargetLevel);
                }

                Habbo.AchievementPoints += AchievementData.Reward;

                if (Session != null)
                {
                    Session.SendMessage(AchievementUnlockedComposer.Compose(AchievementData, TargetLevel, AchievementData.Reward));
                    Session.SendMessage(AchievementScoreUpdateComposer.Compose(Habbo.AchievementPoints));
                }
            }

            if (Session != null)
            {
                Session.SendMessage(AchievementProgressComposer.Compose(AchievementData, UserData));
            }

            using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("REPLACE INTO user_achievements VALUES (" + Habbo.Id + ", @group, " + UserData.Level + ", " + UserData.Progress + ")");
                dbClient.addParameter("group", AchievementGroup);
                dbClient.runQuery();
            }

            if (Session == null)
            {
                Habbo.SaveBadges();
            }

            return(true);
        }
Ejemplo n.º 10
0
        private void processCommand(String data)
        {
            String header = data.Split(';')[0];

            switch (header.ToLower())
            {
            case "enterroom":
            {
                uint HabboID = uint.Parse(data.Split(';')[1]);
                uint RoomID  = uint.Parse(data.Split(';')[2]);

                UsersCache.AddUserProvisionalRoom(HabboID, RoomID);

                break;
            }

            case "goroom":
            {
                uint HabboID = uint.Parse(data.Split(';')[1]);
                uint RoomID  = uint.Parse(data.Split(';')[2]);

                GameClient client = OtanixEnvironment.GetGame().GetClientManager().GetClientByUserID(HabboID);
                if (client == null || client.GetMessageHandler() == null)
                {
                    return;
                }

                Room room = OtanixEnvironment.GetGame().GetRoomManager().LoadRoom(RoomID);
                if (room == null)
                {
                    return;
                }

                client.GetMessageHandler().enterOnRoom3(room);

                break;
            }

            case "getevents":
            {
                int             count      = int.Parse(data.Split(';')[1]);
                StringBuilder   strBuilder = new StringBuilder();
                List <RoomData> rooms      = OtanixEnvironment.GetGame().GetRoomManager().GetEventManager().GetFourRecentEvents(count);

                foreach (RoomData room in rooms)
                {
                    if (room != null && room.Event != null)
                    {
                        strBuilder.Append(room.Id + "" + (char)10 + "" + room.Event.Name + (char)10 + "" + room.UsersNow + "" + (char)13);
                    }
                }

                if (strBuilder.Length > 0)
                {
                    strBuilder.Remove(strBuilder.Length - 1, 1);
                }

                sendCommand(strBuilder.ToString());

                break;
            }

            case "getactiverooms":
            {
                int             count      = int.Parse(data.Split(';')[1]);
                StringBuilder   strBuilder = new StringBuilder();
                List <RoomData> rooms      = OtanixEnvironment.GetGame().GetRoomManager().GetMostActiveRooms(count);

                foreach (RoomData room in rooms)
                {
                    if (room != null)
                    {
                        strBuilder.Append(room.Id + "" + (char)10 + "" + room.UsersNow + "" + (char)13);
                    }
                }

                if (strBuilder.Length > 0)
                {
                    strBuilder.Remove(strBuilder.Length - 1, 1);
                }

                sendCommand(strBuilder.ToString());

                break;
            }

            case "getmotto":
            {
                uint HabboID = uint.Parse(data.Split(';')[1]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);

                if (habbo != null)
                {
                    sendCommand(habbo.Motto.ToString());
                }

                break;
            }

            case "updatemotto":
            {
                uint   HabboID = uint.Parse(data.Split(';')[1]);
                string Motto   = data.Split(';')[2];

                Habbo habbo = UsersCache.getHabboCache(HabboID);
                if (habbo != null && habbo.GetClient() != null)
                {
                    habbo.Motto = Motto;

                    ServerMessage UpdateMotto = new ServerMessage(Outgoing.UpdateUserInformation);
                    UpdateMotto.AppendInt32(-1);
                    UpdateMotto.AppendString(habbo.Look);
                    UpdateMotto.AppendString(habbo.Gender.ToLower());
                    UpdateMotto.AppendString(habbo.Motto);
                    UpdateMotto.AppendUInt(habbo.AchievementPoints);
                    habbo.GetClient().SendMessage(UpdateMotto);

                    if (habbo.CurrentRoom != null)
                    {
                        ServerMessage UpdateMottoInRoom = new ServerMessage(Outgoing.UpdateUserInformation);
                        UpdateMottoInRoom.AppendInt32(habbo.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(habbo.Id).VirtualId);
                        UpdateMottoInRoom.AppendString(habbo.Look);
                        UpdateMottoInRoom.AppendString(habbo.Gender.ToLower());
                        UpdateMottoInRoom.AppendString(habbo.Motto);
                        UpdateMottoInRoom.AppendUInt(habbo.AchievementPoints);
                        habbo.CurrentRoom.SendMessage(UpdateMottoInRoom);
                    }
                }

                break;
            }

            case "getlook":
            {
                uint HabboID = uint.Parse(data.Split(';')[1]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);

                if (habbo != null)
                {
                    sendCommand(habbo.Look.ToString());
                }

                break;
            }

            case "getrespects":
            {
                uint HabboID = uint.Parse(data.Split(';')[1]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);

                if (habbo != null)
                {
                    sendCommand(habbo.Respect.ToString());
                }

                break;
            }

            case "getpetitionsdisable":
            {
                uint HabboID = uint.Parse(data.Split(';')[1]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);

                if (habbo != null)
                {
                    sendCommand(habbo.HasFriendRequestsDisabled.ToString());
                }

                break;
            }

            case "updatepetitionsdisable":
            {
                uint HabboID          = uint.Parse(data.Split(';')[1]);
                bool petitionsDisable = OtanixEnvironment.EnumToBool(data.Split(';')[2]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);
                if (habbo != null)
                {
                    habbo.HasFriendRequestsDisabled = petitionsDisable;
                }

                break;
            }

            case "gettradesdisable":
            {
                uint HabboID = uint.Parse(data.Split(';')[1]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);

                if (habbo != null)
                {
                    sendCommand(habbo.BlockTrade.ToString());
                }

                break;
            }

            case "updatetradesdisable":
            {
                uint HabboID       = uint.Parse(data.Split(';')[1]);
                bool tradesDisable = OtanixEnvironment.EnumToBool(data.Split(';')[2]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);
                if (habbo != null)
                {
                    habbo.BlockTrade = tradesDisable;
                }

                break;
            }

            case "getignoreroominvitations":
            {
                uint HabboID = uint.Parse(data.Split(';')[1]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);

                if (habbo != null)
                {
                    sendCommand(habbo.IgnoreRoomInvitations.ToString());
                }

                break;
            }

            case "updateignoreroominvitations":
            {
                uint HabboID = uint.Parse(data.Split(';')[1]);
                bool ignoreRoomInvitations = OtanixEnvironment.EnumToBool(data.Split(';')[2]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);
                if (habbo != null)
                {
                    habbo.IgnoreRoomInvitations = ignoreRoomInvitations;
                }

                break;
            }

            case "getdontfocususers":
            {
                uint HabboID = uint.Parse(data.Split(';')[1]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);

                if (habbo != null)
                {
                    sendCommand(habbo.DontFocusUser.ToString());
                }

                break;
            }

            case "updatedontfocususers":
            {
                uint HabboID        = uint.Parse(data.Split(';')[1]);
                bool dontFocusUsers = OtanixEnvironment.EnumToBool(data.Split(';')[2]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);
                if (habbo != null)
                {
                    habbo.DontFocusUser = dontFocusUsers;
                }

                break;
            }

            case "getprefoldchat":
            {
                uint HabboID = uint.Parse(data.Split(';')[1]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);

                if (habbo != null)
                {
                    sendCommand(habbo.preferOldChat.ToString());
                }

                break;
            }

            case "updateprefoldchat":
            {
                uint HabboID     = uint.Parse(data.Split(';')[1]);
                bool prefOldChat = OtanixEnvironment.EnumToBool(data.Split(';')[2]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);
                if (habbo != null)
                {
                    habbo.preferOldChat = prefOldChat;
                }

                break;
            }

            case "getdiamonds":
            {
                uint HabboID = uint.Parse(data.Split(';')[1]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);

                if (habbo != null)
                {
                    sendCommand(habbo.Diamonds.ToString());
                }

                break;
            }

            case "updatediamonds":
            {
                uint HabboID  = uint.Parse(data.Split(';')[1]);
                int  Diamonds = int.Parse(data.Split(';')[2]);

                Habbo habbo = UsersCache.getHabboCache(HabboID);
                if (habbo != null)
                {
                    if (Diamonds < 0)
                    {
                        habbo.Diamonds -= (uint)Math.Abs(Diamonds);
                    }
                    else
                    {
                        habbo.Diamonds += (uint)Diamonds;
                    }

                    habbo.UpdateExtraMoneyBalance();
                }

                break;
            }

            case "updatechatsettings":
            {
                uint HabboId = uint.Parse(data.Split(';')[1]);

                GameClient client = OtanixEnvironment.GetGame().GetClientManager().GetClientByUserID(HabboId);
                if (client != null && client.GetHabbo() != null)
                {
                    using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        dbClient.setQuery("SELECT chat_color FROM users WHERE id = '" + HabboId + "'");
                        client.GetHabbo().ChatColor = dbClient.getString();
                    }
                }

                break;
            }

            case "updatecoins":
            {
                uint HabboId = uint.Parse(data.Split(';')[1]);
                uint Coins   = uint.Parse(data.Split(';')[2]);

                GameClient client = OtanixEnvironment.GetGame().GetClientManager().GetClientByUserID(HabboId);
                if (client != null && client.GetHabbo() != null)
                {
                    client.GetHabbo().CoinsPurchased += Coins;
                }

                break;
            }
            }
        }