Exemplo n.º 1
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;");
 }
Exemplo n.º 2
0
        /// <summary>
        /// Databases the cleanup.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal 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 bots SET room_id = '0' WHERE ai_type = 'fightpet' AND room_id > 0");

            dbClient.RunFastQuery(
                string.Format(
                    "UPDATE server_status SET status = 1, users_online = 0, rooms_loaded = 0, server_ver = 'FluxRP Emulator', stamp = '{0}' ",
                    Plus.GetUnixTimeStamp()));
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Shutdown the Emulator
        /// </summary>
        /// <param name="restart">if set to <c>true</c> [restart].</param>
        /// Set a Different Message in Hotel
        internal static void PerformShutDown(bool restart)
        {
            DateTime now = DateTime.Now;

            CacheManager.StopProcess();

            ShutdownStarted = true;

            Console.Title = "Yupi Emulator | Shutting down...";

            GetGame().StopGameLoop();
            GetGame().GetRoomManager().RemoveAllRooms();

            GetGame().GetClientManager().CloseAll();

            GetConnectionManager().Destroy();

            foreach (Group group in GetGame().GetGroupManager().Groups.Values)
            {
                group.UpdateForum();
            }

            using (IQueryAdapter queryReactor = YupiDatabaseManager.GetQueryReactor())
            {
                queryReactor.RunFastQuery("UPDATE users SET online = '0'");
                queryReactor.RunFastQuery("UPDATE rooms_data SET users_now = 0");
                queryReactor.RunFastQuery("TRUNCATE TABLE users_rooms_visits");
            }

            GetConnectionManager().Destroy();

            GetGame().Destroy();

            YupiLogManager.Stop();

            YupiWriterManager.WriteLine(" destroyed", "Yupi.Game", ConsoleColor.DarkYellow);

            TimeSpan span = DateTime.Now - now;

            YupiWriterManager.WriteLine("Elapsed " + TimeSpanToString(span) + "ms on Shutdown Proccess", "Yupi.Life", ConsoleColor.DarkYellow);

            IsLive = false;

            if (restart)
            {
                Process.Start(Assembly.GetEntryAssembly().Location);
            }

            Console.WriteLine("Closing...");

            Environment.Exit(0);
        }
Exemplo n.º 5
0
 public static void SaveBounty()
 {
     if (BountyUsers.Count > 0)
     {
         using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
         {
             dbClient.RunFastQuery("TRUNCATE TABLE rp_bounties;");
             foreach (string username in BountyUsers.Keys)
             {
                 dbClient.RunFastQuery("INSERT INTO rp_bounties (user, amount) VALUES ('" + username + "', '" + BountyUsers[username] + "');");
             }
         }
     }
 }
Exemplo n.º 6
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}'");
            }
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="UserPreferences" /> class.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        internal UserPreferences(uint userId)
        {
            _userId = userId;

            DataRow row;

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery("SELECT * FROM users_preferences WHERE userid = " + _userId);
                queryReactor.AddParameter("userid", _userId);
                row = queryReactor.GetRow();

                if (row == null)
                {
                    queryReactor.RunFastQuery("REPLACE INTO users_preferences (userid, volume) VALUES (" +
                                              _userId +
                                              ", '100,100,100')");
                    return;
                }
            }

            PreferOldChat       = Yupi.EnumToBool((string)row["prefer_old_chat"]);
            IgnoreRoomInvite    = Yupi.EnumToBool((string)row["ignore_room_invite"]);
            DisableCameraFollow = Yupi.EnumToBool((string)row["disable_camera_follow"]);
            Volume        = (string)row["volume"];
            NewnaviX      = Convert.ToInt32(row["newnavi_x"]);
            NewnaviY      = Convert.ToInt32(row["newnavi_y"]);
            NewnaviWidth  = Convert.ToInt32(row["newnavi_width"]);
            NewnaviHeight = Convert.ToInt32(row["newnavi_height"]);
            ChatColor     = Convert.ToInt32(row["chat_color"]);
        }
Exemplo n.º 8
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();
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Kicks the user.
        /// </summary>
        /// <param name="modSession">The mod session.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="message">The message.</param>
        /// <param name="soft">if set to <c>true</c> [soft].</param>
        internal static void KickUser(GameClient modSession, uint userId, string message, bool soft)
        {
            GameClient clientByUserId = Plus.GetGame().GetClientManager().GetClientByUserId(userId);

            if (clientByUserId == null || clientByUserId.GetHabbo().CurrentRoomId < 1u || clientByUserId.GetHabbo().Id == modSession.GetHabbo().Id)
            {
                ModerationTool.ModActionResult(modSession.GetHabbo().Id, false);
                return;
            }
            if (clientByUserId.GetHabbo().Rank >= modSession.GetHabbo().Rank)
            {
                ModerationTool.ModActionResult(modSession.GetHabbo().Id, false);
                return;
            }
            Room room = Plus.GetGame().GetRoomManager().GetRoom(clientByUserId.GetHabbo().CurrentRoomId);

            if (room == null)
            {
                return;
            }
            room.GetRoomUserManager().RemoveUserFromRoom(clientByUserId, true, false);
            clientByUserId.CurrentRoomUserId = -1;
            if (soft)
            {
                return;
            }
            clientByUserId.SendNotif(message);
            using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.RunFastQuery(string.Format("UPDATE users_info SET cautions = cautions + 1 WHERE user_id = {0}", userId));
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Closes the specified new status.
        /// </summary>
        /// <param name="newStatus">The new status.</param>
        /// <param name="updateInDb">if set to <c>true</c> [update in database].</param>
        internal void Close(TicketStatus newStatus, bool updateInDb)
        {
            this.Status = newStatus;
            if (!updateInDb)
            {
                return;
            }
            string text;

            switch (newStatus)
            {
            case TicketStatus.Abusive:
                text = "abusive";
                goto IL_41;

            case TicketStatus.Invalid:
                text = "invalid";
                goto IL_41;
            }
            text = "resolved";
IL_41:
            using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.RunFastQuery(string.Concat(new object[]
                {
                    "UPDATE moderation_tickets SET status = '",
                    text,
                    "' WHERE id = ",
                    this.TicketId
                }));
            }
        }
Exemplo n.º 11
0
        internal void ToggleStaffPick()
        {
            uint roomId  = Request.GetUInteger();
            bool current = Request.GetBool();
            Room room    = Yupi.GetGame().GetRoomManager().GetRoom(roomId);

            Yupi.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_Spr", 1, true);
            if (room == null)
            {
                return;
            }
            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                PublicItem pubItem = Yupi.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()");
                    uint       publicItemId = (uint)queryReactor.GetInteger();
                    PublicItem publicItem   = new PublicItem(publicItemId, 0, string.Empty, string.Empty, string.Empty, PublicImageType.Internal, room.RoomId, 0, -2, false, 1, string.Empty);
                    Yupi.GetGame().GetNavigator().AddPublicItem(publicItem);
                }
                else // picked
                {
                    queryReactor.SetQuery("DELETE FROM navigator_publics WHERE id = @pubId");
                    queryReactor.AddParameter("pubId", pubItem.Id);
                    queryReactor.RunQuery();
                    Yupi.GetGame().GetNavigator().RemovePublicItem(pubItem.Id);
                }
                room.RoomData.SerializeRoomData(Response, Session, false, true);
                Yupi.GetGame().GetNavigator().LoadNewPublicRooms();
            }
        }
Exemplo n.º 12
0
Arquivo: Music.cs Projeto: sgf/Yupi
        /// <summary>
        /// Removes the playlist item.
        /// </summary>
        internal void RemovePlaylistItem()
        {
            if (Session?.GetHabbo() == null || Session.GetHabbo().CurrentRoom == null)
            {
                return;
            }

            Room currentRoom = Session.GetHabbo().CurrentRoom;

            if (!currentRoom.GotMusicController())
            {
                return;
            }

            SoundMachineManager roomMusicController = currentRoom.GetRoomMusicController();

            SongItem songItem = roomMusicController.RemoveDisk(Request.GetInteger());

            if (songItem == null)
            {
                return;
            }

            songItem.RemoveFromDatabase();

            Session.GetHabbo().GetInventoryComponent().AddNewItem(songItem.ItemId, songItem.BaseItem.Name, songItem.ExtraData, 0u, false, true, 0, 0, songItem.SongCode);
            Session.GetHabbo().GetInventoryComponent().UpdateItems(false);

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery($"UPDATE items_rooms SET user_id='{Session.GetHabbo().Id}' WHERE id='{songItem.ItemId}' LIMIT 1;");

            Session.SendMessage(SoundMachineComposer.SerializeSongInventory(Session.GetHabbo().GetInventoryComponent().SongDisks));
            Session.SendMessage(SoundMachineComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList()));
        }
Exemplo n.º 13
0
        public void BanUser(GameClient client, string Mod, ModerationBanType Type, string BanValue, string Reason, double ExpireTimestamp)
        {
            string BanType   = (Type == ModerationBanType.IP ? "ip" : Type == ModerationBanType.MACHINE ? "machine" : "user");
            double BanExpire = Plus.GetUnixTimeStamp() + ExpireTimestamp;

            using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("INSERT INTO `users_bans` (`bantype`, `value`, `reason`, `expire`, `added_by`,`added_date`) VALUES ('" + BanType + "', '" + BanValue + "', @reason, " + BanExpire + ", '" + Mod + "', '" + DateTime.Now.ToLongDateString() + "');");
                dbClient.AddParameter("reason", Reason);
                dbClient.RunQuery();
            }

            if (Type == ModerationBanType.MACHINE || Type == ModerationBanType.USERNAME)
            {
                if (!this._bans.ContainsKey(BanValue))
                {
                    this._bans.Add(BanValue, new ModerationBan(Type, BanValue, Reason, BanExpire));
                }
            }

            using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunFastQuery("UPDATE `users_info` SET `bans` = `bans` + '1' WHERE `user_id` = '" + client.GetHabbo().Id + "' LIMIT 1");
            }

            client.Disconnect("banned");
        }
Exemplo n.º 14
0
        /// <summary>
        ///     Handles all requests.
        /// </summary>
        internal void HandleAllRequests()
        {
            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery("DELETE FROM messenger_requests WHERE from_id = " + _userId + " OR to_id = " + _userId);

            ClearRequests();
        }
Exemplo n.º 15
0
        /// <summary>
        ///     Handles the request.
        /// </summary>
        /// <param name="sender">The sender.</param>
        internal void HandleRequest(uint sender)
        {
            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery(string.Concat("DELETE FROM messenger_requests WHERE (from_id = ", _userId, " AND to_id = ", sender, ") OR (to_id = ", _userId, " AND from_id = ", sender, ")"));

            Requests.Remove(sender);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Removes the playlist item.
        /// </summary>
        internal void RemovePlaylistItem()
        {
            if (this.Session == null || this.Session.GetHabbo() == null || this.Session.GetHabbo().CurrentRoom == null)
            {
                return;
            }
            Room currentRoom = this.Session.GetHabbo().CurrentRoom;

            if (!currentRoom.GotMusicController())
            {
                return;
            }
            RoomMusicController roomMusicController = currentRoom.GetRoomMusicController();
            SongItem            songItem            = roomMusicController.RemoveDisk(this.Request.GetInteger());

            if (songItem == null)
            {
                return;
            }
            songItem.RemoveFromDatabase();
            this.Session.GetHabbo().GetInventoryComponent().AddNewItem(songItem.ItemId, songItem.BaseItem.ItemId, songItem.ExtraData, 0u, false, true, 0, 0, songItem.SongCode);
            this.Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
            using (IQueryAdapter queryReactor = global::Plus.Plus.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.RunFastQuery(string.Format("UPDATE items_rooms SET user_id='{0}' WHERE id='{1}' LIMIT 1;", Session.GetHabbo().Id, songItem.ItemId));
            }
            this.Session.SendMessage(JukeboxComposer.SerializeSongInventory(this.Session.GetHabbo().GetInventoryComponent().SongDisks));
            this.Session.SendMessage(JukeboxComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList <SongInstance>()));
        }
Exemplo n.º 17
0
 /// <summary>
 /// Removes from database.
 /// </summary>
 internal void RemoveFromDatabase()
 {
     using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
     {
         queryReactor.RunFastQuery(string.Format("DELETE FROM items_songs WHERE itemid = {0}", ItemId));
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Saves to database.
 /// </summary>
 /// <param name="roomId">The room identifier.</param>
 internal void SaveToDatabase(uint roomId)
 {
     using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
     {
         queryReactor.RunFastQuery(string.Concat("REPLACE INTO items_songs VALUES (", ItemId, ",", roomId, ",", SongId, ")"));
     }
 }
Exemplo n.º 19
0
        public override bool Execute(GameClient session, string[] pms)
        {
            Room room = session.GetHabbo().CurrentRoom;

            using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                commitableQueryReactor.RunFastQuery(
                    $"UPDATE rooms_data SET roomtype = 'private' WHERE id = {room.RoomId}");

            uint            roomId = session.GetHabbo().CurrentRoom.RoomId;
            List <RoomUser> users  = new List <RoomUser>(session.GetHabbo().CurrentRoom.GetRoomUserManager().UserList.Values);

            Yupi.GetGame().GetRoomManager().UnloadRoom(session.GetHabbo().CurrentRoom, "Unload command");

            Yupi.GetGame().GetRoomManager().LoadRoom(roomId);

            ServerMessage roomFwd = new ServerMessage(LibraryParser.OutgoingRequest("RoomForwardMessageComposer"));

            roomFwd.AppendInteger(roomId);

            byte[] data = roomFwd.GetReversedBytes();

            foreach (RoomUser user in users.Where(user => user != null && user.GetClient() != null))
            {
                user.GetClient().SendMessage(data);
            }

            return(true);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Ends the game when it is finished
        /// </summary>
        public static void EndGame()
        {
            // Send all players that are still in the game to the loby
            ResetAllPlayers();
            SendAllPlayersToRoom(ColourManager.GameLobby);

            // Null all teams
            Teams["red"]    = null;
            Teams["blue"]   = null;
            Teams["yellow"] = null;
            Teams["pink"]   = null;

            // NU LTHE WINNING TEAM YING U FORGOT THIS U BTEC C**T
            WinningTeam = null;

            // Remove them from dictionary
            Teams.Clear();

            // Recreate teams etc
            Initialize();

            using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunFastQuery("UPDATE rp_stats SET last_cw_team = '" + String.Empty + "' WHERE last_cw_team != '" + String.Empty + "'");
            }
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
0
        /// <summary>
        ///     Stops the effect.
        /// </summary>
        /// <param name="effectId">The effect identifier.</param>
        internal void StopEffect(int effectId)
        {
            List <AvatarEffect> avatarEffect = _effects.Where(x => x.EffectId == effectId).ToList();

            if (!avatarEffect.Any())
            {
                return;
            }

            AvatarEffect effect = avatarEffect.Last();

            if (effect == null || !effect.HasExpired)
            {
                return;
            }

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery(string.Concat("DELETE FROM users_effects WHERE user_id = ", _userId,
                                                        " AND effect_id = ", effectId, " AND is_activated = 1"));

            _effects.Remove(effect);

            GetClient()
            .GetMessageHandler()
            .GetResponse()
            .Init(LibraryParser.OutgoingRequest("StopAvatarEffectMessageComposer"));

            GetClient().GetMessageHandler().GetResponse().AppendInteger(effectId);
            GetClient().GetMessageHandler().SendResponse();

            if (CurrentEffect >= 0)
            {
                ActivateCustomEffect(-1);
            }
        }
Exemplo n.º 24
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 = Yupi.GetGame().GetRoomManager().GetRoom(roomId);

            if (room == null)
            {
                return;
            }

            if (lockRoom)
            {
                room.RoomData.State = 1;

                using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                    queryReactor.RunFastQuery($"UPDATE rooms_data SET state = 'locked' WHERE id = {room.RoomId}");
            }

            if (inappropriateRoom)
            {
                room.RoomData.Name        = "Inapropriado para a Gerência do Hotel";
                room.RoomData.Description = "A descrição do quarto não é permitida.";
                room.ClearTags();
                room.RoomData.SerializeRoomData(message, modSession, false, true);
            }

            if (kickUsers)
            {
                room.OnRoomKick();
            }
        }
Exemplo n.º 25
0
        /// <summary>
        ///     Delivers the random pinata item.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="room">The room.</param>
        /// <param name="item">The item.</param>
        internal void DeliverRandomPinataItem(RoomUser user, Room room, RoomItem item)
        {
            if (room == null || item == null || item.GetBaseItem().InteractionType != Interaction.Pinata ||
                !Pinatas.ContainsKey(item.GetBaseItem().ItemId))
            {
                return;
            }

            PinataItem pinataItem;

            Pinatas.TryGetValue(item.GetBaseItem().ItemId, out pinataItem);

            if (pinataItem == null || pinataItem.Rewards.Count < 1)
            {
                return;
            }

            item.RefreshItem();

            //@TODO :: KESSILER, now PINATA DOESNT WORK. MUST CREATE SOLUTION LATER.

            //item.BaseName = pinataItem.Rewards[new Random().Next((pinataItem.Rewards.Count - 1))];

            item.ExtraData = string.Empty;
            room.GetRoomItemHandler().RemoveFurniture(user.GetClient(), item.Id, false);

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery(
                    $"UPDATE items_rooms SET item_name='{item.BaseName}', extra_data='' WHERE id='{item.Id}'");

            if (!room.GetRoomItemHandler().SetFloorItem(user.GetClient(), item, item.X, item.Y, 0, true, false, true))
            {
                user.GetClient().GetHabbo().GetInventoryComponent().AddItem(item);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Closes the ticket.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="ticketId">The ticket identifier.</param>
        /// <param name="result">The result.</param>
        internal void CloseTicket(GameClient session, uint ticketId, int result)
        {
            SupportTicket ticket = this.GetTicket(ticketId);

            if (ticket == null || ticket.Status != TicketStatus.Picked || ticket.ModeratorId != session.GetHabbo().Id)
            {
                return;
            }
            GameClient   clientByUserId = Plus.GetGame().GetClientManager().GetClientByUserId(ticket.SenderId);
            int          i;
            TicketStatus newStatus;

            switch (result)
            {
            case 1:
                i         = 1;
                newStatus = TicketStatus.Invalid;
                goto IL_9E;

            case 2:
                i         = 2;
                newStatus = TicketStatus.Abusive;
                using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
                {
                    queryReactor.RunFastQuery(string.Format("UPDATE users_info SET cfhs_abusive = cfhs_abusive + 1 WHERE user_id = {0}", ticket.SenderId));
                    goto IL_9E;
                }
            }
            i         = 0;
            newStatus = TicketStatus.Resolved;
IL_9E:
            if (clientByUserId != null && (ticket.Type != 3 && ticket.Type != 4))
            {
                foreach (SupportTicket current2 in Tickets.FindAll(current => current.ReportedId == ticket.ReportedId && current.Status == TicketStatus.Picked))
                {
                    current2.Delete(true);
                    SendTicketToModerators(current2);
                    current2.Close(newStatus, true);
                }
                clientByUserId.GetMessageHandler().GetResponse().Init(LibraryParser.OutgoingRequest("ModerationToolUpdateIssueMessageComposer"));
                clientByUserId.GetMessageHandler().GetResponse().AppendInteger(1);
                clientByUserId.GetMessageHandler().GetResponse().AppendInteger(ticket.TicketId);
                clientByUserId.GetMessageHandler().GetResponse().AppendInteger(ticket.ModeratorId);
                clientByUserId.GetMessageHandler()
                .GetResponse()
                .AppendString((Plus.GetHabboById(ticket.ModeratorId) != null)
                                            ? Plus.GetHabboById(ticket.ModeratorId).UserName
                                            : "******");
                clientByUserId.GetMessageHandler().GetResponse().AppendBool(false);
                clientByUserId.GetMessageHandler().GetResponse().AppendInteger(0);
                clientByUserId.GetMessageHandler().GetResponse().Init(LibraryParser.OutgoingRequest("ModerationTicketResponseMessageComposer"));
                clientByUserId.GetMessageHandler().GetResponse().AppendInteger(i);
                clientByUserId.GetMessageHandler().SendResponse();
            }
            using (IQueryAdapter queryreactor2 = Plus.GetDatabaseManager().GetQueryReactor())
            {
                queryreactor2.RunFastQuery(string.Format("UPDATE users_stats SET tickets_answered = tickets_answered+1 WHERE id={0} LIMIT 1", session.GetHabbo().Id));
            }
        }
Exemplo n.º 27
0
        public void timerDone(object info)
        {
            try
            {
                timeLeft -= 60000;

                #region Conditions
                if (Session == null)
                {
                    stopTimer(); return;
                }

                if (timeLeft == 3 * 60000)
                {
                    if (GangManager.TurfData[Convert.ToInt32(Session.GetHabbo().CurrentRoomId)].GangId > 0)
                    {
                        RoleplayManager.AlertGang("Your turf is slowly being captured in RoomID " + Session.GetHabbo().CurrentRoomId + "! They're getting close!", GangManager.TurfData[Convert.ToInt32(Session.GetHabbo().CurrentRoomId)].GangId);
                    }
                }
                else if (timeLeft == 1 * 60000)
                {
                    if (GangManager.TurfData[Convert.ToInt32(Session.GetHabbo().CurrentRoomId)].GangId > 0)
                    {
                        RoleplayManager.AlertGang("Your turf is nearly captured in RoomID " + Session.GetHabbo().CurrentRoomId + "! Hurry Hurry!", GangManager.TurfData[Convert.ToInt32(Session.GetHabbo().CurrentRoomId)].GangId);
                    }
                }

                if (timeLeft > 0)
                {
                    int minutesRemaining = timeLeft / 60000;
                    Session.SendWhisper("You have " + minutesRemaining + " minute(s) left until you capture the turf!");
                    timer.Change(60000, Timeout.Infinite);
                    return;
                }

                #endregion

                #region Execute
                RoleplayManager.Shout(Session, "*Successfully captures gang turf*");
                GangManager.TurfData[Convert.ToInt32(Session.GetHabbo().CurrentRoomId)].GangId = Session.GetRoleplay().GangId;
                using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunFastQuery("UPDATE rp_gangs_turfs SET gang_id = '" + Session.GetRoleplay().GangId + "' WHERE turf_id = '" + Session.GetHabbo().CurrentRoomId + "'");
                }
                GangManager.initTurfs();

                if (GangManager.TurfData[Convert.ToInt32(Session.GetHabbo().CurrentRoomId)].GangId > 0)
                {
                    RoleplayManager.AlertGang("Your turf just got captured in RoomID " + Session.GetHabbo().CurrentRoomId + "! It's too late!", GangManager.TurfData[Convert.ToInt32(Session.GetHabbo().CurrentRoomId)].GangId);
                }

                Session.GetRoleplay().GangCapturing = false;
                stopTimer();
                #endregion
            }
            catch { stopTimer(); }
        }
Exemplo n.º 28
0
        /// <summary>
        ///     Destroys the friendship.
        /// </summary>
        /// <param name="friendId">The friend identifier.</param>
        internal void DestroyFriendship(uint friendId)
        {
            Habbo habbo = GetClient().GetHabbo();

            using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                commitableQueryReactor.RunFastQuery(
                    string.Concat("DELETE FROM messenger_friendships WHERE (user_one_id = ", _userId,
                                  " AND user_two_id = ", friendId, ") OR (user_two_id = ", _userId, " AND user_one_id = ",
                                  friendId, ")"));

                commitableQueryReactor.RunFastQuery(string.Concat("SELECT id FROM users_relationships WHERE user_id=",
                                                                  habbo.Id, " AND target = ", friendId, " LIMIT 1"));

                int id = commitableQueryReactor.GetInteger();

                commitableQueryReactor.RunFastQuery(string.Concat("DELETE FROM users_relationships WHERE (user_id = ",
                                                                  habbo.Id, " AND target = ", friendId, ")"));

                if (id > 0)
                {
                    if (habbo.Relationships.ContainsKey(id))
                    {
                        habbo.Relationships.Remove(id);
                    }
                }
            }

            OnDestroyFriendship(friendId);

            GameClient clientRelationship = Yupi.GetGame().GetClientManager().GetClientByUserId(friendId);

            if (clientRelationship?.GetHabbo().GetMessenger() != null)
            {
                clientRelationship.GetHabbo().GetMessenger().OnDestroyFriendship(_userId);

                if (clientRelationship.GetHabbo().Relationships.ContainsKey((int)friendId))
                {
                    clientRelationship.GetHabbo().Relationships.Remove((int)friendId);
                }
            }
        }
Exemplo n.º 29
0
        /// <summary>
        ///     Deletes the specified update in database.
        /// </summary>
        /// <param name="updateInDb">if set to <c>true</c> [update in database].</param>
        internal void Delete(bool updateInDb)
        {
            Status = TicketStatus.Deleted;

            if (!updateInDb)
            {
                return;
            }

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery($"UPDATE moderation_tickets SET status = 'deleted' WHERE id = {TicketId}");
        }
Exemplo n.º 30
0
 /// <summary>
 /// Deletes the specified update in database.
 /// </summary>
 /// <param name="updateInDb">if set to <c>true</c> [update in database].</param>
 internal void Delete(bool updateInDb)
 {
     this.Status = TicketStatus.Deleted;
     if (!updateInDb)
     {
         return;
     }
     using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
     {
         queryReactor.RunFastQuery(string.Format("UPDATE moderation_tickets SET status = 'deleted' WHERE id = {0}", this.TicketId));
     }
 }
Exemplo n.º 31
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;");
 }
Exemplo n.º 32
0
 /// <summary>
 /// Removes all messages.
 /// </summary>
 /// <param name="dbClient">The database client.</param>
 /// <param name="ToId">To identifier.</param>
 internal static void RemoveAllMessages(IQueryAdapter dbClient, uint ToId)
 {
     dbClient.RunFastQuery(string.Format("DELETE FROM messenger_offline_messages WHERE to_id={0}", ToId));
 }
Exemplo n.º 33
0
 /// <summary>
 /// Databases the cleanup.
 /// </summary>
 /// <param name="dbClient">The database client.</param>
 internal 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(
         string.Format(
             "UPDATE server_status SET status = 1, users_online = 0, rooms_loaded = 0, server_ver = 'Azure emu', stamp = '{0}' ",
             AzureEmulator.GetUnixTimeStamp()));
 }
Exemplo n.º 34
0
 /// <summary>
 ///     Removes all messages.
 /// </summary>
 /// <param name="dbClient">The database client.</param>
 /// <param name="toId">To identifier.</param>
 internal static void RemoveAllMessages(IQueryAdapter dbClient, uint toId)
 {
     dbClient.RunFastQuery($"DELETE FROM messenger_offline_messages WHERE to_id={toId}");
 }
Exemplo n.º 35
0
Arquivo: Habbo.cs Projeto: sgf/Yupi
 /// <summary>
 ///     Runs the database update.
 /// </summary>
 /// <param name="dbClient">The database client.</param>
 internal void RunDbUpdate(IQueryAdapter dbClient)
 {
     dbClient.RunFastQuery(string.Concat("UPDATE users SET last_online = '", Yupi.GetUnixTimeStamp(), "', activity_points = '", ActivityPoints, "', credits = '", Credits, "', diamonds = '", Diamonds, "' WHERE id = '", Id, "' LIMIT 1; "));
 }
Exemplo n.º 36
-1
        /// <summary>
        ///     Saves the furniture.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        /// <param name="session">The session.</param>
        public void SaveFurniture(IQueryAdapter dbClient, GameClient session = null)
        {
            try
            {
                if (!_updatedItems.Any() && !_removedItems.Any() && _room.GetRoomUserManager().PetCount <= 0)
                    return;

                foreach (uint itemId in _removedItems)
                    dbClient.RunFastQuery($"UPDATE items_rooms SET room_id='0', x='0', y='0', z='0', rot='0' WHERE id = {itemId}");

                foreach (RoomItem roomItem in _updatedItems.Select(GetItem).Where(roomItem => roomItem != null))
                {
                    if (roomItem.GetBaseItem() != null && roomItem.GetBaseItem().IsGroupItem)
                    {
                        try
                        {
                            string[] gD = roomItem.GroupData.Split(';');

                            roomItem.ExtraData = roomItem.ExtraData + ";" + gD[1] + ";" + gD[2] + ";" + gD[3];
                        }
                        catch
                        {
                            roomItem.ExtraData = string.Empty;
                        }
                    }

                    if (roomItem.RoomId == 0)
                        continue;

                    if (roomItem.GetBaseItem().Name.Contains("wallpaper_single") ||
                        roomItem.GetBaseItem().Name.Contains("floor_single") ||
                        roomItem.GetBaseItem().Name.Contains("landscape_single"))
                    {
                        dbClient.RunFastQuery($"DELETE FROM items_rooms WHERE id = {roomItem.Id} LIMIT 1");

                        continue;
                    }

                    if (roomItem.IsFloorItem)
                    {
                        dbClient.SetQuery(
                            $"UPDATE items_rooms SET room_id={roomItem.RoomId}, extra_data=@extraData, x={roomItem.X}, y={roomItem.Y}, z='{roomItem.Z.ToString(CultureInfo.InvariantCulture).Replace(',', '.')}', rot={roomItem.Rot} WHERE id={roomItem.Id}");
                        dbClient.AddParameter("extraData",
                            !string.IsNullOrEmpty(roomItem.ExtraData) ? roomItem.ExtraData : string.Empty);
                        dbClient.RunQuery();
                    }
                    else
                    {
                        dbClient.SetQuery(
                            $"UPDATE items_rooms SET room_id={roomItem.RoomId}, extra_data=@extraData, wall_pos=@wallPos WHERE id={roomItem.Id}");
                        dbClient.AddParameter("extraData",
                            !string.IsNullOrEmpty(roomItem.ExtraData) ? roomItem.ExtraData : string.Empty);
                        dbClient.AddParameter("wallPos", roomItem.WallCoord);
                        dbClient.RunQuery();
                    }
                }

                _room.GetRoomUserManager().AppendPetsUpdateString(dbClient);

                session?.GetHabbo().GetInventoryComponent().RunDbUpdate();

                _updatedItems.Clear();
                _removedItems.Clear();
            }
            catch (Exception ex)
            {
                ServerLogManager.LogCriticalException("Error during saving furniture for room " + _room.RoomId +
                                                      ". Stack: " + ex);
            }
        }