예제 #1
0
        internal void RecycleItem()
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            int ItemsCount = Request.PopWiredInt32(); // 5

            for (int i = 0; i < ItemsCount; i++)
            {
                uint ItemId = Request.PopWiredUInt();

                if (!Session.GetHabbo().GetInventoryComponent().ContainsItem(ItemId))
                {
                    return;
                }

                Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId, true);
            }

            uint          newItemId;
            EcotronReward Reward = OtanixEnvironment.GetGame().GetCatalog().GetRandomEcotronReward();

            if (Reward == null)
            {
                return;
            }

            using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("INSERT INTO items (base_id) VALUES (" + EmuSettings.FURNIMATIC_BOX_ITEMID + ")");
                newItemId = (uint)dbClient.insertQuery();

                dbClient.runFastQuery("INSERT INTO items_users VALUES (" + newItemId + "," + Session.GetHabbo().Id + ")");

                dbClient.setQuery("INSERT INTO items_extradata VALUES (" + newItemId + ",@data)");
                dbClient.addParameter("data", DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day);
                dbClient.runQuery();

                dbClient.runFastQuery("INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES (" + newItemId + "," + Reward.BaseId + ",1,'')");
            }

            UserItem u = Session.GetHabbo().GetInventoryComponent().AddNewItem(newItemId, (uint)EmuSettings.FURNIMATIC_BOX_ITEMID, DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day, false, false, false, Reward.GetBaseItem().Name, Session.GetHabbo().Id, 0);

            Session.GetMessageHandler().GetResponse().Init(Outgoing.SendPurchaseAlert);
            Session.GetMessageHandler().GetResponse().AppendInt32(1); // items
            Session.GetMessageHandler().GetResponse().AppendInt32(1); // type (gift) == s
            Session.GetMessageHandler().GetResponse().AppendInt32(1);
            Session.GetMessageHandler().GetResponse().AppendUInt(u.Id);
            Session.GetMessageHandler().SendResponse();

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

            Response.Init(Outgoing.FurniMaticReceiveItem);
            Response.AppendInt32(1);
            Response.AppendUInt(newItemId);
            SendResponse();
        }
예제 #2
0
 public void Handle(GameClient Session, ClientMessage Event)
 {
     if (Session.GetHabbo().InRoom)
     {
         int num = Event.PopWiredInt32();
         if (num >= 3)
         {
             for (int i = 0; i < num; i++)
             {
                 UserItem @class = Session.GetHabbo().GetInventoryComponent().GetItemById(Event.PopWiredUInt());
                 if (@class == null || [email protected]().AllowRecycle)
                 {
                     return;
                 }
                 Session.GetHabbo().GetInventoryComponent().method_12(@class.uint_0, 0u, false);
             }
             uint          num2   = Essential.GetGame().GetCatalog().GetNextId();
             EcotronReward class2 = Essential.GetGame().GetCatalog().GetEcotronReward();
             using (DatabaseClient class3 = Essential.GetDatabase().GetClient())
             {
                 class3.ExecuteQuery(string.Concat(new object[]
                 {
                     "INSERT INTO items (Id,user_id,base_item,wall_pos) VALUES ('",
                     num2,
                     "','",
                     Session.GetHabbo().Id,
                     "','1478','')"
                 }));
                 class3.ExecuteQuery(string.Concat(new object[]
                 {
                     "INSERT INTO items_extra_data (item_id,extra_data) VALUES ('",
                     num2,
                     "','",
                     DateTime.Now.ToLongDateString(),
                     "')"
                 }));
                 class3.ExecuteQuery(string.Concat(new object[]
                 {
                     "INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES ('",
                     num2,
                     "','",
                     class2.uint_2,
                     "','1','')"
                 }));
             }
             Session.GetHabbo().GetInventoryComponent().method_9(true);
             ServerMessage Response = new ServerMessage(Outgoing.SendPurchaseAlert);
             Response.AppendInt32(1);
             Response.AppendInt32(1);
             Response.AppendInt32(1);
             Response.AppendInt32(class2.GetBaseItem().Sprite);
             Session.SendMessage(Response);
             ServerMessage Response2 = new ServerMessage(Outgoing.RecycleState);
             Response2.AppendInt32(1);
             Response2.AppendInt32(class2.GetBaseItem().Sprite);
             Session.SendMessage(Response2);
         }
     }
 }
예제 #3
0
 public void Handle(GameClient Session, ClientMessage Event)
 {
     if (Session.GetHabbo().InRoom)
     {
         int num = Event.PopWiredInt32();
         if (num == 5)
         {
             for (int i = 0; i < num; i++)
             {
                 UserItem @class = Session.GetHabbo().GetInventoryComponent().GetItemById(Event.PopWiredUInt());
                 if (@class == null || [email protected]_1().AllowRecycle)
                 {
                     return;
                 }
                 Session.GetHabbo().GetInventoryComponent().method_12(@class.uint_0, 0u, false);
             }
             uint          num2   = HabboIM.GetGame().GetCatalog().method_14();
             EcotronReward class2 = HabboIM.GetGame().GetCatalog().method_15();
             using (DatabaseClient class3 = HabboIM.GetDatabase().GetClient())
             {
                 class3.ExecuteQuery(string.Concat(new object[]
                 {
                     "INSERT INTO items (Id,user_id,base_item,wall_pos) VALUES ('",
                     num2,
                     "','",
                     Session.GetHabbo().Id,
                     "','1478','')"
                 }));
                 class3.ExecuteQuery(string.Concat(new object[]
                 {
                     "INSERT INTO items_extra_data (item_id,extra_data) VALUES ('",
                     num2,
                     "','",
                     DateTime.Now.ToLongDateString(),
                     "')"
                 }));
                 class3.ExecuteQuery(string.Concat(new object[]
                 {
                     "INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES ('",
                     num2,
                     "','",
                     class2.uint_2,
                     "','1','')"
                 }));
             }
             Session.GetHabbo().GetInventoryComponent().method_9(true);
             ServerMessage Message = new ServerMessage(508u);
             Message.AppendBoolean(true);
             Message.AppendUInt(num2);
             Session.SendMessage(Message);
         }
     }
 }
예제 #4
0
 public void parse(GameClient Session, ClientMessage Event)
 {
     if (Session.GetHabbo().InRoom)
     {
         int num = Event.PopWiredInt32();
         if (num == 5)
         {
             for (int i = 0; i < num; i++)
             {
                 UserItem item = Session.GetHabbo().GetInventoryComponent().GetItem(Event.PopWiredUInt());
                 if (item == null || !item.GetBaseItem().AllowRecycle)
                 {
                     return;
                 }
                 Session.GetHabbo().GetInventoryComponent().RemoveItem(item.Id, 0, false);
             }
             uint          Id = PhoenixEnvironment.GetGame().GetCatalog().GenerateItemId();
             EcotronReward randomEcotronReward = PhoenixEnvironment.GetGame().GetCatalog().GetRandomEcotronReward();
             using (DatabaseClient client = PhoenixEnvironment.GetDatabase().GetClient())
             {
                 client.ExecuteQuery(string.Concat(new object[]
                 {
                     "INSERT INTO items (Id,user_id,base_item,extra_data,wall_pos) VALUES ('",
                     Id,
                     "','",
                     Session.GetHabbo().Id,
                     "','1478','",
                     DateTime.Now.ToLongDateString(),
                     "', '')"
                 }));
                 client.ExecuteQuery(string.Concat(new object[]
                 {
                     "INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES ('",
                     Id,
                     "','",
                     randomEcotronReward.BaseId,
                     "','1','')"
                 }));
             }
             Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
             ServerMessage message = new ServerMessage(508);
             message.AppendBoolean(true);
             message.AppendUInt(Id);
             Session.SendMessage(message);
         }
     }
 }