[PlusEMU] Trouble With Marketplace

treebeard

Member
Jan 16, 2018
317
173
Hello everyone,

I've recently been trying to get the marketplace working in my Plus emulator R2.
When trying to add a new furni offer to the marketplace I get this error immediately:

U1irhWk.png


Here's the packet headers I have in my Communication > Packets:
Code:
Client Packet Header
--------------------
public const int GetMarketplaceCanMakeOfferMessageEvent = 1552;//1647
public const int GetMarketplaceItemStatsMessageEvent = 1561;//1203
public const int GetMarketplaceConfigurationMessageEvent = 2811;//1604

Server Packet Header
--------------------
public const int MarketplaceCanMakeOfferResultMessageComposer = 2452;//1874
public const int MarketplaceConfigurationMessageComposer = 1817;//3702
public const int MarketplaceItemStatsMessageComposer = 480;//2909
public const int MarketPlaceOwnOffersMessageComposer = 1892;//2806
public const int MarketPlaceOffersMessageComposer = 291;//2985
public const int MarketplaceMakeOfferResultMessageComposer = 480;//3960
public const int MarketplaceCancelOfferResultMessageComposer = 1892;//202

Here's the code I have for marketplace in my EMU:
MarketOffer.cs
Code:
namespace Plus.HabboHotel.Catalog.Marketplace
{
    public class MarketOffer
    {
        public int OfferID { get; set; }
        public int ItemType { get; set; }
        public int SpriteId { get; set; }
        public int TotalPrice { get; set; }
        public int LimitedNumber { get; set; }
        public int LimitedStack { get; set; }

        public MarketOffer(int OfferID, int SpriteId, int TotalPrice, int ItemType, int LimitedNumber, int LimitedStack)
        {
            this.OfferID = OfferID;
            this.SpriteId = SpriteId;
            this.ItemType = ItemType;
            this.TotalPrice = TotalPrice;
            this.LimitedNumber = LimitedNumber;
            this.LimitedStack = LimitedStack;
        }
    }
}

MarketplaceManager.cs
Code:
using System;
using System.Collections.Generic;

using Plus.Database.Interfaces;

namespace Plus.HabboHotel.Catalog.Marketplace
{
    public class MarketplaceManager
    {
        public List<int> MarketItemKeys = new List<int>();
        public List<MarketOffer> MarketItems = new List<MarketOffer>();
        public Dictionary<int, int> MarketCounts = new Dictionary<int, int>();
        public Dictionary<int, int> MarketAverages = new Dictionary<int, int>();

        public MarketplaceManager()
        {

        }

        public int AvgPriceForSprite(int SpriteID)
        {
            int num = 0;
            int num2 = 0;
            if (this.MarketAverages.ContainsKey(SpriteID) && this.MarketCounts.ContainsKey(SpriteID))
            {
                if (this.MarketCounts[SpriteID] > 0)
                {
                    return (this.MarketAverages[SpriteID] / this.MarketCounts[SpriteID]);
                }
                return 0;
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `avgprice` FROM `catalog_marketplace_data` WHERE `sprite` = '" + SpriteID + "' LIMIT 1");
                num = dbClient.GetInteger();

                dbClient.SetQuery("SELECT `sold` FROM `catalog_marketplace_data` WHERE `sprite` = '" + SpriteID + "' LIMIT 1");
                num2 = dbClient.GetInteger();
            }

            this.MarketAverages.Add(SpriteID, num);
            this.MarketCounts.Add(SpriteID, num2);

            if (num2 > 0)
                return Convert.ToInt32(Math.Ceiling((double)(num / num2)));
            
            return 0;
        }

        public string FormatTimestampString()
        {
            return this.FormatTimestamp().ToString().Split(new char[] { ',' })[0];
        }

        public double FormatTimestamp()
        {
            return (PlusEnvironment.GetUnixTimestamp() - 172800.0);
        }

        public int OfferCountForSprite(int SpriteID)
        {
            Dictionary<int, MarketOffer> dictionary = new Dictionary<int, MarketOffer>();
            Dictionary<int, int> dictionary2 = new Dictionary<int, int>();
            foreach (MarketOffer item in this.MarketItems)
            {
                if (dictionary.ContainsKey(item.SpriteId))
                {
                    if (dictionary[item.SpriteId].TotalPrice > item.TotalPrice)
                    {
                        dictionary.Remove(item.SpriteId);
                        dictionary.Add(item.SpriteId, item);
                    }

                    int num = dictionary2[item.SpriteId];
                    dictionary2.Remove(item.SpriteId);
                    dictionary2.Add(item.SpriteId, num + 1);
                }
                else
                {
                    dictionary.Add(item.SpriteId, item);
                    dictionary2.Add(item.SpriteId, 1);
                }
            }
            if (dictionary2.ContainsKey(SpriteID))
            {
                return dictionary2[SpriteID];
            }
            return 0;
        }

        public int CalculateComissionPrice(float SellingPrice)
        {
            return Convert.ToInt32(Math.Ceiling(SellingPrice / 100 * 1));
        }
    }
}

& I'm using PRODUCTION-201701242205-837386173

If there's any other information that can better equip you to assist me, feel free to let me know.
As always, I appreciate the time, energy, and effort that goes into all feedback. Thanks!
 

Damien

Don't need glasses if you can C#
Feb 26, 2012
434
647
You've not posted all your marketplace headers (only some of them). I'm guessing your MakeOfferMessageEvent is wrong as it's dishing out an error telling you the item doesn't exist, or your price is set to high, or too low, as defined in the Emu. The ugly alert message is you just not having the appropriate external text set up for it.
 
That error is defined In your external variables. No idea what it means but that's where you set it up

Maybe marketplace disabled?
Nothing to do with variables.
 

treebeard

Member
Jan 16, 2018
317
173
You've not posted all your marketplace headers (only some of them). I'm guessing your MakeOfferMessageEvent is wrong as it's dishing out an error telling you the item doesn't exist, or your price is set to high, or too low, as defined in the Emu. The ugly alert message is you just not having the appropriate external text set up for it.
 

Nothing to do with variables.
Sorry, I thought that I got all of them.
I'll check it out but I could have sworn I had min set to 1c and max at 99999999c.

That error is defined In your external variables. No idea what it means but that's where you set it up

Maybe marketplace disabled?

I just checked in external_variable and external_override_variables and there are no entries in there pertaining to the marketplace :/
 

JayC

Always Learning
Aug 8, 2013
5,505
1,401
You've not posted all your marketplace headers (only some of them). I'm guessing your MakeOfferMessageEvent is wrong as it's dishing out an error telling you the item doesn't exist, or your price is set to high, or too low, as defined in the Emu. The ugly alert message is you just not having the appropriate external text set up for it.
 

Nothing to do with variables.
Sorry, I thought that I got all of them.
I'll check it out but I could have sworn I had min set to 1c and max at 99999999c.



I just checked in external_variable and external_override_variables and there are no entries in there pertaining to the marketplace :/
You both misread my answer... Please review!!!
inventory.marketplace.result.0=MarketPlace Error!

That is what I was meaning when I said the error was defined in your marketplace. :) I suggested that your server settings may have your marketplace disabled.
 

treebeard

Member
Jan 16, 2018
317
173
Post them, and post the contents of MakeOfferEvent.cs
Just got home from Uni, give me 5 mins.


You both misread my answer... Please review!!!
inventory.marketplace.result.0=MarketPlace Error!

That is what I was meaning when I said the error was defined in your marketplace. :) I suggested that your server settings may have your marketplace disabled.

Ahh sorry, now I understand what you meant! Let me get to my actual computer and I'll take a look!

Thank you both for your assistance!
 

Damien

Don't need glasses if you can C#
Feb 26, 2012
434
647
You both misread my answer... Please review!!!
inventory.marketplace.result.0=MarketPlace Error!

That is what I was meaning when I said the error was defined in your marketplace. :) I suggested that your server settings may have your marketplace disabled.
That alert is handled in the MakeOfferEvent file. Which for me get fired during these checks (highlighted, 0 being the identifier for that error).
 

treebeard

Member
Jan 16, 2018
317
173
That alert is handled in the MakeOfferEvent file. Which for me get fired during these checks (highlighted, 0 being the identifier for that error).

Here is my MarkeOfferEvent.cs
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.HabboHotel.Items;
using Plus.HabboHotel.Catalog.Utilities;
using Plus.Communication.Packets.Outgoing.Marketplace;
using Plus.Database.Interfaces;


namespace Plus.Communication.Packets.Incoming.Marketplace
{
    class MakeOfferEvent : IPacketEvent
    {
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            int SellingPrice = Packet.PopInt();
            int ComissionPrice = Packet.PopInt();
            int ItemId = Packet.PopInt();

            Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);
            if (Item == null)
            {
                Session.SendPacket(new MarketplaceMakeOfferResultComposer(0));
                return;
            }

            if (!ItemUtility.IsRare(Item))
            {
                Session.SendNotification("Sorry, only Rares & LTDs can go be auctioned off in the Marketplace!");
                return;
            }

            if (SellingPrice > 70000000 || SellingPrice == 0)
            {
                Session.SendPacket(new MarketplaceMakeOfferResultComposer(0));
                return;
            }

            int Comission = PlusEnvironment.GetGame().GetCatalog().GetMarketplace().CalculateComissionPrice((float)SellingPrice);
            int TotalPrice = SellingPrice + Comission;
            int ItemType = 1;
            if (Item.GetBaseItem().Type == 'i')
                ItemType++;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("INSERT INTO `catalog_marketplace_offers` (`furni_id`,`item_id`,`user_id`,`asking_price`,`total_price`,`public_name`,`sprite_id`,`item_type`,`timestamp`,`extra_data`,`limited_number`,`limited_stack`) VALUES ('" + ItemId + "','" + Item.BaseItem + "','" + Session.GetHabbo().Id + "','" + SellingPrice + "','" + TotalPrice + "',@public_name,'" + Item.GetBaseItem().SpriteId + "','" + ItemType + "','" + PlusEnvironment.GetUnixTimestamp() + "',@extra_data, '" + Item.LimitedNo + "', '" + Item.LimitedTot + "')");
                dbClient.AddParameter("public_name", Item.GetBaseItem().PublicName);
                dbClient.AddParameter("extra_data", Item.ExtraData);
                dbClient.RunQuery();

                dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + ItemId + "' AND `user_id` = '" + Session.GetHabbo().Id + "' LIMIT 1");
            }

            Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);
            Session.SendPacket(new MarketplaceMakeOfferResultComposer(1));
        }
    }
}

Also these are the only packet headers I'm seeing in the respective locations
Code:
Client Packet Headers
---------------------
public const int GetMarketplaceItemStatsMessageEvent = 1561;//1203
public const int GetMarketplaceConfigurationMessageEvent = 2811;//1604
public const int GetMarketplaceCanMakeOfferMessageEvent = 1552;//1647

Server Packet Headers
---------------------
public const int MarketplaceCanMakeOfferResultMessageComposer = 2452;//1874
public const int MarketplaceConfigurationMessageComposer = 1817;//3702
public const int MarketplaceItemStatsMessageComposer = 480;//2909
public const int MarketPlaceOwnOffersMessageComposer = 1892;//2806
public const int MarketPlaceOffersMessageComposer = 291;//2985
public const int MarketplaceMakeOfferResultMessageComposer = 480;//3960
public const int MarketplaceCancelOfferResultMessageComposer = 1892;//202
 

Damien

Don't need glasses if you can C#
Feb 26, 2012
434
647
You should have one named "MakeOfferMessageEvent".
 
Code:
if (SellingPrice > 70000000 || SellingPrice == 0)
That's also an exploit, I could come on your hotel and give myself millions of credits by selling items for negative values.
Should be:
Code:
if (SellingPrice > 70000000 || SellingPrice <= 0)
 

treebeard

Member
Jan 16, 2018
317
173
You should have one named "MakeOfferMessageEvent".
 

That's also an exploit, I could come on your hotel and give myself millions of credits by selling items for negative values.
Should be:
Code:
if (SellingPrice > 70000000 || SellingPrice <= 0)
Was searching for it wrong: public const int MakeOfferMessageEvent = 2308;//255

Yeah, I just noticed that when I opened the file. I'm still getting around to many aspects of the emulator, this is just how PlusEMU R2 came when I downloaded it.

I don't think this is helpful but the My Sales tab looks like this right now also.
Xkbs9sJ.png

 
You both misread my answer... Please review!!!
inventory.marketplace.result.0=MarketPlace Error!

That is what I was meaning when I said the error was defined in your marketplace. :) I suggested that your server settings may have your marketplace disabled.
Where is the setting to disable marketplace though? I'm not finding a line anywhere to explicitly disable it.
 

JayC

Always Learning
Aug 8, 2013
5,505
1,401
Was searching for it wrong: public const int MakeOfferMessageEvent = 2308;//255

Yeah, I just noticed that when I opened the file. I'm still getting around to many aspects of the emulator, this is just how PlusEMU R2 came when I downloaded it.

I don't think this is helpful but the My Sales tab looks like this right now also.
Xkbs9sJ.png

 

Where is the setting to disable marketplace though? I'm not finding a line anywhere to explicitly disable it.
I may be wrong, but I thought I remembered on Plus EMU you could disable and enable the marketplace? Please follow @Damien he will provide much better support with this issue. Disregard my comments
 

Damien

Don't need glasses if you can C#
Feb 26, 2012
434
647
The packets for marketplace are all wrong in Plus R2. A correct list can be found bellow: (PRODUCTION-201701242205-837386173)

Incoming:
Code:
// Marketplace
public const int GetOffersMessageEvent = 2817;
public const int GetOwnOffersMessageEvent = 904;
public const int GetMarketplaceCanMakeOfferMessageEvent = 1552;
public const int GetMarketplaceConfigurationMessageEvent = 2811;
public const int GetMarketplaceItemStatsMessageEvent = 1561;
public const int MakeOfferMessageEvent = 2308;
public const int CancelOfferMessageEvent = 100;
public const int RedeemOfferCreditsMessageEvent = 195;
public const int BuyOfferMessageEvent = 2879;


Outgoing:
Code:
// Marketplace
public const int MarketplaceCancelOfferResultMessageComposer = 1980;
public const int MarketPlaceOffersMessageComposer = 291;
public const int MarketPlaceOwnOffersMessageComposer = 1892;
public const int MarketplaceItemStatsMessageComposer = 2201;
public const int MarketplaceConfigurationMessageComposer = 1817;
public const int MarketplaceCanMakeOfferResultMessageComposer = 2452;
public const int MarketplaceMakeOfferResultMessageComposer = 480;
 

Txc

Member
Jan 26, 2017
84
45
The packets for marketplace are all wrong in Plus R2. A correct list can be found bellow: (PRODUCTION-201701242205-837386173)

Incoming:
Code:
// Marketplace
public const int GetOffersMessageEvent = 2817;
public const int GetOwnOffersMessageEvent = 904;
public const int GetMarketplaceCanMakeOfferMessageEvent = 1552;
public const int GetMarketplaceConfigurationMessageEvent = 2811;
public const int GetMarketplaceItemStatsMessageEvent = 1561;
public const int MakeOfferMessageEvent = 2308;
public const int CancelOfferMessageEvent = 100;
public const int RedeemOfferCreditsMessageEvent = 195;
public const int BuyOfferMessageEvent = 2879;


Outgoing:
Code:
// Marketplace
public const int MarketplaceCancelOfferResultMessageComposer = 1980;
public const int MarketPlaceOffersMessageComposer = 291;
public const int MarketPlaceOwnOffersMessageComposer = 1892;
public const int MarketplaceItemStatsMessageComposer = 2201;
public const int MarketplaceConfigurationMessageComposer = 1817;
public const int MarketplaceCanMakeOfferResultMessageComposer = 2452;
public const int MarketplaceMakeOfferResultMessageComposer = 480;
You happen to have the correct packets for Production 201802201205-141713395? I think my packet headers might also be wrong.
 

Users who are viewing this thread

Top