[PLUS EMU] I need code of command :search_furni

Hypothesis

Programmer
Jan 6, 2019
524
361
Probably not the most efficient way to code something like this, but it works, tested on my hotel.
Basically what this does is it selects items from the catalog that contain a certain string.
An example would be :searchfurni Iced, this will return all furniture names containing Iced along with their page ID, you could further this and have it collect the page name instead of the page ID, but this is just most basic start of it.
C#:
using System;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections.Generic;

using Plus.HabboHotel.Users;
using Plus.HabboHotel.GameClients;

using Plus.Database.Interfaces;
using Plus.Communication.Packets.Outgoing.Notifications;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
{
    class SearchFurniCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_enable"; }
        }

        public string Parameters
        {
            get { return ""; }
        }

        public string Description
        {
            get { return "Locate catalog items containing a certain name"; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            StringBuilder b = new StringBuilder();
            b.Append("Listed items containing " + Params[1] + "\n\n");
            using (IQueryAdapter db = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                db.SetQuery("SELECT * FROM `catalog_items` WHERE `public_name` LIKE '%" + Params[1] + "%'");
                db.RunQuery();
                DataTable t = db.getTable();
                foreach (DataRow r in t.Rows)
                {
                    b.Append("You found: " + Convert.ToString(r["public_name"]) + " listed in: " + Convert.ToString(r["page_id"]) + "\n");
                }
            }

            Session.SendMessage(new MOTDNotificationComposer(b.ToString()));
        }
    }
}
 
Last edited:

olliedean

ollie.cool
Jan 28, 2013
433
107
Probably not the most efficient way to code something like this, but it works, tested on my hotel.
Basically what this does is it selects items from the catalog that contain a certain string.
An example would be :searchfurni Iced, this will return all furniture names containing Iced along with their page ID, you could further this and have it collect the page name instead of the page ID, but this is just the basic score of it.
C#:
using System;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections.Generic;

using Plus.HabboHotel.Users;
using Plus.HabboHotel.GameClients;

using Plus.Database.Interfaces;
using Plus.Communication.Packets.Outgoing.Notifications;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
{
    class SearchFurniCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_enable"; }
        }

        public string Parameters
        {
            get { return ""; }
        }

        public string Description
        {
            get { return "Locate catalog items containing a certain name"; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            StringBuilder b = new StringBuilder();
            b.Append("Listed items containing " + Params[1] + "\n\n");
            using (IQueryAdapter db = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                db.SetQuery("SELECT * FROM `catalog_items` WHERE `public_name` LIKE '%" + Params[1] + "'%");
                db.RunQuery();
                DataTable t = db.getTable();
                foreach (DataRow r in t.Rows)
                {
                    b.Append("You found: " + Convert.ToString(r["public_name"]) + " listed in: " + Convert.ToString(r["page_id"]) + "\n");
                }
            }

            Session.SendMessage(new MOTDNotificationComposer(b.ToString()));
        }
    }
}
Thats amazing. I always go on hotels, and see a messy catalog and can never find the item I want. I hope retros atleast catch on to this concept. Good job.
 

Damien

Don't need glasses if you can C#
Feb 26, 2012
434
647
Probably not the most efficient way to code something like this, but it works, tested on my hotel.
Basically what this does is it selects items from the catalog that contain a certain string.
An example would be :searchfurni Iced, this will return all furniture names containing Iced along with their page ID, you could further this and have it collect the page name instead of the page ID, but this is just the basic score of it.
C#:
using System;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections.Generic;

using Plus.HabboHotel.Users;
using Plus.HabboHotel.GameClients;

using Plus.Database.Interfaces;
using Plus.Communication.Packets.Outgoing.Notifications;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
{
    class SearchFurniCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_enable"; }
        }

        public string Parameters
        {
            get { return ""; }
        }

        public string Description
        {
            get { return "Locate catalog items containing a certain name"; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            StringBuilder b = new StringBuilder();
            b.Append("Listed items containing " + Params[1] + "\n\n");
            using (IQueryAdapter db = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                db.SetQuery("SELECT * FROM `catalog_items` WHERE `public_name` LIKE '%" + Params[1] + "'%");
                db.RunQuery();
                DataTable t = db.getTable();
                foreach (DataRow r in t.Rows)
                {
                    b.Append("You found: " + Convert.ToString(r["public_name"]) + " listed in: " + Convert.ToString(r["page_id"]) + "\n");
                }
            }

            Session.SendMessage(new MOTDNotificationComposer(b.ToString()));
        }
    }
}
Only thing I'd improve is removing the query. The catalog items are already cached on the server. Other than that, it's a fantastic command with room to do some much more with it.
 

GoodHotel

New Member
Sep 21, 2018
12
3
Probably not the most efficient way to code something like this, but it works, tested on my hotel.
Basically what this does is it selects items from the catalog that contain a certain string.
An example would be :searchfurni Iced, this will return all furniture names containing Iced along with their page ID, you could further this and have it collect the page name instead of the page ID, but this is just most basic start of it.
C#:
using System;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections.Generic;

using Plus.HabboHotel.Users;
using Plus.HabboHotel.GameClients;

using Plus.Database.Interfaces;
using Plus.Communication.Packets.Outgoing.Notifications;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
{
    class SearchFurniCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_enable"; }
        }

        public string Parameters
        {
            get { return ""; }
        }

        public string Description
        {
            get { return "Locate catalog items containing a certain name"; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            StringBuilder b = new StringBuilder();
            b.Append("Listed items containing " + Params[1] + "\n\n");
            using (IQueryAdapter db = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                db.SetQuery("SELECT * FROM `catalog_items` WHERE `public_name` LIKE '%" + Params[1] + "'%");
                db.RunQuery();
                DataTable t = db.getTable();
                foreach (DataRow r in t.Rows)
                {
                    b.Append("You found: " + Convert.ToString(r["public_name"]) + " listed in: " + Convert.ToString(r["page_id"]) + "\n");
                }
            }

            Session.SendMessage(new MOTDNotificationComposer(b.ToString()));
        }
    }
}
You code is not work
 

Users who are viewing this thread

Top