[HELP] Diamond Exchange

NickZeGamerX

Member
Apr 2, 2016
79
9
Hello, I am so noob with this ;[
So I have been gathering information about how to add diamond exchange;
So I got this one code from this source:
And the problem is, it isn't letting me convert the diamond exchange furnis to diamond but It converts to credits instead!
SO this is my code:
CreditFurniRedeemEvent.cs

Code:
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;


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


if (!Room.CheckRights(Session, true))
    return;


if (PlusEnvironment.GetDBConfig().DBData["exchange_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.GetBaseItem().ItemName.StartsWith("CF_") && !Exchange.GetBaseItem().ItemName.StartsWith("CFC_") || !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
        default:
        {
            Session.GetHabbo().Credits += Value;
            Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits));
            
            break;
        }
        case "DFD": // Updates a users diamonds instead of credits.
        {
            Session.GetHabbo().Diamonds += Value;
            Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5));
            
            break;
        }
    }
}


using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
    dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + Exchange.Id + "' LIMIT 1");
}


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

        }
    }
}

ItemUtility.cs

Code:
using Plus.HabboHotel.Items;
using Plus.HabboHotel.Items.Utilities;
 
using Plus.HabboHotel.Items;

namespace Plus.HabboHotel.Catalog.Utilities
{
    public static class ItemUtility    {
        public static bool CanGiftItem(CatalogItem Item)
        {
            if (!Item.Data.AllowGift || Item.IsLimited || Item.Amount > 1 || Item.Data.ItemName.ToLower().StartsWith("cf_") || Item.Data.ItemName.ToLower().StartsWith("cfc_") || Item.Data.ItemName.ToLower().StartsWith("dfd_") ||
                Item.Data.InteractionType == InteractionType.BADGE || (Item.Data.Type != 's' && Item.Data.Type != 'i') || Item.CostDiamonds > 0 ||
                Item.Data.InteractionType == InteractionType.TELEPORT || Item.Data.InteractionType == InteractionType.DEAL)
                return false;


            if (Item.Data.IsRare)
                return false;


            if (PetUtility.IsPet(Item.Data.InteractionType))
                return false;
            return true;
        }


        public static bool CanSelectAmount(CatalogItem Item)
        {
            if (Item.IsLimited || Item.Amount > 1 || Item.Data.ItemName.ToLower().StartsWith("cf_") || Item.Data.ItemName.ToLower().StartsWith("cfc_") || Item.Data.ItemName.ToLower().StartsWith("dfd_") || !Item.HaveOffer || Item.Data.InteractionType == InteractionType.BADGE || Item.Data.InteractionType == InteractionType.DEAL)
                return false;
            return true;
        }

        public static int GetSaddleId(int Saddle)
        {
            switch (Saddle)
            {
                default:
                case 9:
                    return 4221;
                case 10:
                    return 4450;
            }
        }

        public static bool IsRare(Item Item)
        {
            if (Item.LimitedNo > 0)
                return true;

            if (Item.Data.IsRare)
                return true;

            return false;
        }
    }
}

So, the point is; idk what I did wrong or I am even doing it right :< Forgive me for being so noob about this
 

Joe

Well-Known Member
Jun 10, 2012
4,090
1,918
Does the item name begin with dfd?
Code:
case "DFD": // Updates a users diamonds instead of credits.
        {
            Session.GetHabbo().Diamonds += Value;
            Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5));
            
            break;
        }
 

NickZeGamerX

Member
Apr 2, 2016
79
9
Does the item name begin with dfd?
Code:
case "DFD": // Updates a users diamonds instead of credits.
        {
            Session.GetHabbo().Diamonds += Value;
            Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5));
           
            break;
        }
no, it starts with DF.
Is that a problem?
 

Karel

Member
May 15, 2019
80
13
The code returns when the items does not start with "CF_", "CFC_" or "DFD_". So in your case the item's name starts with "DF_" so it will not continue in the code. You'll have to add the the name "DF_" to the if statement here:
Code:
if (!Exchange.GetBaseItem().ItemName.StartsWith("CF_") && !Exchange.GetBaseItem().ItemName.StartsWith("CFC_") || !Exchange.GetBaseItem().ItemName.StartsWith("DFD_"))
    return;
I've done it for you so you can replace that line with this code:
Code:
if (!Exchange.GetBaseItem().ItemName.StartsWith("CF_") || !Exchange.GetBaseItem().ItemName.StartsWith("CFC_") || !Exchange.GetBaseItem().ItemName.StartsWith("DFD_") || !Exchange.GetBaseItem().ItemName.StartsWith("DF_"))
    return;

Edit:
Oh wait I didn't read the problem well

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

This code sees what currency it has to give to the user. You're furni starts with "DF" and is not an option in the switch and so it will execute the default option. Here is the switch that will probably work correctly:
Code:
switch(Split[0]){ // Checks what type of exchange furni we're dealing with
        default:
        {
            Session.GetHabbo().Credits += Value;
            Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits));
            
            break;
        }
        case "DF": // Updates a users diamonds instead of credits.
        {
            Session.GetHabbo().Diamonds += Value;
            Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5));
            
            break;
        }
    }
(I changed the "DFD" to "DF")
 
Last edited:

Joe

Well-Known Member
Jun 10, 2012
4,090
1,918
The code returns when the items does not start with "CF_", "CFC_" or "DFD_". So in your case the item's name starts with "DF_" so it will not continue in the code. You'll have to add the the name "DF_" to the if statement here:
Code:
if (!Exchange.GetBaseItem().ItemName.StartsWith("CF_") && !Exchange.GetBaseItem().ItemName.StartsWith("CFC_") || !Exchange.GetBaseItem().ItemName.StartsWith("DFD_"))
    return;
I've done it for you so you can replace that line with this code:
Code:
if (!Exchange.GetBaseItem().ItemName.StartsWith("CF_") || !Exchange.GetBaseItem().ItemName.StartsWith("CFC_") || !Exchange.GetBaseItem().ItemName.StartsWith("DFD_") || !Exchange.GetBaseItem().ItemName.StartsWith("DF_"))
    return;

Edit:
Oh wait I didn't read the problem well

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

This code sees what currency it has to give to the user. You're furni starts with "DF" and is not an option in the switch and so it will execute the default option. Here is the switch that will probably work correctly:
Code:
switch(Split[0]){ // Checks what type of exchange furni we're dealing with
        default:
        {
            Session.GetHabbo().Credits += Value;
            Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits));
           
            break;
        }
        case "DF": // Updates a users diamonds instead of credits.
        {
            Session.GetHabbo().Diamonds += Value;
            Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5));
           
            break;
        }
    }
(I changed the "DFD" to "DF")
If my solution didn't work (can't see why it wouldn't as you've just changed DF_ to DFD_ and he's changed DFD_ to DF_) then this should :p
 

NickZeGamerX

Member
Apr 2, 2016
79
9
Did you restart your emulator or use the command ":update items" to reload the hotel's items?
Restart.
Post automatically merged:

The code returns when the items does not start with "CF_", "CFC_" or "DFD_". So in your case the item's name starts with "DF_" so it will not continue in the code. You'll have to add the the name "DF_" to the if statement here:
Code:
if (!Exchange.GetBaseItem().ItemName.StartsWith("CF_") && !Exchange.GetBaseItem().ItemName.StartsWith("CFC_") || !Exchange.GetBaseItem().ItemName.StartsWith("DFD_"))
    return;
I've done it for you so you can replace that line with this code:
Code:
if (!Exchange.GetBaseItem().ItemName.StartsWith("CF_") || !Exchange.GetBaseItem().ItemName.StartsWith("CFC_") || !Exchange.GetBaseItem().ItemName.StartsWith("DFD_") || !Exchange.GetBaseItem().ItemName.StartsWith("DF_"))
    return;

Edit:
Oh wait I didn't read the problem well

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

This code sees what currency it has to give to the user. You're furni starts with "DF" and is not an option in the switch and so it will execute the default option. Here is the switch that will probably work correctly:
Code:
switch(Split[0]){ // Checks what type of exchange furni we're dealing with
        default:
        {
            Session.GetHabbo().Credits += Value;
            Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits));
           
            break;
        }
        case "DF": // Updates a users diamonds instead of credits.
        {
            Session.GetHabbo().Diamonds += Value;
            Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5));
           
            break;
        }
    }
(I changed the "DFD" to "DF")
Did this but never worked D:
 

Users who are viewing this thread

Top