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:
Here's the packet headers I have in my Communication > Packets:
Here's the code I have for marketplace in my EMU:
MarketOffer.cs
MarketplaceManager.cs
& 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!
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:
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!