Plus R2 ~ Catalog Deal Bundles

Joe

Well-Known Member
Jun 10, 2012
4,089
1,918
Hi,

I've setup bundles on Plus Emulator R2 by Sledmore. They work fine, you can buy them and the room loads, as soon as you try to walk, there's an error. When I leave and re-enter the room it works fine.

You must be registered for see images attach


anyone else got the same problem?
 

JayC

Always Learning
Aug 8, 2013
5,494
1,398
You have to share your code, it's different than the one currently in the github.

I need to see the process of buying the room bundle, and the method that contains line 1600 on Item.cs in UserWalksOffFurni
 

Joe

Well-Known Member
Jun 10, 2012
4,089
1,918
C#:
        public void UserWalksOffFurni(RoomUser user)
        {
            if (user == null || user.GetClient() == null || user.GetClient().GetHabbo() == null)
                return;

            if (GetBaseItem().InteractionType == InteractionType.TENT || GetBaseItem().InteractionType == InteractionType.TENT_SMALL)
                GetRoom().RemoveUserFromTent(Id, user);

            GetRoom().GetWired().TriggerEvent(Wired.WiredBoxType.TriggerWalkOffFurni, user.GetClient().GetHabbo(), this);
        }
Post automatically merged:

C#:
using System;
using System.Data;
using System.Collections.Generic;

using Plus.HabboHotel.Items;
using Plus.Database.Interfaces;

namespace Plus.HabboHotel.Catalog
{
    public class CatalogDeal
    {
        public int Id { get; set; }
        public List<CatalogItem> ItemDataList { get; private set; }
        public string DisplayName { get; set; }
        public int RoomId { get; set; }

        public CatalogDeal(int Id, string Items, string DisplayName, int RoomId, ItemDataManager ItemDataManager)
        {
            this.Id = Id;
            this.DisplayName = DisplayName;
            this.RoomId = RoomId;
            this.ItemDataList = new List<CatalogItem>();

            if (RoomId != 0)
            {
                DataTable getRoomItems = null;
                Dictionary<int, int> roomItems = new Dictionary<int, int>();

                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `items`.base_item, COALESCE(`items_groups`.`group_id`, 0) AS `group_id` FROM `items` LEFT OUTER JOIN `items_groups` ON `items`.`id` = `items_groups`.`id` WHERE `items`.`room_id` = @rid;");
                    dbClient.AddParameter("rid", RoomId);
                    getRoomItems = dbClient.GetTable();
                }

                if (getRoomItems != null)
                {
                    foreach (DataRow dRow in getRoomItems.Rows)
                    {
                        int item_id = Convert.ToInt32(dRow["base_item"]);
                        if (roomItems.ContainsKey(item_id))
                            roomItems[item_id]++;
                        else
                            roomItems.Add(item_id, 1);
                    }
                }

                foreach (var roomItem in roomItems)
                    Items += roomItem.Key + "*" + roomItem.Value + ";";

                if (roomItems.Count > 0)
                    Items = Items.Remove(Items.Length - 1);
            }

            string[] SplitItems = Items.Split(';');
            foreach (string Split in SplitItems)
            {
                string[] Item = Split.Split('*');
                int ItemId = 0;
                int Amount = 0;
                if (!int.TryParse(Item[0], out ItemId) || !int.TryParse(Item[1], out Amount))
                    continue;

                ItemData Data = null;
                if (!ItemDataManager.GetItem(ItemId, out Data))
                    continue;

                ItemDataList.Add(new CatalogItem(0, ItemId, Data, string.Empty, 0, 0, 0, 0, Amount, 0, 0, false, "", "", 0));
            }
        }
    }
}
 

JayC

Always Learning
Aug 8, 2013
5,494
1,398
C#:
        public void UserWalksOffFurni(RoomUser user)
        {
            if (user == null || user.GetClient() == null || user.GetClient().GetHabbo() == null)
                return;

            if (GetBaseItem().InteractionType == InteractionType.TENT || GetBaseItem().InteractionType == InteractionType.TENT_SMALL)
                GetRoom().RemoveUserFromTent(Id, user);

            GetRoom().GetWired().TriggerEvent(Wired.WiredBoxType.TriggerWalkOffFurni, user.GetClient().GetHabbo(), this);
        }
Post automatically merged:

C#:
using System;
using System.Data;
using System.Collections.Generic;

using Plus.HabboHotel.Items;
using Plus.Database.Interfaces;

namespace Plus.HabboHotel.Catalog
{
    public class CatalogDeal
    {
        public int Id { get; set; }
        public List<CatalogItem> ItemDataList { get; private set; }
        public string DisplayName { get; set; }
        public int RoomId { get; set; }

        public CatalogDeal(int Id, string Items, string DisplayName, int RoomId, ItemDataManager ItemDataManager)
        {
            this.Id = Id;
            this.DisplayName = DisplayName;
            this.RoomId = RoomId;
            this.ItemDataList = new List<CatalogItem>();

            if (RoomId != 0)
            {
                DataTable getRoomItems = null;
                Dictionary<int, int> roomItems = new Dictionary<int, int>();

                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `items`.base_item, COALESCE(`items_groups`.`group_id`, 0) AS `group_id` FROM `items` LEFT OUTER JOIN `items_groups` ON `items`.`id` = `items_groups`.`id` WHERE `items`.`room_id` = @rid;");
                    dbClient.AddParameter("rid", RoomId);
                    getRoomItems = dbClient.GetTable();
                }

                if (getRoomItems != null)
                {
                    foreach (DataRow dRow in getRoomItems.Rows)
                    {
                        int item_id = Convert.ToInt32(dRow["base_item"]);
                        if (roomItems.ContainsKey(item_id))
                            roomItems[item_id]++;
                        else
                            roomItems.Add(item_id, 1);
                    }
                }

                foreach (var roomItem in roomItems)
                    Items += roomItem.Key + "*" + roomItem.Value + ";";

                if (roomItems.Count > 0)
                    Items = Items.Remove(Items.Length - 1);
            }

            string[] SplitItems = Items.Split(';');
            foreach (string Split in SplitItems)
            {
                string[] Item = Split.Split('*');
                int ItemId = 0;
                int Amount = 0;
                if (!int.TryParse(Item[0], out ItemId) || !int.TryParse(Item[1], out Amount))
                    continue;

                ItemData Data = null;
                if (!ItemDataManager.GetItem(ItemId, out Data))
                    continue;

                ItemDataList.Add(new CatalogItem(0, ItemId, Data, string.Empty, 0, 0, 0, 0, Amount, 0, 0, false, "", "", 0));
            }
        }
    }
}
Which line is 1600 in the method, and I don't see the function where it generates the room for the user
 

Joe

Well-Known Member
Jun 10, 2012
4,089
1,918
Which line is 1600 in the method, and I don't see the function where it generates the room for the user
Code:
            GetRoom().GetWired().TriggerEvent(Wired.WiredBoxType.TriggerWalkOffFurni, user.GetClient().GetHabbo(), this);
This is line 1600. I'll get the other info now.
 

JayC

Always Learning
Aug 8, 2013
5,494
1,398
Code:
            GetRoom().GetWired().TriggerEvent(Wired.WiredBoxType.TriggerWalkOffFurni, user.GetClient().GetHabbo(), this);
This is line 1600. I'll get the other info now.
Run the emulator from the debugger, and put a breakpoint on that line. Buy the deal, and see what is null.... It's either the room, or the habbo.
Post automatically merged:

 

Users who are viewing this thread

Top