public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom || Session.GetHabbo().Credits < RocketEmulador.GetGame().GetCameraManager().PurchaseCoinsPrice || Session.GetHabbo().Duckets < RocketEmulador.GetGame().GetCameraManager().PurchaseDucketsPrice)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (User == null || User.LastPhotoPreview == null)
            {
                return;
            }

            CameraPhotoPreview preview = User.LastPhotoPreview;

            if (RocketEmulador.GetGame().GetCameraManager().PurchaseCoinsPrice > 0)
            {
                Session.GetHabbo().Credits -= RocketEmulador.GetGame().GetCameraManager().PurchaseCoinsPrice;
                Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits));
            }

            if (RocketEmulador.GetGame().GetCameraManager().PurchaseDucketsPrice > 0)
            {
                Session.GetHabbo().Duckets -= RocketEmulador.GetGame().GetCameraManager().PurchaseDucketsPrice;
                Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Session.GetHabbo().Duckets));
            }

            using (IQueryAdapter dbClient = RocketEmulador.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("UPDATE `camera_photos` SET `file_state` = 'purchased' WHERE `id` = '" + preview.Id + "' LIMIT 1");
                Console.WriteLine(@"Oinhe wulles fez isso aq");
            }

            Item photoPoster = ItemFactory.CreateSingleItemNullable(RocketEmulador.GetGame().GetCameraManager().PhotoPoster, Session.GetHabbo(),
                                                                    "{\"w\":\"" + StringCharFilter.EscapeJSONString(RocketEmulador.GetGame().GetCameraManager().GetPath(CameraPhotoType.PURCHASED, preview.Id, preview.CreatorId)) + "\", \"n\":\"" + StringCharFilter.EscapeJSONString(Session.GetHabbo().Username) + "\", \"s\":\"" + Session.GetHabbo().Id + "\", \"u\":\"" + preview.Id + "\", \"t\":\"" + (long)RocketEmulador.Now() + "\"}", "");

            if (photoPoster != null)
            {
                Session.GetHabbo().GetInventoryComponent().TryAddItem(photoPoster);

                Session.SendMessage(new FurniListAddComposer(photoPoster));
                Session.SendMessage(new FurniListUpdateComposer());
                Session.SendMessage(new FurniListNotificationComposer(photoPoster.Id, 1));
            }

            Session.SendMessage(new CameraPhotoPurchaseOkComposer());
        }
Пример #2
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            String photoUrl = PlusEnvironment.GetGame().GetCameraManager().GetPhotoForHabbo(Session.GetHabbo());

            if (String.IsNullOrEmpty(photoUrl))
            {
                return;
            }

            if (Session.GetHabbo().Duckets < 1)
            {
                Session.SendPacket(new RoomNotificationComposer("camera", "errors", "${catalog.alert.notenough.activitypoints.description.0}"));
                return;
            }

            string roomId    = photoUrl.Split('-')[0];
            string timestamp = photoUrl.Split('-')[1];

            int posterId = 777954881;

            Int32.TryParse(CameraUtils.Value("camera.poster.id"), out posterId);

            if (!PlusEnvironment.GetGame().GetItemManager().GetItem(posterId, out ItemData Item))
            {
                return;
            }
            if (Item == null)
            {
                return;
            }

            int photoId;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("INSERT INTO `camera_photos` (creator_id, creator_name, file_name, reports, deleted, ip_address, created_at) VALUES (@uid,@name,@fileName,@reports,@deleted,@ip_address,@created_at)");
                dbClient.AddParameter("uid", Session.GetHabbo().Id);
                dbClient.AddParameter("name", Session.GetHabbo().Username);
                dbClient.AddParameter("fileName", photoUrl);
                dbClient.AddParameter("reports", 0);
                dbClient.AddParameter("deleted", "0");
                dbClient.AddParameter("ip_address", Session.GetConnection().GetIp());
                dbClient.AddParameter("created_at", timestamp);
                photoId = Convert.ToInt32(dbClient.InsertQuery());
            }

            Item photoPoster = ItemFactory.CreateSingleItemNullable(Item, Session.GetHabbo(), "{\"w\":\"" + StringCharFilter.EscapeJSONString(photoUrl) + "\", \"n\":\"" + StringCharFilter.EscapeJSONString(Session.GetHabbo().Username) + "\", \"s\":\"" + Session.GetHabbo().Id + "\", \"u\":\"" + photoId + "\", \"t\":\"" + timestamp + "\"}", "");

            if (photoPoster != null)
            {
                Session.GetHabbo().GetInventoryComponent().TryAddItem(photoPoster);

                Session.SendPacket(new FurniListAddComposer(photoPoster));
                Session.SendPacket(new FurniListUpdateComposer());
                Session.SendPacket(new FurniListNotificationComposer(photoPoster.Id, 1));
                Session.GetHabbo().Duckets--;
                Session.SendPacket(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, -1));

                PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_CameraPhotoCount", 1);
            }

            Session.SendPacket(new CameraPurchaseSuccesfullComposer());

            Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
        }