[PlusEmu] [Help] Converting to diamonds not working

BizarreDio

New Member
Mar 17, 2018
26
2
After using to figure out how to add diamond exchange, Items that start with "DF" in my furniture database convert to the price of diamonds but give credits instead. E.g. a exchange furni worth 1 diamond, when converted, gives 1 credit.

Here is my CreditFurniRedeemEvent.cs
PHP:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.Items;
using Plus.Communication.Packets.Outgoing.Inventory.Purse;
using Plus.Communication.Packets.Outgoing.Inventory.Furni;

using Plus.Database.Interfaces;


namespace Plus.Communication.Packets.Incoming.Rooms.Furni
{
    class CreditFurniRedeemEvent : IPacketEvent
    {
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
                return;

            Room Room = null;
            if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
                return;

            if (!Room.CheckRights(Session, true))
                return;
           
            if (PlusEnvironment.GetSettingsManager().TryGetValue("room.item.exchangeables.enabled") != "1")
            {
                Session.SendNotification("The hotel managers have temporarilly disabled exchanging!");
                return;
            }

            Item Exchange = Room.GetRoomItemHandler().GetItem(Packet.PopInt());
            if (Exchange == null)
                return;

            if (Exchange.Data.InteractionType != InteractionType.EXCHANGE)
                return;

            int Value = Exchange.Data.BehaviourData;
           
            if (!Exchange.GetBaseItem().ItemName.StartsWith("CF_") && !Exchange.GetBaseItem().ItemName.StartsWith("CFC_") && !Exchange.GetBaseItem().ItemName.StartsWith("DF_") && !Exchange.GetBaseItem().ItemName.StartsWith("DFD_"))
                return;
           
            string[] Split = Exchange.GetBaseItem().ItemName.Split('_');
            int Value = int.Parse(Split[1]);

            if (Value > 0)
            {
                switch (Split[0])
                { // Checks what type of exchange furni we're dealing with
                    case "DFD": // Updates a users diamonds instead of credits.
                        {
                            Session.GetHabbo().Diamonds += Value;
                            Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5));

                            break;
                        }
                    default:
                        {
                            Session.GetHabbo().Credits += Value;
                            Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits));

                            break;
                        }
                }
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @exchangeId LIMIT 1");
                dbClient.AddParameter("exchangeId", Exchange.Id);
                dbClient.RunQuery();
            }

            Session.SendPacket(new FurniListUpdateComposer());
            Room.GetRoomItemHandler().RemoveFurniture(null, Exchange.Id, false);
            Session.GetHabbo().GetInventoryComponent().RemoveItem(Exchange.Id);

        }
    }
}

Any clue how to fix?
 

BizarreDio

New Member
Mar 17, 2018
26
2
Should work fine. Did for me.

Copy the code in the second post (assuming you use R1).
My emulator's build is 3.4.x.x and I'm on R63B, have no clue if thats R1 or not.
 
Tried changing the default switch to give diamonds, still giving me credits. Could this be an issue with the emulator? Do I need to compile it or just edit the C# files that are part of the solution?
 
Bump.
 
Bump again.
 

cammy

Member
May 15, 2014
481
238
Close the emu, make the code changes and debug it. It'll then open a debugging emu if the code works. Then you can close that emu and load the normal one.
 

Users who are viewing this thread

Top