[FluxEmu] How to fix items owner

Kashi

Member
Jun 1, 2014
62
2
Hello, I have a problem regarding current item owner, how do I change it so it appears to belong to the user saying the command.

:sleepingbag command was used by me (Ali) , and another user's name appear (Jerry).

You must be registered for see images attach


I tried to check in RoleplayManager.cs and cannot find way for it, and recalling the command again resulting the same. Hope I can find help for this.
 

Kashi

Member
Jun 1, 2014
62
2
HI. You can share the code where you use this command?

C++:
               #region :sleepingbag
                case "sleepingbag":
                    {
                        if (Session == null)
                            return true;

                        if (!Session.GetRoleplay().MultiCoolDown.ContainsKey("bag_cooldown"))
                        {
                            Session.GetRoleplay().MultiCoolDown.Add("bag_cooldown", 0);
                        }
                        if (Session.GetRoleplay().MultiCoolDown["bag_cooldown"] > 0)
                        {
                            Session.SendWhisper("Cooldown [" + Session.GetRoleplay().MultiCoolDown["bag_cooldown"] + "/20]");
                            return true;
                        }

                        UserItem BagInv = Session.GetHabbo().GetInventoryComponent().GetBag();

                        if (BagInv != null)
                        {
                            RoomUser Me = Session.GetHabbo().GetRoomUser();

                            if (Me == null)
                                return true;

                            if (Session.GetRoleplay().Bag == null)
                            {
                                if (Me.IsWalking)
                                {
                                    Session.SendWhisper("slow down cowboy");
                                    Me.IsWalking = false;
                                    Me.ClearMovement();
                                }

                                Session.GetRoleplay().Bag = RoleplayManager.PlaceItemToRoomReturn(BagInv.BaseItemId, Me.X, Me.Y, Me.Z, 0, false, Session.GetHabbo().CurrentRoomId, false);
                                Me.AddStatus("lay", TextHandling.GetString(Session.GetRoleplay().Bag.GetBaseItem().Height));
                                Me.Z = Session.GetRoleplay().Bag.Z;
                                Me.RotBody = Session.GetRoleplay().Bag.Rot;

                                Me.CanWalk = false;

                                Session.SendWhisper("You will gain a random amount of energy every 20 seconds whilst in your sleeping bag!");

                                TimerCallback TCB = new TimerCallback(Session.GetRoleplay().BagTimerDone);

                                Session.GetRoleplay().BagTimer = new Timer(TCB, null, 20000, Timeout.Infinite);
                                Session.Shout("*Pulls out their sleeping bag*");

                            }
                            else
                            {
                                RoleplayManager.PickRock(Session.GetRoleplay().Bag, Session.GetRoleplay().Bag.RoomId);
                                Me.RemoveStatus("lay");
                                Session.GetRoleplay().Bag = null;
                                Session.Shout("*Puts back their sleeping bag*");
                                Session.GetRoleplay().MultiCoolDown["bag_cooldown"] = 20;
                                Session.GetRoleplay().CheckingMultiCooldown = true;

                                Me.CanWalk = true;
                            }

                            Me.UpdateNeeded = true;

                        }

                        return true;
                    }
                #endregion

Here's the region for :sleepingbag in ChatCommandHandler.cs
 

Pollak

Active Member
Oct 12, 2017
161
51
C++:
               #region :sleepingbag
                case "sleepingbag":
                    {
                        if (Session == null)
                            return true;

                        if (!Session.GetRoleplay().MultiCoolDown.ContainsKey("bag_cooldown"))
                        {
                            Session.GetRoleplay().MultiCoolDown.Add("bag_cooldown", 0);
                        }
                        if (Session.GetRoleplay().MultiCoolDown["bag_cooldown"] > 0)
                        {
                            Session.SendWhisper("Cooldown [" + Session.GetRoleplay().MultiCoolDown["bag_cooldown"] + "/20]");
                            return true;
                        }

                        UserItem BagInv = Session.GetHabbo().GetInventoryComponent().GetBag();

                        if (BagInv != null)
                        {
                            RoomUser Me = Session.GetHabbo().GetRoomUser();

                            if (Me == null)
                                return true;

                            if (Session.GetRoleplay().Bag == null)
                            {
                                if (Me.IsWalking)
                                {
                                    Session.SendWhisper("slow down cowboy");
                                    Me.IsWalking = false;
                                    Me.ClearMovement();
                                }

                                Session.GetRoleplay().Bag = RoleplayManager.PlaceItemToRoomReturn(BagInv.BaseItemId, Me.X, Me.Y, Me.Z, 0, false, Session.GetHabbo().CurrentRoomId, false);
                                Me.AddStatus("lay", TextHandling.GetString(Session.GetRoleplay().Bag.GetBaseItem().Height));
                                Me.Z = Session.GetRoleplay().Bag.Z;
                                Me.RotBody = Session.GetRoleplay().Bag.Rot;

                                Me.CanWalk = false;

                                Session.SendWhisper("You will gain a random amount of energy every 20 seconds whilst in your sleeping bag!");

                                TimerCallback TCB = new TimerCallback(Session.GetRoleplay().BagTimerDone);

                                Session.GetRoleplay().BagTimer = new Timer(TCB, null, 20000, Timeout.Infinite);
                                Session.Shout("*Pulls out their sleeping bag*");

                            }
                            else
                            {
                                RoleplayManager.PickRock(Session.GetRoleplay().Bag, Session.GetRoleplay().Bag.RoomId);
                                Me.RemoveStatus("lay");
                                Session.GetRoleplay().Bag = null;
                                Session.Shout("*Puts back their sleeping bag*");
                                Session.GetRoleplay().MultiCoolDown["bag_cooldown"] = 20;
                                Session.GetRoleplay().CheckingMultiCooldown = true;

                                Me.CanWalk = true;
                            }

                            Me.UpdateNeeded = true;

                        }

                        return true;
                    }
                #endregion

Here's the region for :sleepingbag in ChatCommandHandler.cs
Right and you can show the function PlaceItemToRoomReturn in RoleplayManager.cs? Probably the user id there are wrong.
 

Kashi

Member
Jun 1, 2014
62
2
Right and you can show the function PlaceItemToRoomReturn in RoleplayManager.cs? Probably the user id there are wrong.

C++:
       public static RoomItem PlaceItemToRoomReturn(uint BaseId, int X, int Y, double Z, int Rot, bool FromInventory, uint roomid, bool ToDB = true)
        {

            using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
            {
                Room Room = GenerateRoom(roomid);
                int ItDemId = 0;
                uint ItemId = 0;

                if (ToDB)
                {
                    dbClient.SetQuery("INSERT INTO items_rooms (user_id,base_item) VALUES (1, " + BaseId + ")");
                    dbClient.RunQuery();
                    dbClient.SetQuery("SELECT id FROM items_rooms WHERE user_id = '1' AND room_id = 0 AND base_item = '" + BaseId + "' ORDER BY id DESC LIMIT 1");
                    ItDemId = dbClient.GetInteger();
                   ItemId = Convert.ToUInt32(ItDemId);
                }
                else
                {
                    dbClient.SetQuery("SELECT id FROM items_rooms WHERE user_id = '1' AND room_id = 0 ORDER BY id DESC LIMIT 1");
                    ItDemId = dbClient.GetInteger();
                    ItemId = Convert.ToUInt32(ItDemId) + 1;
                }
                

                RoomItem RoomItem = new RoomItem(ItemId, Room.RoomId, BaseId, "", X, Y, Z, Rot, Room, Convert.ToUInt32(Room.RoomData.OwnerId), 0, 3537, "", false);


                Room.GetRoomItemHandler().SetRockItem(RoomItem, X, Y, Rot, true, false, true, false, false);

                return RoomItem;
            }

        }

Here was the snippet for PlaceItemToRoom found in RoleplayManager.cs
 

Pollak

Active Member
Oct 12, 2017
161
51
C++:
       public static RoomItem PlaceItemToRoomReturn(uint BaseId, int X, int Y, double Z, int Rot, bool FromInventory, uint roomid, bool ToDB = true)
        {

            using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
            {
                Room Room = GenerateRoom(roomid);
                int ItDemId = 0;
                uint ItemId = 0;

                if (ToDB)
                {
                    dbClient.SetQuery("INSERT INTO items_rooms (user_id,base_item) VALUES (1, " + BaseId + ")");
                    dbClient.RunQuery();
                    dbClient.SetQuery("SELECT id FROM items_rooms WHERE user_id = '1' AND room_id = 0 AND base_item = '" + BaseId + "' ORDER BY id DESC LIMIT 1");
                    ItDemId = dbClient.GetInteger();
                   ItemId = Convert.ToUInt32(ItDemId);
                }
                else
                {
                    dbClient.SetQuery("SELECT id FROM items_rooms WHERE user_id = '1' AND room_id = 0 ORDER BY id DESC LIMIT 1");
                    ItDemId = dbClient.GetInteger();
                    ItemId = Convert.ToUInt32(ItDemId) + 1;
                }
              

                RoomItem RoomItem = new RoomItem(ItemId, Room.RoomId, BaseId, "", X, Y, Z, Rot, Room, Convert.ToUInt32(Room.RoomData.OwnerId), 0, 3537, "", false);


                Room.GetRoomItemHandler().SetRockItem(RoomItem, X, Y, Rot, true, false, true, false, false);

                return RoomItem;
            }

        }

Here was the snippet for PlaceItemToRoom found in RoleplayManager.cs
Well when insert in table items_rooms the user_id is 1 and in other tabeles
 
Last edited:

Users who are viewing this thread

Top