Having an issue adding Diamond exchange.

Ellu

Donator
Mar 8, 2018
42
65
Hey. I'm trying to add diamond exchange to my hotel but am seeming to have some difficulties.

I changed the files ItemUtility.cs and CreditFurniRedeemEvent.cs

- ItemUtility.cs
- CreditFurniRedeemEvent.cs

After rebuilding Plus emulator and running in debug I get the following error code while trying to redeem a diamond furni.
Code:
01:05:54 - [ERROR] Exception:
System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffe
r& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo in
fo)
   at Plus.Communication.Packets.Incoming.Rooms.Furni.CreditFurniRedeemEvent.Par
se(GameClient Session, ClientPacket Packet) in C:\Users\Administrator\Desktop\Re
lease 2\Emulator Source\Communication\Packets\Incoming\Rooms\Furni\CreditFurniRe
deemEvent.cs:line 45
   at Plus.Communication.Packets.PacketManager.TryExecutePacket(GameClient Sessi
on, ClientPacket Packet) in C:\Users\Administrator\Desktop\Release 2\Emulator So
urce\Communication\Packets\PacketManager.cs:line 154
   at Plus.HabboHotel.GameClients.GameClient.parser_onNewPacket(ClientPacket Mes
sage) in C:\Users\Administrator\Desktop\Release 2\Emulator Source\HabboHotel\Gam
eClients\GameClient.cs:line 65

Help is appreciated :)
 

treebeard

Member
Jan 16, 2018
317
173
Code:
at Plus.Communication.Packets.Incoming.Rooms.Furni.CreditFurniRedeemEvent.Parse(GameClient Session, ClientPacket Packet) in C:\Users\Administrator\Desktop\Release 2\Emulator Source\Communication\Packets\Incoming\Rooms\Furni\CreditFurniRedeemEvent.cs:line 45

at Plus.Communication.Packets.PacketManager.TryExecutePacket(GameClient Session, ClientPacket Packet) in C:\Users\Administrator\Desktop\Release 2\Emulator Source\Communication\Packets\PacketManager.cs:line 154

at Plus.HabboHotel.GameClients.GameClient.parser_onNewPacket(ClientPacket Message) in C:\Users\Administrator\Desktop\Release 2\Emulator Source\HabboHotel\Gam
eClients\GameClient.cs:line 65

Because they all are mentioning errors in the Communications directory of the emulator it seems like there's an issue with a packet there.

Could anyone more experienced give some input maybe? @Damien @JayCustom @Marko97 @JMG ???
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398


Sorry, I’m on my phone, maybe this will help.
Ok clearly you didn't read the thread or the code. The error is getting stuck on the parse. He has his switch statement and checks correct. His furniture name is probably something like DF_1000bar when it needs to have an underscore after the amount to be correctly parsed.

Please read the error, not everyone's situation is the exact same...
 

Marko97

M97 Project based Plus EMU
Aug 7, 2013
99
45
Use this CreditFurniReedemEvent.cs
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("Funzionalità momentaneamente non disponibile.");
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("DF_") && !Exchange.GetBaseItem().ItemName.StartsWith("DFD_"))
return;

int Value = Exchange.Data.BehaviourData;

if (Value > 0)
{
if (Exchange.GetBaseItem().ItemName.StartsWith("CF_") || Exchange.GetBaseItem().ItemName.StartsWith("CFC_"))
{
Session.GetHabbo().Credits += Value;
Session.SendPacket(new CreditBalanceComposer(Session.GetHabbo().Credits));
}
else if (Exchange.GetBaseItem().ItemName.StartsWith("DF_") || Exchange.GetBaseItem().ItemName.StartsWith("DFD_"))
{
Session.GetHabbo().Diamonds += Value;
Session.SendPacket(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, Value, 5));
}
}

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);

}
}
}
Next you need to add in furniture table the furnitures. For diamonds exchange the name of furni it must start DF_ of DFD_ and set interaction: exchange
 

Users who are viewing this thread

Top