Hi! I coded this system and now I'm going to share it for everyone.
1- HabboHotel>Catalog>CatalogItem.cs
After OfferID, enter this code (ex: print)
Now in ' public CatalogItem( ' after int OfferID, add int LTDLimit (ex: print)
After ' this.OfferId = OfferId; ' add this.LTDLimit = LTDLimit; (ex: print)
2- HabboHotel>Catalog>CatalogManager.cs
In the query ' SELECT `id`,`item_id`,`catalog_name`,`cost_credits`,`cost_pixels`,`cost_diamonds`,`cost_gotw`... ' after offer_id add `ltd_limit` (ex: print)
Now in this._items[PageId].Add after Convert.ToInt32(Row["offer_id"]), add Convert.ToInt32(Row["ltd_limit"])
3- HabboHotel>Catalog>CatalogDeal (only if it exists)
In ItemDataList.Add(new CatalogItem( add more one , 0
4- Communication>Packets>Incoming>Catalog>PurchaseFromCatalogEvent.cs
Below that add this code
if (Item.IsLimited)
{
1- HabboHotel>Catalog>CatalogItem.cs
After OfferID, enter this code (ex: print)
Code:
public int LTDLimit { get; set; }
You must be registered for see images attach
Now in ' public CatalogItem( ' after int OfferID, add int LTDLimit (ex: print)
You must be registered for see images attach
After ' this.OfferId = OfferId; ' add this.LTDLimit = LTDLimit; (ex: print)
You must be registered for see images attach
2- HabboHotel>Catalog>CatalogManager.cs
In the query ' SELECT `id`,`item_id`,`catalog_name`,`cost_credits`,`cost_pixels`,`cost_diamonds`,`cost_gotw`... ' after offer_id add `ltd_limit` (ex: print)
You must be registered for see images attach
Now in this._items[PageId].Add after Convert.ToInt32(Row["offer_id"]), add Convert.ToInt32(Row["ltd_limit"])
3- HabboHotel>Catalog>CatalogDeal (only if it exists)
In ItemDataList.Add(new CatalogItem( add more one , 0
4- Communication>Packets>Incoming>Catalog>PurchaseFromCatalogEvent.cs
Below that add this code
if (Item.IsLimited)
{
C#:
#region Limit LTDs
if (Item.LTDLimit > 0)
{
using (IQueryAdapter dbclient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
dbclient.SetQuery("SELECT * FROM `catalog_user_ltds` WHERE `user_id`='" + Session.GetHabbo().Id + "' AND `catalog_id`='" + Item.Id + "'");
DataTable table = dbclient.getTable();
dbclient.SetQuery("SELECT COUNT(id) as count FROM `catalog_user_ltds` WHERE `user_id`='" + Session.GetHabbo().Id + "' AND `catalog_id`='" + Item.Id + "'");
DataTable tablecount = dbclient.getTable();
foreach (DataRow rows in table.Rows)
{
int CountLtds = Convert.ToInt32(rows["count"]);
if (table != null)
{
if (CountLtds >= Item.LTDLimit)
{
Session.SendMessage(new PurchaseErrorComposer(1));
Session.SendNotification("Limit LTD: " + Convert.ToString(Item.LTDLimit));
return;
}
}
}
foreach (DataRow row in tablecount.Rows)
{
if (tablecount != null)
{
if (Convert.ToInt32(row["count"]) == 0)
{
dbclient.RunQuery("INSERT INTO `catalog_user_ltds` (`user_id`, `base_id`, `catalog_id`, `count`, `last_purchase`) VALUES ('" + Session.GetHabbo().Id + "', '" + Item.ItemId + "', '" + Item.Id + "', '1', '" + PlusEnvironment.GetUnixTimestamp() + "')");
}
else
{
dbclient.RunQuery("UPDATE `catalog_user_ltds` SET `count` = `count` + 1, `last_purchase`='" + PlusEnvironment.GetUnixTimestamp() + "' WHERE `user_id`='" + Session.GetHabbo().Id + "' AND `catalog_id`='" + Item.Id + "'");
}
}
}
}
}
#endregion
5- Insert the table into your database.
Code:
CREATE TABLE `catalog_user_ltds` (
`id` INT(3) NOT NULL AUTO_INCREMENT,
`user_id` INT(11) NOT NULL,
`base_id` INT(11) NOT NULL,
`catalog_id` INT(11) NOT NULL,
`count` INT(3) NOT NULL,
`last_purchase` DOUBLE NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
INDEX `catalog_id` (`catalog_id`),
INDEX `base_id` (`base_id`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
AUTO_INCREMENT=1
;
ALTER TABLE `catalog_items`
ADD COLUMN `ltd_limit` INT(4) NOT NULL DEFAULT '0' AFTER `offer_id`;
If you want to have a purchase limit per user for that particular item only change the value of ltd_limit to the limit quantity that the user can buy that item.
I'm sorry if I didn't explain how to add it, but if you already know how to move it will be easy to add.
If you have questions just comment! I appreciate your attention!
CREDITS:
Snaiker (Pollak)
I'm sorry if I didn't explain how to add it, but if you already know how to move it will be easy to add.
If you have questions just comment! I appreciate your attention!
CREDITS:
Snaiker (Pollak)