Пример #1
0
 internal void GiveUserCrystals(int p)
 {
     using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
     {
         dbClient.runFastQuery("UPDATE users SET crystals = crystals + " + p + " WHERE id = '" + Id + "'");
     }
 }
Пример #2
0
        internal void AddFavorite()
        {
            uint Id = Request.PopWiredUInt();

            RoomData Data = PiciEnvironment.GetGame().GetRoomManager().GenerateRoomData(Id);

            if (Data == null || Session.GetHabbo().FavoriteRooms.Count >= 30 || Session.GetHabbo().FavoriteRooms.Contains(Id) || Data.Type == "public")
            {
                GetResponse().Init(33);
                GetResponse().AppendInt32(-9001);
                SendResponse();

                return;
            }

            GetResponse().Init(459);
            GetResponse().AppendUInt(Id);
            GetResponse().AppendBoolean(true);
            SendResponse();

            Session.GetHabbo().FavoriteRooms.Add(Id);

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("INSERT INTO user_favorites (user_id,room_id) VALUES (" + Session.GetHabbo().Id + "," + Id + ")");
            }
        }
Пример #3
0
        internal void GetWardrobe()
        {
            GetResponse().Init(267);
            GetResponse().AppendBoolean(true);

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                //dbClient.addParameter("userid", Session.GetHabbo().Id);
                dbClient.setQuery("SELECT slot_id, look, gender FROM user_wardrobe WHERE user_id = " + Session.GetHabbo().Id);
                DataTable WardrobeData = dbClient.getTable();

                if (WardrobeData == null)
                {
                    GetResponse().Append(0);
                }
                else
                {
                    GetResponse().Append(WardrobeData.Rows.Count);

                    foreach (DataRow Row in WardrobeData.Rows)
                    {
                        GetResponse().Append(Convert.ToUInt32(Row["slot_id"]));
                        GetResponse().Append((string)Row["look"]);
                        GetResponse().Append((string)Row["gender"]);
                    }
                }
            }

            SendResponse();
        }
Пример #4
0
        internal RoomData GenerateRoomData(UInt32 RoomId)
        {
            if (loadedRoomData.ContainsKey(RoomId))
            {
                return((RoomData)loadedRoomData[RoomId]);
            }

            RoomData Data = new RoomData();

            if (IsRoomLoaded(RoomId))
            {
                return(GetRoom(RoomId).RoomData);
            }
            else
            {
                DataRow Row = null;

                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT rooms.*, room_active.active_users FROM rooms LEFT JOIN room_active ON (room_active.roomid = rooms.id) WHERE id = " + RoomId);
                    Row = dbClient.getRow();
                }

                if (Row == null)
                {
                    return(null);
                }

                Data.Fill(Row);
                loadedRoomData.Add(RoomId, Data);
            }

            return(Data);
        }
Пример #5
0
        internal static void Save()
        {
            if (!enabled)
            {
                return;
            }

            lock (loggedMessages.SyncRoot)
            {
                int totalMessages = loggedMessages.Count;

                if (loggedMessages.Count > 0)
                {
                    using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        while (loggedMessages.Count > 0)
                        {
                            Message message = (Message)loggedMessages.Dequeue();

                            dbClient.setQuery("INSERT INTO system_packetlog (connectionid, timestamp, data) VALUES @connectionid @timestamp, @data");
                            dbClient.addParameter("connectionid", message.ConnectionID);
                            dbClient.addParameter("timestamp", message.GetTimestamp);
                            dbClient.addParameter("data", message.GetData);

                            dbClient.runQuery();
                        }
                    }
                }
            }
        }
Пример #6
0
        internal void MarketplaceClaimCredits()
        {
            DataTable Results = null;

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT asking_price FROM catalog_marketplace_offers WHERE user_id = " + Session.GetHabbo().Id + " AND state = 2");
                Results = dbClient.getTable();
            }

            if (Results == null)
            {
                return;
            }

            int Profit = 0;

            foreach (DataRow Row in Results.Rows)
            {
                Profit += (int)Row["asking_price"];
            }

            if (Profit >= 1)
            {
                Session.GetHabbo().Credits += Profit;
                Session.GetHabbo().UpdateCreditsBalance();
            }

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("DELETE FROM catalog_marketplace_offers WHERE user_id = " + Session.GetHabbo().Id + " AND state = 2");
            }
        }
Пример #7
0
        internal static void KickUser(GameClient ModSession, uint UserId, String Message, Boolean Soft)
        {
            GameClient Client = PiciEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);

            if (Client == null || Client.GetHabbo().CurrentRoomId < 1 || Client.GetHabbo().Id == ModSession.GetHabbo().Id)
            {
                return;
            }

            if (Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank)
            {
                ModSession.SendNotif(LanguageLocale.GetValue("moderation.kick.missingrank"));
                return;
            }

            Room Room = PiciEnvironment.GetGame().GetRoomManager().GetRoom(Client.GetHabbo().CurrentRoomId);

            if (Room == null)
            {
                return;
            }

            Room.GetRoomUserManager().RemoveUserFromRoom(Client, true, false);
            Client.CurrentRoomUserID = -1;

            if (!Soft)
            {
                Client.SendNotif(Message);

                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE user_info SET cautions = cautions + 1 WHERE user_id = " + UserId + "");
                }
            }
        }
Пример #8
0
 internal void RemoveFromDatabase()
 {
     using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
     {
         dbClient.runFastQuery("DELETE FROM items_rooms_songs WHERE itemid = " + itemID);
     }
 }
Пример #9
0
        internal MoodlightData(uint ItemId)
        {
            this.ItemId = ItemId;

            DataRow Row;

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT enabled,current_preset,preset_one,preset_two,preset_three FROM items_moodlight WHERE item_id = " + ItemId);
                Row = dbClient.getRow();
            }

            if (Row == null)
            {
                throw new NullReferenceException("No moodlightdata found in the database");
            }

            this.Enabled       = PiciEnvironment.EnumToBool(Row["enabled"].ToString());
            this.CurrentPreset = (int)Row["current_preset"];
            this.Presets       = new List <MoodlightPreset>();

            this.Presets.Add(GeneratePreset((string)Row["preset_one"]));
            this.Presets.Add(GeneratePreset((string)Row["preset_two"]));
            this.Presets.Add(GeneratePreset((string)Row["preset_three"]));
        }
Пример #10
0
        internal AvatarEffectsInventoryComponent(uint UserId, GameClient pClient, UserData data)
        {
            this.mClient       = pClient;
            this.Effects       = new ArrayList();
            this.UserId        = UserId;
            this.CurrentEffect = -1;
            this.Effects.Clear();

            StringBuilder QueryBuilder = new StringBuilder();

            foreach (AvatarEffect effect in data.effects)
            {
                if (!effect.HasExpired)
                {
                    Effects.Add(effect);
                    EffectCount++;
                }
                else
                {
                    QueryBuilder.Append("DELETE FROM user_effects WHERE user_id = " + UserId + " AND effect_id = " + effect.EffectId + "; ");
                }
            }

            if (QueryBuilder.Length > 0)
            {
                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                    dbClient.runFastQuery(QueryBuilder.ToString());
            }
        }
Пример #11
0
        internal void StopEffect(int EffectId)
        {
            AvatarEffect Effect = GetEffect(EffectId, true);

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

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("DELETE FROM user_effects WHERE user_id = " + UserId + " AND effect_id = " + EffectId + " AND is_activated = 1");
            }

            Effects.Remove(Effect);
            EffectCount--;

            GetClient().GetMessageHandler().GetResponse().Init(463);
            GetClient().GetMessageHandler().GetResponse().AppendInt32(EffectId);
            GetClient().GetMessageHandler().SendResponse();

            if (CurrentEffect >= 0)
            {
                ApplyEffect(-1);
            }
        }
Пример #12
0
        internal void Close(TicketStatus NewStatus, Boolean UpdateInDb)
        {
            this.Status = NewStatus;

            if (UpdateInDb)
            {
                String dbType = "";

                switch (NewStatus)
                {
                case TicketStatus.ABUSIVE:

                    dbType = "abusive";
                    break;

                case TicketStatus.INVALID:

                    dbType = "invalid";
                    break;

                case TicketStatus.RESOLVED:
                default:

                    dbType = "resolved";
                    break;
                }

                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE moderation_tickets SET status = '" + dbType + "' WHERE id = " + Id + "");
                }
            }
        }
Пример #13
0
        internal void SaveWardrobe()
        {
            uint SlotId = Request.PopWiredUInt();

            string Look   = Request.PopFixedString();
            string Gender = Request.PopFixedString();

            if (!AntiMutant.ValidateLook(Look, Gender))
            {
                return;
            }

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT null FROM user_wardrobe WHERE user_id = " + Session.GetHabbo().Id + " AND slot_id = " + SlotId + "");
                dbClient.addParameter("look", Look);
                dbClient.addParameter("gender", Gender.ToUpper());

                if (dbClient.getRow() != null)
                {
                    dbClient.setQuery("UPDATE user_wardrobe SET look = @look, gender = @gender WHERE user_id = " + Session.GetHabbo().Id + " AND slot_id = " + SlotId + ";");
                    dbClient.addParameter("look", Look);
                    dbClient.addParameter("gender", Gender.ToUpper());
                    dbClient.runQuery();
                }
                else
                {
                    dbClient.setQuery("INSERT INTO user_wardrobe (user_id,slot_id,look,gender) VALUES (" + Session.GetHabbo().Id + "," + SlotId + ",@look,@gender)");
                    dbClient.addParameter("look", Look);
                    dbClient.addParameter("gender", Gender.ToUpper());
                    dbClient.runQuery();
                }
            }
        }
Пример #14
0
        internal void OnNewFriendship(uint friendID)
        {
            GameClient friend = PiciEnvironment.GetGame().GetClientManager().GetClientByUserID(friendID);

            MessengerBuddy newFriend;

            if (friend == null || friend.GetHabbo() == null)
            {
                DataRow dRow;
                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT username,motto,look,last_online FROM users WHERE id = " + friendID);
                    dRow = dbClient.getRow();
                }

                newFriend = new MessengerBuddy(friendID, (string)dRow["username"], (string)dRow["look"], (string)dRow["motto"], (string)dRow["last_online"]);
            }
            else
            {
                Habbo user = friend.GetHabbo();
                newFriend = new MessengerBuddy(friendID, user.Username, user.Look, user.Motto, string.Empty);
                newFriend.UpdateUser(friend);
            }

            if (!friends.ContainsKey(friendID))
            {
                friends.Add(friendID, newFriend);
            }

            GetClient().SendMessage(SerializeUpdate(newFriend));
        }
Пример #15
0
        internal static void AlertUser(GameClient ModSession, uint UserId, String Message, Boolean Caution)
        {
            GameClient Client = PiciEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);

            if (Client == null || Client.GetHabbo().Id == ModSession.GetHabbo().Id)
            {
                return;
            }

            if (Caution && Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank)
            {
                ModSession.SendNotif(LanguageLocale.GetValue("moderation.caution.missingrank"));
                Caution = false;
            }

            Client.SendNotif(Message, Caution);

            if (Caution)
            {
                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE user_info SET cautions = cautions + 1 WHERE user_id = " + UserId + "");
                }
            }
        }
Пример #16
0
        internal Game(int conns)
        {
            ClientManager = new GameClientManager();

            //if (PiciEnvironment.GetConfig().data["client.ping.enabled"] == "1")
            //{
            //    ClientManager.StartConnectionChecker();
            //}


            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                //PiciEnvironment.GameInstance = this;
                DateTime start = DateTime.Now;

                BanManager           = new ModerationBanManager();
                RoleManager          = new RoleManager();
                HelpTool             = new HelpTool();
                Catalog              = new Catalog();
                Navigator            = new Navigator();
                ItemManager          = new ItemManager();
                RoomManager          = new RoomManager();
                AdvertisementManager = new AdvertisementManager();
                PixelManager         = new PixelManager();

                ModerationTool = new ModerationTool();
                BotManager     = new BotManager();
                questManager   = new QuestManager();
                //soundMachineManager = new SoundMachineManager();

                TimeSpan spent = DateTime.Now - start;
            }
        }
Пример #17
0
        internal void MarketplaceTakeBack()
        {
            uint    ItemId = Request.PopWiredUInt();
            DataRow Row    = null;

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT item_id, user_id, extra_data, offer_id state FROM catalog_marketplace_offers WHERE offer_id = " + ItemId + " LIMIT 1");
                Row = dbClient.getRow();
            }

            if (Row == null || Convert.ToUInt32(Row["user_id"]) != Session.GetHabbo().Id || (UInt32)Row["state"] != 1)
            {
                return;
            }

            Item Item = PiciEnvironment.GetGame().GetItemManager().GetItem(Convert.ToUInt32(Row["item_id"]));

            if (Item == null)
            {
                return;
            }

            PiciEnvironment.GetGame().GetCatalog().DeliverItems(Session, Item, 1, (String)Row["extra_data"]);

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("DELETE FROM catalog_marketplace_offers WHERE offer_id = " + ItemId + "");
            }

            GetResponse().Init(614);
            GetResponse().AppendUInt(Convert.ToUInt32(Row["offer_id"]));
            GetResponse().AppendBoolean(true);
            SendResponse();
        }
Пример #18
0
        internal void ActivateQuest(GameClient Session, ClientMessage Message)
        {
            Quest Quest = GetQuest(Message.PopWiredUInt());

            if (Quest == null)
            {
                return;
            }

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == Pici.Storage.Database.DatabaseType.MySQL)
                {
                    dbClient.runFastQuery("REPLACE INTO user_quests VALUES (" + Session.GetHabbo().Id + ", " + Quest.Id + ", 0)");
                }
                else
                {
                    dbClient.runFastQuery("IF NOT EXISTS (SELECT user_id FROM user_quests WHERE user_id = " + Session.GetHabbo().Id + " AND quest_id = " + Quest.Id + ") " +
                                          "INSERT INTO user_quests VALUES (" + Session.GetHabbo().Id + ", " + Quest.Id + ", 0)");
                }
                dbClient.runFastQuery("UPDATE users SET currentquestid = " + Quest.Id + " WHERE id = " + Session.GetHabbo().Id);
            }

            Session.GetHabbo().CurrentQuestId = Quest.Id;
            GetList(Session, null);
            Session.SendMessage(QuestStartedComposer.Compose(Session, Quest));
        }
Пример #19
0
        internal ServerMessage SerializeSearchResults(string SearchQuery)
        {
            DataTable Data = new DataTable();

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (SearchQuery.Length > 0)
                {
                    if (dbClient.dbType == Pici.Storage.Database.DatabaseType.MySQL)
                    {
                        dbClient.setQuery("SELECT rooms.*, room_active.active_users FROM rooms LEFT JOIN room_active ON (room_active.roomid = rooms.id) WHERE owner = @query AND roomtype = 'private' " +
                                          "UNION ALL " +
                                          "SELECT rooms.*, room_active.active_users FROM rooms LEFT JOIN room_active ON (room_active.roomid = rooms.id) WHERE caption = @query AND roomtype = 'private' " +
                                          "ORDER BY active_users DESC LIMIT 50");
                    }
                    else
                    {
                        dbClient.setQuery("SELECT TOP 50 rooms.*, room_active.active_users FROM rooms LEFT JOIN room_active ON (room_active.roomid = rooms.id) WHERE owner = @query AND roomtype = 'private' " +
                                          "UNION ALL " +
                                          "SELECT rooms.*, room_active.active_users FROM rooms LEFT JOIN room_active ON (room_active.roomid = rooms.id) WHERE caption = @query AND roomtype = 'private' " +
                                          "ORDER BY active_users DESC");
                    }
                    dbClient.addParameter("query", SearchQuery);
                    Data = dbClient.getTable();
                }
            }

            List <RoomData> Results = new List <RoomData>();

            if (Data != null)
            {
                foreach (DataRow Row in Data.Rows)
                {
                    RoomData RData = PiciEnvironment.GetGame().GetRoomManager().FetchRoomData(Convert.ToUInt32(Row["id"]), Row);
                    Results.Add(RData);
                }
            }

            ServerMessage Message = new ServerMessage(451);

            Message.AppendInt32(1);
            Message.AppendInt32(9);
            Message.AppendStringWithBreak(SearchQuery);
            Message.AppendInt32(Results.Count);

            int i = 0;

            foreach (RoomData Room in Results)
            {
                if (i > 0)
                {
                    Message.AppendInt32(0);
                }
                Room.Serialize(Message, false);
                i++;
            }

            return(Message);
        }
Пример #20
0
        internal void FlushSettings()
        {
            List <ServerMessage> messages = new List <ServerMessage>();

            lock (GetRoomItemHandler().mFloorItems)
            {
                foreach (RoomItem Item in GetRoomItemHandler().mFloorItems.Values)
                {
                    ServerMessage Message = new ServerMessage(94);
                    Message.AppendUInt(Item.Id);
                    Message.AppendStringWithBreak("");
                    Message.AppendBoolean(false);
                    messages.Add(Message);
                }
            }


            lock (GetRoomItemHandler().mWallItems)
            {
                foreach (RoomItem Item in GetRoomItemHandler().mWallItems.Values)
                {
                    ServerMessage Message = new ServerMessage(84);
                    Message.AppendUInt(Item.Id);
                    Message.AppendStringWithBreak("");
                    Message.AppendBoolean(false);
                    messages.Add(Message);
                }
            }

            SendMessage(messages);


            mCycleEnded = true;
            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                GetRoomItemHandler().SaveFurniture(dbClient);

            Tags.Clear();
            UsersWithRights.Clear();
            Bans.Clear();
            ActiveTrades.Clear();


            if (GotFreeze())
            {
                freeze = new Freeze(this);
            }
            if (GotBanzai())
            {
                banzai = new BattleBanzai(this);
            }
            if (GotSoccer())
            {
                soccer = new Soccer(this);
            }
            if (gameItemHandler != null)
            {
                gameItemHandler = new GameItemHandler(this);
            }
        }
Пример #21
0
 internal static void SaveAchievement(Achievement achievement)
 {
     using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
     {
         dbClient.setQuery("UPDATE achievement_info SET level = " + achievement.Level + ", progress = " + achievement.Progress);
         dbClient.runQuery();
     }
 }
Пример #22
0
        internal static ServerMessage SerializeUserInfo(uint UserId)
        {
            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT id, username, online FROM users WHERE id = " + UserId + "");
                DataRow User = dbClient.getRow();

                dbClient.setQuery("SELECT reg_timestamp, login_timestamp, cfhs, cfhs_abusive, cautions, bans FROM user_info WHERE user_id = " + UserId + "");
                DataRow Info = dbClient.getRow();

                if (User == null)
                {
                    throw new NullReferenceException("No user found in database");
                }

                ServerMessage Message = new ServerMessage(533);

                Message.AppendUInt(Convert.ToUInt32(User["id"]));
                Message.AppendStringWithBreak((string)User["username"]);

                if (Info != null)
                {
                    Message.AppendInt32((int)Math.Ceiling((PiciEnvironment.GetUnixTimestamp() - (Double)Info["reg_timestamp"]) / 60));
                    Message.AppendInt32((int)Math.Ceiling((PiciEnvironment.GetUnixTimestamp() - (Double)Info["login_timestamp"]) / 60));
                }
                else
                {
                    Message.AppendInt32(0);
                    Message.AppendInt32(0);
                }

                if (User["online"].ToString() == "1")
                {
                    Message.AppendBoolean(true);
                }
                else
                {
                    Message.AppendBoolean(false);
                }

                if (Info != null)
                {
                    Message.AppendInt32((int)Info["cfhs"]);
                    Message.AppendInt32((int)Info["cfhs_abusive"]);
                    Message.AppendInt32((int)Info["cautions"]);
                    Message.AppendInt32((int)Info["bans"]);
                }
                else
                {
                    Message.AppendInt32(0); // cfhs
                    Message.AppendInt32(0); // abusive cfhs
                    Message.AppendInt32(0); // cautions
                    Message.AppendInt32(0); // bans
                }

                return(Message);
            }
        }
Пример #23
0
        internal void HandleAllRequests()
        {
            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("DELETE FROM messenger_requests WHERE sender = " + UserId + " OR receiver = " + UserId);
            }

            ClearRequests();
        }
Пример #24
0
        internal void MarketplaceRowchase()
        {
            uint    ItemId = Request.PopWiredUInt();
            DataRow Row    = null;

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT state, timestamp, total_price, extra_data, item_id FROM catalog_marketplace_offers WHERE offer_id = " + ItemId + " ");
                Row = dbClient.getRow();
            }

            if (Row == null || (string)Row["state"] != "1" || (double)Row["timestamp"] <= Marketplace.FormatTimestamp())
            {
                Session.SendNotif(LanguageLocale.GetValue("catalog.offerexpired"));
                return;
            }

            Item Item = PiciEnvironment.GetGame().GetItemManager().GetItem(Convert.ToUInt32(Row["item_id"]));

            if (Item == null)
            {
                return;
            }

            int prize = (int)Row["total_price"];

            if ((int)Row["total_price"] >= 1)
            {
                Session.GetHabbo().Credits -= prize;
                Session.GetHabbo().UpdateCreditsBalance();
            }

            PiciEnvironment.GetGame().GetCatalog().DeliverItems(Session, Item, 1, (String)Row["extra_data"]);
            Session.GetHabbo().GetInventoryComponent().RunDBUpdate();

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("UPDATE catalog_marketplace_offers SET state = 2 WHERE offer_id = " + ItemId + "");
            }


            Session.GetMessageHandler().GetResponse().Init(67);
            Session.GetMessageHandler().GetResponse().AppendUInt(Item.ItemId);
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Item.Name);
            Session.GetMessageHandler().GetResponse().AppendInt32(prize);
            Session.GetMessageHandler().GetResponse().AppendInt32(0);
            Session.GetMessageHandler().GetResponse().AppendInt32(0);
            Session.GetMessageHandler().GetResponse().AppendInt32(1);
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Item.Type.ToString());
            Session.GetMessageHandler().GetResponse().AppendInt32(Item.SpriteId);
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak("");
            Session.GetMessageHandler().GetResponse().AppendInt32(1);
            Session.GetMessageHandler().GetResponse().AppendInt32(0);
            Session.GetMessageHandler().SendResponse();

            Session.SendMessage(Marketplace.SerializeOffers(-1, -1, "", 1));
        }
Пример #25
0
 private static void TryDeleteVoucher(string Code)
 {
     using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
     {
         dbClient.setQuery("DELETE FROM credit_vouchers WHERE code = @code");
         dbClient.addParameter("code", Code);
         dbClient.runQuery();
     }
 }
Пример #26
0
        internal void OnView()
        {
            this.Views++;

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("UPDATE room_ads SET views = views + 1 WHERE id = " + Id);
            }
        }
Пример #27
0
        internal void HandleRequest(uint sender)
        {
            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("DELETE FROM messenger_requests WHERE (sender = " + UserId + " AND receiver = " + sender + ") OR (receiver = " + UserId + " AND sender = " + sender + ")");
            }

            requests.Remove(sender);
        }
Пример #28
0
        internal void Disable()
        {
            this.Enabled = false;

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("UPDATE items_moodlight SET enabled = 0 WHERE item_id = " + ItemId);
            }
        }
Пример #29
0
        internal static ServerMessage SerializeOwnOffers(uint HabboId)
        {
            int       Profits = 0;
            DataTable Data;
            String    RawProfit;

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT timestamp, state, offer_id, item_type, sprite_id, total_price FROM catalog_marketplace_offers WHERE user_id = " + HabboId);
                Data = dbClient.getTable();

                dbClient.setQuery("SELECT SUM(asking_price) FROM catalog_marketplace_offers WHERE state = '2' AND user_id = " + HabboId);
                RawProfit = dbClient.getRow()[0].ToString();
            }

            if (RawProfit.Length > 0)
            {
                Profits = int.Parse(RawProfit);
            }

            ServerMessage Message = new ServerMessage(616);

            Message.AppendInt32(Profits);

            if (Data != null)
            {
                Message.AppendInt32(Data.Rows.Count);

                foreach (DataRow Row in Data.Rows)
                {
                    int MinutesLeft = (int)Math.Floor((((Double)Row["timestamp"] + 172800) - PiciEnvironment.GetUnixTimestamp()) / 60);
                    int state       = int.Parse(Row["state"].ToString());

                    if (MinutesLeft <= 0)
                    {
                        state       = 3;
                        MinutesLeft = 0;
                    }

                    Message.AppendUInt(Convert.ToUInt32(Row["offer_id"]));
                    Message.AppendInt32(state);                                  // 1 = active, 2 = sold, 3 = expired
                    Message.AppendInt32(int.Parse(Row["item_type"].ToString())); // always 1 (??)
                    Message.AppendInt32((int)Row["sprite_id"]);
                    Message.AppendStringWithBreak("");                           // Extra Chr (R52)
                    Message.AppendInt32((int)Row["total_price"]);                // ??
                    Message.AppendInt32(MinutesLeft);
                    Message.AppendInt32((int)Row["sprite_id"]);
                }
            }
            else
            {
                Message.AppendInt32(0);
            }

            return(Message);
        }
Пример #30
0
        internal void UnregisterClient(uint userid, string username)
        {
            userIDRegister.Remove(userid);
            usernameRegister.Remove(username.ToLower());

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("DELETE FROM user_online WHERE id = " + userid);
            }
        }