Fix Your MarketPlace!

Results 1 to 10 of 10
  1. #1
    Enthusiast dimitri54480 is offline
    MemberRank
    Feb 2011 Join Date
    44Posts

    Fix Your MarketPlace!

    Hello!
    Here, there is my MarketPlace.Cs


    Go to Messages/Requests/Catalog.cs

    Find in the void
    Code:
    private void MarketplacePurchase()
            {
    This code
    Code:
    Session.GetMessageHandler().GetResponse().Init(67);
                Session.GetMessageHandler().GetResponse().AppendUInt(Item.ItemId);
                Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Item.Name);
                Session.GetMessageHandler().GetResponse().AppendInt32(0);
                Session.GetMessageHandler().GetResponse().AppendInt32(0);
    Under, add
    Code:
    Session.GetMessageHandler().GetResponse().AppendInt32(0);
    Replace MarketPlace.cs per

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    
    using Uber.HabboHotel.GameClients;
    using Uber.HabboHotel.Items;
    using Uber.Storage;
    using Uber.Messages;
    
    namespace Uber.HabboHotel.Catalogs
    {
        class Marketplace
        {
            public Boolean CanSellItem(UserItem Item)
            {
                if (!Item.GetBaseItem().AllowTrade || !Item.GetBaseItem().AllowMarketplaceSell)
                {
                    return false;
                }
    
                return true;
            }
    
            public void SellItem(GameClient Session, uint ItemId, int SellingPrice)
            {
                UserItem Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);
    
                if (Item == null || SellingPrice > 10000 || !CanSellItem(Item))
                {
                    Session.GetMessageHandler().GetResponse().Init(610);
                    Session.GetMessageHandler().GetResponse().AppendBoolean(false);
                    Session.GetMessageHandler().SendResponse();
    
                    return;
                }
    
                int Comission = CalculateComissionPrice(SellingPrice);
                int TotalPrice = SellingPrice + Comission;
                int ItemType = 1;
    
                if (Item.GetBaseItem().Type == "i")
                {
                    ItemType++;
                }
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    dbClient.AddParamWithValue("public_name", Item.GetBaseItem().PublicName);
                    dbClient.AddParamWithValue("extra_data", Item.ExtraData);
                    dbClient.ExecuteQuery("INSERT INTO catalog_marketplace_offers (item_id,user_id,asking_price,total_price,public_name,sprite_id,item_type,timestamp,extra_data) VALUES ('" + Item.BaseItem + "','" + Session.GetHabbo().Id + "','" + SellingPrice + "','" + TotalPrice + "',@public_name,'" + Item.GetBaseItem().SpriteId + "','" + ItemType + "','" + UberEnvironment.GetUnixTimestamp() + "',@extra_data)");
                    //dbClient.ExecuteQuery("UPDATE users set ticket_market = ticket_market -1 WHERE id = '" + Session.GetHabbo().Id + "'");
                }
    
                Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);
    
                Session.GetMessageHandler().GetResponse().Init(610);
                Session.GetMessageHandler().GetResponse().AppendBoolean(true);
                Session.GetMessageHandler().SendResponse();
            }
    
            public int CalculateComissionPrice(float SellingPrice)
            {
                return (int)Math.Ceiling((float)(SellingPrice / 100));
            }
    
            public Double FormatTimestamp()
            {
                return UberEnvironment.GetUnixTimestamp() - 172800;
            }
    
            public ServerMessage SerializeOffers(int MinCost, int MaxCost, String SearchQuery, int FilterMode)
            {
                // IgI`UJUIIY~JX]gXoAJISA
    
                DataTable Data = null;
                StringBuilder WhereClause = new StringBuilder();
                string OrderMode = "";
    
                WhereClause.Append("WHERE state = '1' AND timestamp >= '" + FormatTimestamp());
    
                if (MinCost >= 0)
                {
                    WhereClause.Append("' AND total_price >= '" + MinCost);
                }
    
                if (MaxCost >= 0)
                {
                    WhereClause.Append("' AND total_price <= '" + MaxCost);
                }
    
                switch (FilterMode)
                {
                    case 1:
                    default:
    
                        OrderMode = "' ORDER BY asking_price DESC";
                        break;
    
                    case 2:
    
                        OrderMode = "' ORDER BY asking_price ASC";
                        break;
                }
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    dbClient.AddParamWithValue("search_query", "%" + SearchQuery + "%");
    
                    if (SearchQuery.Length >= 1)
                    {
                        WhereClause.Append(" AND public_name LIKE @search_query");
                    }
    
                    Data = dbClient.ReadDataTable("SELECT * FROM catalog_marketplace_offers " + WhereClause.ToString() + " " + OrderMode + " LIMIT 100");
                }
    
                ServerMessage Message = new ServerMessage(615);
    
                if (Data != null)
                {
                    Message.AppendInt32(Data.Rows.Count);
    
                    foreach (DataRow Row in Data.Rows)
                    {
                        Message.AppendUInt((uint)Row["offer_id"]);
                        Message.AppendInt32(1);
                        Message.AppendInt32(int.Parse(Row["item_type"].ToString()));
                        Message.AppendInt32((int)Row["sprite_id"]); // Sprite ID
                        Message.AppendStringWithBreak(""); // Extra Chr (R52)
                        Message.AppendInt32((int)Row["total_price"]); // Price
                        Message.AppendInt32((int)Row["sprite_id"]); // ??
                        Message.AppendInt32((int)Row["total_price"]); // Avg
                        Message.AppendInt32(0); // Offers 
                    }
                }
                else
                {
                    Message.AppendInt32(0);
                }
    
                return Message;
            }
    
            public ServerMessage SerializeOwnOffers(uint HabboId)
            {
                DataTable Data = null;
                int Profits = 0;
    
                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    Data = dbClient.ReadDataTable("SELECT * FROM catalog_marketplace_offers WHERE user_id = '" + HabboId + "'");
                    String RawProfit = dbClient.ReadDataRow("SELECT SUM(asking_price) FROM catalog_marketplace_offers WHERE state = '2' AND user_id = '" + HabboId + "'")[0].ToString();
    
                    if (RawProfit.Length > 0)
                    {
                        Profits = int.Parse(RawProfit);
                    }
                }
    
                ServerMessage Message = new ServerMessage(616);
                Message.AppendInt32(Profits);
    
                if (Data != null)
                {
                    Message.AppendInt32(Data.Rows.Count);
    
                    foreach (DataRow Row in Data.Rows)
                    {
                        // IhHI`n~^II[EFPN[OKPA
    
                        int MinutesLeft = (int)Math.Floor((((Double)Row["timestamp"] + 172800) - UberEnvironment.GetUnixTimestamp()) / 60);
                        int state = int.Parse(Row["state"].ToString());
    
                        if (MinutesLeft <= 0)
                        {
                            state = 3;
                            MinutesLeft = 0;
                        }
    
                        Message.AppendUInt((uint)Row["offer_id"]);
                        Message.AppendInt32(state); // 1 = active, 2 = sold, 3 = expired
                        Message.AppendInt32(int.Parse(Row["item_type"].ToString())); // always 1 (??)
                        Message.AppendInt32((int)Row["sprite_id"]);
                        Message.AppendInt32((int)Row["total_price"]); // ??
                        Message.AppendInt32(MinutesLeft);
                        Message.AppendInt32((int)Row["sprite_id"]);
                    }
                }
                else
                {
                    Message.AppendInt32(0);
                }
    
                return Message;
            }
        }
    }
    For prove, go to http://www.hobbouhotel.com
    Last edited by dimitri54480; 25-04-11 at 09:01 PM.


  2. #2
    Member EliteRoyal is offline
    MemberRank
    Mar 2011 Join Date
    Santo Domingo,Location
    55Posts

    Re: Fix Your MarketPlace!

    Thanks i need this

  3. #3
    Apprentice CoCaCoL is offline
    MemberRank
    Mar 2011 Join Date
    20Posts

    Re: Fix Your MarketPlace!

    Very Nice. Thanks.

  4. #4
    hi i'm robbie Roper is offline
    MemberRank
    Oct 2008 Join Date
    /home/roperLocation
    2,283Posts

    Re: Fix Your MarketPlace!

    Cheers for sharing this snippet.

  5. #5
    Enthusiast dimitri54480 is offline
    MemberRank
    Feb 2011 Join Date
    44Posts

    Re: Fix Your MarketPlace!

    Who can put a screnn please?

  6. #6
    swagggggg Livar is offline
    MemberRank
    Oct 2008 Join Date
    United KingdomLocation
    2,272Posts

    Re: Fix Your MarketPlace!

    You obviously did not code this then.

  7. #7

    Re: Fix Your MarketPlace!

    Nice Release Thanks

  8. #8
    Account Upgraded | Title Enabled! Habblet is offline
    MemberRank
    Jul 2008 Join Date
    The NetherlandsLocation
    324Posts

    Re: Fix Your MarketPlace!

    He dindt code this, this is from bobba emu.

  9. #9
    sexiess is a sin. Subway is offline
    MemberRank
    Jun 2010 Join Date
    2,491Posts

    Re: Fix Your MarketPlace!

    Some of You guys go about every thread saying nice and 2 to 1 you didn't test the code :D

  10. #10
    Enthusiast dimitri54480 is offline
    MemberRank
    Feb 2011 Join Date
    44Posts

    Re: Fix Your MarketPlace!

    I never said that I had coded the marketplace of 1, 2, the code just MarketPlacePurchase anthony93260

    The site comes MarketPlace devbest.com whose title of the resource is Fixed uberemu

    The code is tested on http://www.hobbouhotel.com
    Last edited by dimitri54480; 26-04-11 at 08:13 PM.



Advertisement