Example #1
0
 /// <summary>
 ///     Logs the staff entry.
 /// </summary>
 /// <param name="modName">Name of the mod.</param>
 /// <param name="target">The target.</param>
 /// <param name="type">The type.</param>
 /// <param name="description">The description.</param>
 internal void LogStaffEntry(string modName, string target, string type, string description)
 {
     using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
     {
         queryReactor.SetQuery(
             "INSERT INTO server_stafflogs (staffuser,target,action_type,description) VALUES (@Username,@target,@type,@desc)");
         queryReactor.AddParameter("Username", modName);
         queryReactor.AddParameter("target", target);
         queryReactor.AddParameter("type", type);
         queryReactor.AddParameter("desc", description);
         queryReactor.RunQuery();
     }
 }
Example #2
0
        /// <summary>
        ///     Adds the specified clothing.
        /// </summary>
        /// <param name="clothing">The clothing.</param>
        internal void Add(string clothing)
        {
            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery("INSERT INTO users_clothing (userid,clothing) VALUES (@userid,@clothing)");

                queryReactor.AddParameter("userid", _userId);
                queryReactor.AddParameter("clothing", clothing);
                queryReactor.RunQuery();
            }

            Clothing.Add(clothing);
        }
Example #3
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}");
        }
Example #4
0
        /// <summary>
        ///     Releases the specified update in database.
        /// </summary>
        /// <param name="updateInDb">if set to <c>true</c> [update in database].</param>
        internal void Release(bool updateInDb)
        {
            Status = TicketStatus.Open;

            if (!updateInDb)
            {
                return;
            }

            using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                commitableQueryReactor.RunFastQuery(
                    $"UPDATE moderation_tickets SET status = 'open' WHERE id = {TicketId}");
        }
Example #5
0
        public override bool Execute(GameClient session, string[] pms)
        {
            using (IQueryAdapter adapter = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                Yupi.GetGame().GetNavigator().Initialize(adapter);
                Yupi.GetGame().GetRoomManager().LoadModels(adapter);
            }

            Yupi.GetGame().GetNavigator().LoadNewPublicRooms();

            session.SendNotif(Yupi.GetLanguage().GetVar("command_refresh_navigator"));
            return(true);
        }
Example #6
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 #7
0
        /// <summary>
        ///     Creates the bot from catalog.
        /// </summary>
        /// <param name="botType">Type of the bot.</param>
        /// <param name="userId">The user identifier.</param>
        /// <returns>RoomBot.</returns>
        internal static RoomBot CreateBotFromCatalog(string botType, uint userId)
        {
            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                CatalogBot catalogBot = GetCatalogBot(botType);

                queryReactor.SetQuery(
                    $"INSERT INTO bots_data (user_id,name,motto,look,gender,walk_mode,ai_type,bot_type) VALUES ('{userId}', '{catalogBot.BotName}', '{catalogBot.BotMission}', '{catalogBot.BotLook}', '{catalogBot.BotGender}', 'freeroam', 'generic', '{catalogBot.BotType}')");

                return(new RoomBot(Convert.ToUInt32(queryReactor.InsertQuery()), userId, 0u, AiType.Generic,
                                   "freeroam", catalogBot.BotName, catalogBot.BotMission, catalogBot.BotLook, 0, 0, 0.0, 0, null, null,
                                   catalogBot.BotGender, 0, catalogBot.BotType));
            }
        }
Example #8
0
        /// <summary>
        ///     Gets the linked tele.
        /// </summary>
        /// <param name="teleId">The tele identifier.</param>
        /// <param name="pRoom">The p room.</param>
        /// <returns>System.UInt32.</returns>
        internal static uint GetLinkedTele(uint teleId, Room pRoom)
        {
            uint result;

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery($"SELECT tele_two_id FROM items_teleports WHERE tele_one_id = {teleId}");
                DataRow row = queryReactor.GetRow();

                result = row == null ? 0 : Convert.ToUInt32(row[0]);
            }

            return(result);
        }
Example #9
0
File: Others.cs Project: sgf/Yupi
        /// <summary>
        /// Gets the friends count.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns>System.Int32.</returns>
        private static int GetFriendsCount(uint userId)
        {
            int result;

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery("SELECT COUNT(*) FROM messenger_friendships WHERE user_one_id = @id OR user_two_id = @id;");
                queryReactor.AddParameter("id", userId);

                result = queryReactor.GetInteger();
            }

            return(result);
        }
Example #10
0
        /// <summary>
        ///     Loads the specified index.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <returns>SmallPromo.</returns>
        public static HotelLandingPromos Load(int index)
        {
            using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                commitableQueryReactor.SetQuery(
                    "SELECT hotelview_promos.`index`,hotelview_promos.header,hotelview_promos.body,hotelview_promos.button,hotelview_promos.in_game_promo,hotelview_promos.special_action,hotelview_promos.image,hotelview_promos.enabled FROM hotelview_promos WHERE hotelview_promos.`index` = @x LIMIT 1");
                commitableQueryReactor.AddParameter("x", index);

                DataRow row = commitableQueryReactor.GetRow();

                return(new HotelLandingPromos(index, (string)row[1], (string)row[2], (string)row[3],
                                              Convert.ToInt32(row[4]), (string)row[5], (string)row[6]));
            }
        }
Example #11
0
 public static void Save(uint id, bool stackable, bool allowTrade, double[] height, uint modes)
 {
     using (IQueryAdapter commitableQueryReacter = Yupi.GetDatabaseManager().GetQueryReactor())
     {
         commitableQueryReacter.SetQuery(
             "UPDATE LOW_PRIORITY catalog_furnitures SET stack_height = @height, can_stack = @stack, allow_trade = @trade, interaction_modes_count = @modes WHERE id = " +
             id);
         commitableQueryReacter.AddParameter("height", string.Join(";", height).Replace(',', '.'));
         commitableQueryReacter.AddParameter("stack", stackable ? "1" : "0");
         commitableQueryReacter.AddParameter("trade", allowTrade ? "1" : "0");
         commitableQueryReacter.AddParameter("modes", modes);
         commitableQueryReacter.RunQuery();
     }
 }
Example #12
0
        /// <summary>
        ///     _s the load my groups.
        /// </summary>
        internal void _LoadMyGroups()
        {
            using (IQueryAdapter commitableQueryAdapter = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                commitableQueryAdapter.SetQuery($"SELECT id FROM groups_data WHERE owner_id = {Id}");

                foreach (DataRow dRow in commitableQueryAdapter.GetTable().Rows)
                {
                    _myGroups.Add(Convert.ToUInt32(dRow["id"]));
                }

                _loadedMyGroups = true;
            }
        }
Example #13
0
        public override bool Execute(GameClient session, string[] pms)
        {
            using (IQueryAdapter adapter = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                FurnitureDataManager.SetCache();
                Yupi.GetGame().GetItemManager().LoadItems(adapter);
                Yupi.GetGame().GetCatalog().Initialize(adapter);
                FurnitureDataManager.Clear();
            }

            Yupi.GetGame().GetClientManager().QueueBroadcaseMessage(new ServerMessage(LibraryParser.OutgoingRequest("PublishShopMessageComposer")));

            return(true);
        }
Example #14
0
        private void LoadHvBadges()
        {
            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery("SELECT * FROM hotelview_badges WHERE enabled = '1'");

                DataTable table = queryReactor.GetTable();

                foreach (DataRow dataRow in table.Rows)
                {
                    HotelViewBadges.Add((string)dataRow[0], (string)dataRow[1]);
                }
            }
        }
Example #15
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 #16
0
        /// <summary>
        ///     Initializes the groups.
        /// </summary>
        internal void InitGroups()
        {
            Bases             = new HashSet <GroupBases>();
            Symbols           = new HashSet <GroupSymbols>();
            BaseColours       = new HashSet <GroupBaseColours>();
            SymbolColours     = new HybridDictionary();
            BackGroundColours = new HybridDictionary();
            Groups            = new HybridDictionary();

            ClearInfo();

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery("SELECT * FROM groups_badges_parts ORDER BY id");

                DataTable table = queryReactor.GetTable();

                if (table == null)
                {
                    return;
                }

                foreach (DataRow row in table.Rows)
                {
                    switch (row["type"].ToString().ToLower())
                    {
                    case "base":
                        Bases.Add(new GroupBases(int.Parse(row["id"].ToString()), row["code"].ToString(), row["second_code"].ToString()));
                        break;

                    case "symbol":
                        Symbols.Add(new GroupSymbols(int.Parse(row["id"].ToString()), row["code"].ToString(), row["second_code"].ToString()));
                        break;

                    case "base_color":
                        BaseColours.Add(new GroupBaseColours(int.Parse(row["id"].ToString()), row["code"].ToString()));
                        break;

                    case "symbol_color":
                        SymbolColours.Add(int.Parse(row["id"].ToString()), new GroupSymbolColours(int.Parse(row["id"].ToString()), row["code"].ToString()));
                        break;

                    case "other_color":
                        BackGroundColours.Add(int.Parse(row["id"].ToString()), new GroupBackGroundColours(int.Parse(row["id"].ToString()), row["code"].ToString()));
                        break;
                    }
                }
            }
        }
Example #17
0
        /// <summary>
        ///     Adds the playlist item.
        /// </summary>
        internal void AddPlaylistItem()
        {
            if (Session?.GetHabbo() == null || Session.GetHabbo().CurrentRoom == null)
            {
                return;
            }

            Room currentRoom = Session.GetHabbo().CurrentRoom;

            if (!currentRoom.CheckRights(Session, true))
            {
                return;
            }

            SoundMachineManager roomMusicController = currentRoom.GetRoomMusicController();

            if (roomMusicController.PlaylistSize >= roomMusicController.PlaylistCapacity)
            {
                return;
            }

            uint num = Request.GetUInteger();

            UserItem item = Session.GetHabbo().GetInventoryComponent().GetItem(num);

            if (item == null || item.BaseItem.InteractionType != Interaction.MusicDisc)
            {
                return;
            }

            SongItem songItem = new SongItem(item);

            int num2 = roomMusicController.AddDisk(songItem);

            if (num2 < 0)
            {
                return;
            }

            songItem.SaveToDatabase(currentRoom.RoomId);

            Session.GetHabbo().GetInventoryComponent().RemoveItem(num, true);

            using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                commitableQueryReactor.RunFastQuery($"UPDATE items_rooms SET user_id='0' WHERE id={num} LIMIT 1");

            Session.SendMessage(SoundMachineComposer.Compose(roomMusicController.PlaylistCapacity,
                                                             roomMusicController.Playlist.Values.ToList()));
        }
Example #18
0
        /// <summary>
        ///     Gets a hopper.
        /// </summary>
        /// <param name="curRoom">The current room.</param>
        /// <returns>System.UInt32.</returns>
        internal static uint GetAHopper(uint curRoom)
        {
            uint result;

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(
                    $"SELECT room_id FROM items_hopper WHERE room_id <> '{curRoom}' ORDER BY RAND() LIMIT 1");

                uint num = Convert.ToUInt32(queryReactor.GetInteger());
                result = num;
            }

            return(result);
        }
Example #19
0
        /// <summary>
        ///     Gets the search result.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <returns>List&lt;SearchResult&gt;.</returns>
        internal static List <SearchResult> GetSearchResult(string query)
        {
            DataTable table;

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery("SELECT id,username,motto,look,last_online FROM users WHERE username LIKE @query LIMIT 50");

                queryReactor.AddParameter("query", $"{query}%");

                table = queryReactor.GetTable();
            }

            return((from DataRow dataRow in table.Rows let userId = Convert.ToUInt32(dataRow[0]) let userName = (string)dataRow[1] let motto = (string)dataRow[2] let look = (string)dataRow[3] let lastOnline = dataRow[4].ToString() select new SearchResult(userId, userName, motto, look, lastOnline)).ToList());
        }
Example #20
0
        /// <summary>
        ///     Saves the specified room identifier.
        /// </summary>
        /// <param name="roomId"></param>
        internal void Save(uint roomId)
        {
            if (IsSaved)
            {
                return;
            }

            using (IQueryAdapter adapter = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                adapter.SetQuery($"INSERT INTO users_chatlogs (user_id, room_id, timestamp, message) VALUES ('{UserId}', '{roomId}', '{Yupi.DateTimeToUnix(TimeStamp)}', @messageid_{UserId})");
                adapter.AddParameter("messageid_" + UserId, Message);

                adapter.RunQuery();
            }
        }
Example #21
0
        /// <summary>
        ///     Deletes the theGroup.
        /// </summary>
        /// <param name="id">The identifier.</param>
        internal void DeleteGroup(uint id)
        {
            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(string.Format("DELETE FROM groups_members WHERE group_id = {0};" +
                                                    "DELETE FROM groups_requests WHERE group_id = {0};" +
                                                    "DELETE FROM groups_forums_data WHERE group_id = {0}; " +
                                                    "DELETE FROM groups_data WHERE id = {0};" +
                                                    "UPDATE rooms_data SET group_id = 0 WHERE group_id = {0};", id)
                                      );
                queryReactor.RunQuery();

                Groups.Remove(id);
            }
        }
Example #22
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="RoomEvents" /> class.
 /// </summary>
 internal RoomEvents()
 {
     _events = new Dictionary <uint, RoomEvent>();
     using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
     {
         commitableQueryReactor.SetQuery("SELECT * FROM rooms_events WHERE `expire` > UNIX_TIMESTAMP()");
         DataTable table = commitableQueryReactor.GetTable();
         foreach (DataRow dataRow in table.Rows)
         {
             _events.Add((uint)dataRow[0],
                         new RoomEvent((uint)dataRow[0], dataRow[1].ToString(), dataRow[2].ToString(), (int)dataRow[3],
                                       (int)dataRow[4]));
         }
     }
 }
Example #23
0
        /// <summary>
        ///     Reloads the subscription.
        /// </summary>
        internal void ReloadSubscription()
        {
            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(
                    "SELECT * FROM users_subscriptions WHERE user_id=@id AND timestamp_expire > UNIX_TIMESTAMP() ORDER BY subscription_id DESC LIMIT 1");
                queryReactor.AddParameter("id", _userId);

                DataRow row = queryReactor.GetRow();

                _subscription = row == null
                    ? null
                    : new Subscription((int)row[1], (int)row[2], (int)row[3], (int)row[4]);
            }
        }
Example #24
0
 internal void UpdateInDb()
 {
     using (IQueryAdapter adapter = Yupi.GetDatabaseManager().GetQueryReactor())
     {
         adapter.SetQuery(
             "REPLACE INTO pets_plants (pet_id, rarity, plant_name, plant_data, plant_state, growing_status) VALUES (@petid , @rarity , @plantname , @plantdata , @plantstate , @growing)");
         adapter.AddParameter("petid", _petId);
         adapter.AddParameter("rarity", _rarity);
         adapter.AddParameter("plantname", Name);
         adapter.AddParameter("plantdata", PlantData);
         adapter.AddParameter("plantstate", ((int)LiveState).ToString());
         adapter.AddParameter("growing", GrowingStatus);
         adapter.RunQuery();
     }
 }
Example #25
0
        public static void SaveWired(IWiredItem fItem)
        {
            if (fItem == null)
            {
                return;
            }

            using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                string text = string.Empty;
                int    num  = 0;

                foreach (RoomItem current in fItem.Items)
                {
                    if (num != 0)
                    {
                        text += ";";
                    }
                    text += current.Id;
                    num++;
                }

                if (fItem.OtherString == null)
                {
                    fItem.OtherString = string.Empty;
                }
                if (fItem.OtherExtraString == null)
                {
                    fItem.OtherExtraString = string.Empty;
                }
                if (fItem.OtherExtraString2 == null)
                {
                    fItem.OtherExtraString2 = string.Empty;
                }

                commitableQueryReactor.SetQuery(
                    "REPLACE INTO items_wireds VALUES (@id, @items, @delay, @string, @bool, @extrastring, @extrastring2)");
                commitableQueryReactor.AddParameter("id", fItem.Item.Id);
                commitableQueryReactor.AddParameter("items", text);
                commitableQueryReactor.AddParameter("delay", fItem.Delay);
                commitableQueryReactor.AddParameter("string", fItem.OtherString);
                commitableQueryReactor.AddParameter("bool", Yupi.BoolToEnum(fItem.OtherBool));
                commitableQueryReactor.AddParameter("extrastring", fItem.OtherExtraString);
                commitableQueryReactor.AddParameter("extrastring2", fItem.OtherExtraString2);

                commitableQueryReactor.RunQuery();
            }
        }
Example #26
0
        /// <summary>
        ///     Adds the user score.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="username">The username.</param>
        /// <param name="score">The score.</param>
        internal void AddUserScore(RoomItem item, string username, int score)
        {
            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                if (item.GetBaseItem().Name.StartsWith("highscore_classic"))
                {
                    queryReactor.SetQuery(
                        "INSERT INTO items_highscores (item_id,username,score) VALUES (@itemid,@username,@score)");
                    queryReactor.AddParameter("itemid", item.Id);
                    queryReactor.AddParameter("username", username);
                    queryReactor.AddParameter("score", score);
                    queryReactor.RunQuery();
                }
                else if (item.GetBaseItem().Name.StartsWith("highscore_mostwin"))
                {
                    score = 1;
                    queryReactor.SetQuery(
                        "SELECT id,score FROM items_highscores WHERE username = @username AND item_id = @itemid");
                    queryReactor.AddParameter("itemid", item.Id);
                    queryReactor.AddParameter("username", username);

                    DataRow row = queryReactor.GetRow();

                    if (row != null)
                    {
                        queryReactor.SetQuery(
                            "UPDATE items_highscores SET score = score + 1 WHERE username = @username AND item_id = @itemid");
                        queryReactor.AddParameter("itemid", item.Id);
                        queryReactor.AddParameter("username", username);
                        queryReactor.RunQuery();
                        Lines.Remove((int)row["id"]);
                        score = (int)row["score"] + 1;
                    }
                    else
                    {
                        queryReactor.SetQuery(
                            "INSERT INTO items_highscores (item_id,username,score) VALUES (@itemid,@username,@score)");
                        queryReactor.AddParameter("itemid", item.Id);
                        queryReactor.AddParameter("username", username);
                        queryReactor.AddParameter("score", score);
                        queryReactor.RunQuery();
                    }
                }

                LastId++;
                Lines.Add(LastId, new HighScoreLine(username, score));
            }
        }
Example #27
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 #28
0
        /// <summary>
        ///     Closes all.
        /// </summary>
        internal void CloseAll()
        {
            StringBuilder stringBuilder = new StringBuilder();
            bool          flag          = false;

            Writer.WriteLine("Saving Inventary Content....", "Yupi.Boot", ConsoleColor.DarkCyan);

            foreach (GameClient current2 in Clients.Values.Where(current2 => current2.GetHabbo() != null))
            {
                current2.GetHabbo().GetInventoryComponent().RunDbUpdate();
                current2.GetHabbo().RunDbUpdate(Yupi.GetDatabaseManager().GetQueryReactor());
                stringBuilder.Append(current2.GetHabbo().GetQueryString);
                flag = true;
                Console.ForegroundColor = ConsoleColor.DarkMagenta;
            }

            Writer.WriteLine("Inventary Content Saved!", "Yupi.Boot", ConsoleColor.DarkCyan);

            if (flag)
            {
                if (stringBuilder.Length > 0)
                {
                    using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                        queryReactor.RunFastQuery(stringBuilder.ToString());
                }
            }
            try
            {
                Writer.WriteLine("Closing Connection Manager...", "Yupi.Boot", ConsoleColor.DarkMagenta);

                foreach (GameClient current3 in Clients.Values.Where(current3 => current3.GetConnection() != null))
                {
                    current3.GetConnection().Dispose();

                    Console.ForegroundColor = ConsoleColor.DarkMagenta;

                    Writer.WriteLine("Connection Manager Closed!", "Yupi.Boot", ConsoleColor.DarkMagenta);
                }
            }
            catch (Exception ex)
            {
                ServerLogManager.LogCriticalException(ex.ToString());
            }

            Clients.Clear();

            Writer.WriteLine("Connections closed", "Yupi.Conn", ConsoleColor.DarkYellow);
        }
Example #29
0
        /// <summary>
        ///     Habboes the camera.
        /// </summary>
        internal void HabboCamera()
        {
            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(
                    $"SELECT * FROM cms_stories_photos_preview WHERE user_id = {Session.GetHabbo().Id} AND type = 'PHOTO' ORDER BY id DESC LIMIT 1");

                DataTable table = queryReactor.GetTable();

                foreach (DataRow dataRow in table.Rows)
                {
                    object date  = dataRow["date"];
                    object room  = dataRow["room_id"];
                    object photo = dataRow["id"];
                    object image = dataRow["image_url"];

                    using (IQueryAdapter queryReactor2 = Yupi.GetDatabaseManager().GetQueryReactor())
                    {
                        queryReactor2.SetQuery(
                            "INSERT INTO cms_stories_photos (user_id,user_name,room_id,image_preview_url,image_url,type,date,tags) VALUES (@user_id,@user_name,@room_id,@image_url,@image_url,@type,@date,@tags)");
                        queryReactor2.AddParameter("user_id", Session.GetHabbo().Id);
                        queryReactor2.AddParameter("user_name", Session.GetHabbo().UserName);
                        queryReactor2.AddParameter("room_id", room);
                        queryReactor2.AddParameter("image_url", image);
                        queryReactor2.AddParameter("type", "PHOTO");
                        queryReactor2.AddParameter("date", date);
                        queryReactor2.AddParameter("tags", "");
                        queryReactor2.RunQuery();

                        string newPhotoData = "{\"t\":" + date + ",\"u\":\"" + photo + "\",\"m\":\"\",\"s\":" + room +
                                              ",\"w\":\"" + image + "\"}";

                        UserItem item = Session.GetHabbo()
                                        .GetInventoryComponent()
                                        .AddNewItem(0, "external_image_wallitem_poster", newPhotoData, 0, true, false, 0, 0);

                        Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
                        Session.GetHabbo().Credits -= 2;
                        Session.GetHabbo().UpdateCreditsBalance();
                        Session.GetHabbo().GetInventoryComponent().SendNewItems(item.Id);
                    }
                }
            }

            ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("CameraPurchaseOk"));

            Session.SendMessage(message);
        }
Example #30
0
File: UserInfo.cs Project: sgf/Yupi
        public override bool Execute(GameClient session, string[] pms)
        {
            string userName = pms[0];

            if (string.IsNullOrEmpty(userName))
            {
                return(true);
            }
            GameClient clientByUserName = Yupi.GetGame().GetClientManager().GetClientByUserName(userName);

            if (clientByUserName == null || clientByUserName.GetHabbo() == null)
            {
                using (IQueryAdapter adapter = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    adapter.SetQuery(
                        "SELECT username, rank, id, credits, activity_points, diamonds FROM users WHERE username=@user LIMIT 1");
                    adapter.AddParameter("user", userName);
                    DataRow row = adapter.GetRow();

                    if (row == null)
                    {
                        session.SendWhisper(Yupi.GetLanguage().GetVar("user_not_found"));
                        return(true);
                    }
                    session.SendNotif(string.Format(Yupi.GetLanguage().GetVar("user_info_all"), userName, row[1],
                                                    row[3], row[4], row[5]));
                }
                return(true);
            }
            Habbo         habbo   = clientByUserName.GetHabbo();
            StringBuilder builder = new StringBuilder();

            if (habbo.CurrentRoom != null)
            {
                builder.AppendFormat(" - ROOM INFORMATION [{0}] - \r", habbo.CurrentRoom.RoomId);
                builder.AppendFormat("Owner: {0}\r", habbo.CurrentRoom.RoomData.Owner);
                builder.AppendFormat("Room Name: {0}\r", habbo.CurrentRoom.RoomData.Name);
                builder.Append(
                    string.Concat("Current Users: ", habbo.CurrentRoom.UserCount, "/",
                                  habbo.CurrentRoom.RoomData.UsersMax));
            }
            session.SendNotif(string.Concat("User info for: ", userName, " \rUser ID: ", habbo.Id, ":\rRank: ",
                                            habbo.Rank, "\rCurrentTalentLevel: ", habbo.CurrentTalentLevel, " \rCurrent Room: ", habbo.CurrentRoomId,
                                            " \rCredits: ", habbo.Credits, "\rDuckets: ", habbo.ActivityPoints, "\rDiamonds: ", habbo.Diamonds,
                                            "\rMuted: ", habbo.Muted.ToString(), "\r\r\r", builder.ToString()));

            return(true);
        }