[COMMAND] Add LTD (catalog)

Pollak

Active Member
Oct 12, 2017
161
51
Hi! I coded this command and now I want to share it for everyone. :)

1- HabboHotel>Rooms>Chat>Commands>Administrator and enter a new code with the name LTDCommand.cs


C#:
#region
using Plus.HabboHotel.Items;
using Plus.Core;
using Plus.HabboHotel.GameClients;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Plus.Database.Interfaces;
using System.Data;
using Plus.Utilities;
using Plus.Communication.Packets.Outgoing.Notifications;
#endregion

namespace Plus.HabboHotel.Rooms.Chat.Commands.Administrator
{
    internal class LTDCommand : IChatCommand
    {
        public string PermissionRequired => "command_add_ltd";

        public string Parameters => "%variable%";

        public string Description => "";

        public void Execute(GameClient Session, Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Oops, enter the variable name! ': ltd list'");
                return;
            }

            int randNum = RandomNumber.GenerateNewRandom(35000, 45000);

            StringBuilder builder = new StringBuilder();

            var Variables = Params[1];
            switch (Variables.ToLower())
            {
                case "lista":
                case "list":
                case "help":
                case "ajuda":
                    {
                        builder.Append("List of currently available options:\n\n");
                        builder.Append("add -> Stand in front of Furni and type the command ' :ltd add '\n");
                        builder.Append("remove -> Updates the current LTD of this page to the sold out LTD page!\n");
                        builder.Append("NOTE: Configure in the server_limited_edition (database) table the settings.");

                        Session.SendMessage(new MOTDNotificationComposer(builder.ToString()));
                        break;
                    }
                case "adicionar":
                case "add":
                    {
                        RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
                        List<Item> Items = Room.GetGameMap().GetAllRoomItemForSquare(User.SquareInFront.X, User.SquareInFront.Y);
                        foreach (Item _item in Items)
                        {
                            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.SetQuery("SELECT * FROM `server_limited_edition` LIMIT 1");
                                DataTable table = dbClient.getTable();

                                foreach (DataRow row in table.Rows)
                                {
                                    int PriceCredits = Convert.ToInt32(row["price_credits"]);
                                    int PriceDuckets = Convert.ToInt32(row["price_duckets"]);
                                    int PriceDiamonds = Convert.ToInt32(row["price_diamonds"]);
                                    int PriceGotw = Convert.ToInt32(row["price_gotw"]);
                                    int LimitedStack = Convert.ToInt32(row["limited_stack"]);
                                    int LtdLimit = Convert.ToInt32(row["ltd_limit"]);
                                    int PageId = Convert.ToInt32(row["page_id"]);

                                    dbClient.runFastQuery("INSERT INTO `catalog_items` (id, page_id, item_id, catalog_name, cost_credits, cost_pixels, cost_diamonds, cost_gotw, limited_stack) VALUES ('" + randNum + "', '" + PageId + "', '" + _item.Data.Id + "', '" + _item.Data.PublicName + "', '" + PriceCredits + "', '" + PriceDuckets + "', '" + PriceDiamonds + "', '" + PriceGotw + "', '" + LimitedStack + "')");

                                    Session.SendWhisper("Item " + _item.Data.PublicName + " has been successfully added to the catalog!");
                                }
                            }
                        }

                        break;
                    }
                case "remover":
                case "remove":
                case "mover":
                case "move":
                    {
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT * FROM `server_limited_edition` LIMIT 1");
                            DataTable table = dbClient.getTable();

                            foreach (DataRow row in table.Rows)
                            {
                                int PageId = Convert.ToInt32(row["page_id"]);
                                int SoldPageId = Convert.ToInt32(row["sold_page_id"]);

                                if (SoldPageId != 0)
                                {
                                    dbClient.runFastQuery("UPDATE catalog_items SET page_id='" + SoldPageId + "' WHERE page_id='" + PageId + "'");

                                    Session.SendWhisper("Current Limited Edition LTD page is now on the Rare Out of Stock (Page " + Convert.ToString(SoldPageId) + ") page");
                                }
                            }
                        }
                        break;
                    }
                default:
                    {
                        Session.SendWhisper(Params[1] + " is not an existing variable!");
                        break;
                    }
            }
        }
    }
}

2- HabboHotel>Rooms>Chat>Commands in CommandManager.cs
Search for private void RegisterAdministrator() and enter:

Code:
this.Register("ltd", new LTDCommand());

3-
Then debug everything you entered.
Then go to your database (db) in the permissions_commands table and enter:

Code:
INSERT INTO `permissions_commands` (`command`, `group_id`, `subscription_id`) VALUES ('command_add_ltd', '8', '0');

4- Insert the table into your database.

Code:
CREATE TABLE IF NOT EXISTS `server_limited_edition` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `page_id` int(11) NOT NULL DEFAULT '510',
  `sold_page_id` int(11) NOT NULL,
  `limited_stack` int(5) NOT NULL DEFAULT '25',
  `price_credits` int(5) NOT NULL DEFAULT '0',
  `price_duckets` int(5) NOT NULL DEFAULT '0',
  `price_diamonds` int(5) NOT NULL DEFAULT '0',
  `price_gotw` int(5) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

INSERT INTO `server_limited_edition` (`id`, `page_id`, `sold_page_id`, `limited_stack`, `price_credits`, `price_duckets`, `price_diamonds`, `price_gotw`) VALUES (1, 510, 0, 10, 10, 0, 15, 0);

If you have questions just comment! I appreciate your attention!

CREDITS:
Snaiker (Pollak)
 

Bran

habcrush.pw
Mar 13, 2017
1,789
1,608
it's not that hard to do manually this just seems lazy, but good release non the less :)
 

ZaneyRetros

i am dead
Jul 27, 2015
211
105
how to insert table in database ?
Run this as a query
Code:
CREATE TABLE IF NOT EXISTS `server_limited_edition` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `page_id` int(11) NOT NULL DEFAULT '510',
  `sold_page_id` int(11) NOT NULL,
  `limited_stack` int(5) NOT NULL DEFAULT '25',
  `price_credits` int(5) NOT NULL DEFAULT '0',
  `price_duckets` int(5) NOT NULL DEFAULT '0',
  `price_diamonds` int(5) NOT NULL DEFAULT '0',
  `price_gotw` int(5) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

INSERT INTO `server_limited_edition` (`id`, `page_id`, `sold_page_id`, `limited_stack`, `price_credits`, `price_duckets`, `price_diamonds`, `price_gotw`) VALUES (1, 510, 0, 10, 10, 0, 15, 0);
 

Users who are viewing this thread

Top