Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Command Edit Furniture [¨PLUSEMU]

Newbie Spellweaver
Joined
Aug 17, 2016
Messages
19
Reaction score
11
Hi guys i will give you my new command :item (update furniture)

Options of my command are:

- :item length number
- :item height decimalnumber
- :item width number
- :item mercadillo si/no (can sell item on marketplace)
- :item cansit si/no
- :item canwalk si/no
- :item canstack si/no
- :item interaction name
- :item ineractioncount number

My command is in spanish because im from venezuela, but you can edit it (sorry for my bad english)

so, here is the code:
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;


using Plus.Communication.Packets.Outgoing.Moderation;
using Plus.HabboHotel.Items;
using Plus.Communication.Packets.Outgoing.Notifications;
using Plus.Database.Interfaces;
using System.Data;


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




        public string Parameters
        {
            get { return "(tipo) (cantidad)"; }
        }


        public string Description
        {
            get { return "Envia una alerta a todo el hotel."; }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            RoomUser RUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            List<Item> Items = Room.GetGameMap().GetRoomItemForSquare(RUser.X, RUser.Y);
            if (Params.Length == 1 || Params[1] == "utilidad")
            {
                StringBuilder Lista = new StringBuilder();
                Lista.Append("Lista de usos: (Nota: Edita TODOS los items abajo de ti): \r\r");
                Lista.Append("1) :item width numero (Edita la anchura del Item) \r");
                Lista.Append("2) :item length numero (Edita la longitud del Item) \r");
                Lista.Append("3) :item height numero (Edita la altura del Item) \r");
                Lista.Append("4) :item cansit si/no (Permite / No Permite sentarse sobre el Item) \r");
                Lista.Append("5) :item canwalk si/no (Permite / No Permite caminar sobre el Item) \r");
                Lista.Append("6) :item canstack si/no (Permite / No Permite apilar sobre el Item) \r");
                Lista.Append("7) :item mercadillo si/no (Permite / No Permite la venta del Item en mercadillo) \r");
                Lista.Append("8) :item interaction nombre (Asigna una interacción al Item) \r");
                Lista.Append("9) :item interactioncount numero (Asigna la cantidad de interacciones del Item) \r\r");
                Lista.Append("Nota: Para que se actualice el Item debes recogerlo y ponerlo en la sala nuevamente o refrescar la sala.");
                Session.SendMessage(new MOTDNotificationComposer(Lista.ToString()));
                return;
            }
            String Type = Params[1].ToLower();
            int numeroint = 0, FurnitureID = 0;
            double numerodouble = 0;
            DataRow Item = null;
            String opcion = "";
            switch (Type)
            {
                case "width":
                    {
                        try
                        {
                            numeroint = Convert.ToInt32(Params[2]);
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `width` = '" + numeroint + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Anchura del Item: " + FurnitureID + " editada con éxito (Valor de anchura ingresado: "+numeroint.ToString()+")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Ha ocurrido un error (Ingrese números válidos)");
                        }
                    }
                    break;
                case "length":
                    {
                        try
                        {
                            numeroint = Convert.ToInt32(Params[2]);
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `length` = '" + numeroint + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Longitud del Item: " + FurnitureID + " editada con éxito (Valor de longitud ingresado: " + numeroint.ToString() + ")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Ha ocurrido un error (Ingrese números válidos)");
                        }
                    }
                    break;
                case "height":
                    {
                        try
                        {
                            numerodouble = Convert.ToDouble(Params[2]);
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `stack_height` = '" + numerodouble + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Altura del Item: " + FurnitureID + " editada con éxito (Valor de altura ingresado: " + numerodouble.ToString() + ")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Ha ocurrido un error (Ingrese números válidos)");
                        }
                    }
                    break;
                case "interactioncount":
                    {
                        try
                        {
                            numeroint = Convert.ToInt32(Params[2]);
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `interaction_modes_count` = '" + numeroint + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Numero de interacciones del Item: " + FurnitureID + " editado con éxito (Valor ingresado: " + numeroint.ToString() + ")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Ha ocurrido un error (Ingrese números válidos)");
                        }
                    }
                    break;
                case "cansit":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            if (!opcion.Equals("si") && !opcion.Equals("no"))
                            {
                                Session.SendWhisper("Ingresa una opción valida (si/no)");
                                return;
                            }
                            if (opcion.Equals("si"))
                                opcion = "1";
                            else if (opcion.Equals("no"))
                                opcion = "0";
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `can_sit` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("can_sit del Item: " + FurnitureID + " editado con éxito");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Ha ocurrido un error.");
                        }
                    }
                    break;
                case "canstack":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            if (!opcion.Equals("si") && !opcion.Equals("no"))
                            {
                                Session.SendWhisper("Ingresa una opción valida (si/no)");
                                return;
                            }
                            if (opcion.Equals("si"))
                                opcion = "1";
                            else if (opcion.Equals("no"))
                                opcion = "0";
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `can_stack` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("can_stack del Item: " + FurnitureID + " editado con éxito");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Ha ocurrido un error.");
                        }
                    }
                    break;
                case "canwalk":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            if (!opcion.Equals("si") && !opcion.Equals("no"))
                            {
                                Session.SendWhisper("Ingresa una opción valida (si/no)");
                                return;
                            }
                            if (opcion.Equals("si"))
                                opcion = "1";
                            else if (opcion.Equals("no"))
                                opcion = "0";
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `is_walkable` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("can_walk del Item: " + FurnitureID + " editado con éxito");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Ha ocurrido un error.");
                        }
                    }
                    break;
                case "mercadillo":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            if (!opcion.Equals("si") && !opcion.Equals("no"))
                            {
                                Session.SendWhisper("Ingresa una opción valida (si/no)");
                                return;
                            }
                            if (opcion.Equals("si"))
                                opcion = "1";
                            else if (opcion.Equals("no"))
                                opcion = "0";
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `is_rare` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Opción de venta en el mercadillo del Item: " + FurnitureID + " editado con éxito");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Ha ocurrido un error.");
                        }
                    }
                    break;
                case "interaction":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `interaction_type` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Interacción del Item: "+FurnitureID+" editada con éxito. (Valor ingresado: "+opcion+")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Ha ocurrido un error.");
                        }
                    }
                    break;
                default:
                    {
                        Session.SendNotification("La opción ingrsada no existe, para saber las opciones decir :item utilidad");
                        return;
                    }break;
            }




        }
   }
}

You can edit all items on your square, below your keko (stacking them)

Greatz, Felix (Distorsion)
 
Still alive.
Loyal Member
Joined
Apr 13, 2013
Messages
1,145
Reaction score
886
Good idea. Never seen that before, great job.
 
Newbie Spellweaver
Joined
Apr 23, 2016
Messages
62
Reaction score
12
Google Translate sucks when i'm translating the Spanish bits into English.
Can somebody who speaks Spanish and English translate these steps into English? :):


Great release tho! :w00t:
 
Junior Spellweaver
Joined
May 3, 2009
Messages
173
Reaction score
134
English version, almost :laugh:

I have not tested!

PHP:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;


using Plus.Communication.Packets.Outgoing.Moderation;
using Plus.HabboHotel.Items;
using Plus.Communication.Packets.Outgoing.Notifications;
using Plus.Database.Interfaces;
using System.Data;


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

        public string Parameters
        {
            get { return "(type) (amount)"; }
        }


        public string Description
        {
            get { return "Send an alert for everyone."; }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            RoomUser RUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            List<Item> Items = Room.GetGameMap().GetRoomItemForSquare(RUser.X, RUser.Y);
            if (Params.Length == 1 || Params[1] == "help")
            {
                StringBuilder Lista = new StringBuilder();
                Lista.Append("Usage: (WARNING: this command edit everything under you!): \r\r");
                Lista.Append("1) :item width number (Edit item witdh) \r");
                Lista.Append("2) :item length number (Edit item length) \r");
                Lista.Append("3) :item height number (Edit item height) \r");
                Lista.Append("4) :item cansit yes/no (Allow / Disallow Sit on the Item) \r");
                Lista.Append("5) :item canwalk yes/no (Allow / Disallow Walk on the Item) \r");
                Lista.Append("6) :item canstack yes/no (Allow / Disallow Stack on the Item) \r");
                Lista.Append("7) :item market yes/no (Allow / Disallow Market place sell) \r");
                Lista.Append("8) :item interaction name (Set the Item interaction) \r");
                Lista.Append("9) :item interactioncount number (Set the amount of interactions of the Item) \r\r");
                Lista.Append("Notice: Pick up and place or refresh the room to work.");
                Session.SendMessage(new MOTDNotificationComposer(Lista.ToString()));
                return;
            }
            String Type = Params[1].ToLower();
            int numeroint = 0, FurnitureID = 0;
            double numerodouble = 0;
            DataRow Item = null;
            String opcion = "";
            switch (Type)
            {
                case "width":
                    {
                        try
                        {
                            numeroint = Convert.ToInt32(Params[2]);
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `width` = '" + numeroint + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item width: " + FurnitureID + " updated (New width: "+numeroint.ToString()+")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong! (Only valid numbers)");
                        }
                    }
                    break;
                case "length":
                    {
                        try
                        {
                            numeroint = Convert.ToInt32(Params[2]);
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `length` = '" + numeroint + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item length: " + FurnitureID + " updated (New length: " + numeroint.ToString() + ")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong! (Only valid numbers)");
                        }
                    }
                    break;
                case "height":
                    {
                        try
                        {
                            numerodouble = Convert.ToDouble(Params[2]);
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `stack_height` = '" + numerodouble + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item height: " + FurnitureID + " updated (New height: " + numerodouble.ToString() + ")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong! (Only valid numbers)");
                        }
                    }
                    break;
                case "interactioncount":
                    {
                        try
                        {
                            numeroint = Convert.ToInt32(Params[2]);
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `interaction_modes_count` = '" + numeroint + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Interaction count: " + FurnitureID + " updated (New interaction count: " + numeroint.ToString() + ")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong! (Only valid numbers)");
                        }
                    }
                    break;
                case "cansit":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            if (!opcion.Equals("yes") && !opcion.Equals("no"))
                            {
                                Session.SendWhisper("Only use yes OR no)");
                                return;
                            }
                            if (opcion.Equals("yes"))
                                opcion = "1";
                            else if (opcion.Equals("no"))
                                opcion = "0";
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `can_sit` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item can_sit: " + FurnitureID + " updated");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong!");
                        }
                    }
                    break;
                case "canstack":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            if (!opcion.Equals("yes") && !opcion.Equals("no"))
                            {
                                Session.SendWhisper("Only use yes OR no)");
                                return;
                            }
                            if (opcion.Equals("yes"))
                                opcion = "1";
                            else if (opcion.Equals("no"))
                                opcion = "0";
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `can_stack` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item can_stack: " + FurnitureID + " updated");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong!");
                        }
                    }
                    break;
                case "canwalk":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            if (!opcion.Equals("yes") && !opcion.Equals("no"))
                            {
                                Session.SendWhisper("Only use yes OR no)");
                                return;
                            }
                            if (opcion.Equals("yes"))
                                opcion = "1";
                            else if (opcion.Equals("no"))
                                opcion = "0";
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `is_walkable` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item can_walk: " + FurnitureID + " updated");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong!");
                        }
                    }
                    break;
                case "market":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            if (!opcion.Equals("yes") && !opcion.Equals("no"))
                            {
                                Session.SendWhisper("Only use yes OR no)");
                                return;
                            }
                            if (opcion.Equals("yes"))
                                opcion = "1";
                            else if (opcion.Equals("no"))
                                opcion = "0";
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `is_rare` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Market place option: " + FurnitureID + " updated");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong!");
                        }
                    }
                    break;
                case "interaction":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `interaction_type` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item interaction: "+FurnitureID+" updated. (New interaction: "+opcion+")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong!");
                        }
                    }
                    break;
                default:
                    {
                        Session.SendNotification("Oops! Something wrong! If you need help, see :item help");
                        return;
                    }break;
            }
        }
   }
}
 
Newbie Spellweaver
Joined
Apr 23, 2016
Messages
62
Reaction score
12
English version, almost :laugh:

I have not tested!

PHP:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;


using Plus.Communication.Packets.Outgoing.Moderation;
using Plus.HabboHotel.Items;
using Plus.Communication.Packets.Outgoing.Notifications;
using Plus.Database.Interfaces;
using System.Data;


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

        public string Parameters
        {
            get { return "(type) (amount)"; }
        }


        public string Description
        {
            get { return "Send an alert for everyone."; }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            RoomUser RUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            List<Item> Items = Room.GetGameMap().GetRoomItemForSquare(RUser.X, RUser.Y);
            if (Params.Length == 1 || Params[1] == "help")
            {
                StringBuilder Lista = new StringBuilder();
                Lista.Append("Usage: (WARNING: this command edit everything under you!): \r\r");
                Lista.Append("1) :item width number (Edit item witdh) \r");
                Lista.Append("2) :item length number (Edit item length) \r");
                Lista.Append("3) :item height number (Edit item height) \r");
                Lista.Append("4) :item cansit yes/no (Allow / Disallow Sit on the Item) \r");
                Lista.Append("5) :item canwalk yes/no (Allow / Disallow Walk on the Item) \r");
                Lista.Append("6) :item canstack yes/no (Allow / Disallow Stack on the Item) \r");
                Lista.Append("7) :item market yes/no (Allow / Disallow Market place sell) \r");
                Lista.Append("8) :item interaction name (Set the Item interaction) \r");
                Lista.Append("9) :item interactioncount number (Set the amount of interactions of the Item) \r\r");
                Lista.Append("Notice: Pick up and place or refresh the room to work.");
                Session.SendMessage(new MOTDNotificationComposer(Lista.ToString()));
                return;
            }
            String Type = Params[1].ToLower();
            int numeroint = 0, FurnitureID = 0;
            double numerodouble = 0;
            DataRow Item = null;
            String opcion = "";
            switch (Type)
            {
                case "width":
                    {
                        try
                        {
                            numeroint = Convert.ToInt32(Params[2]);
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `width` = '" + numeroint + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item width: " + FurnitureID + " updated (New width: "+numeroint.ToString()+")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong! (Only valid numbers)");
                        }
                    }
                    break;
                case "length":
                    {
                        try
                        {
                            numeroint = Convert.ToInt32(Params[2]);
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `length` = '" + numeroint + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item length: " + FurnitureID + " updated (New length: " + numeroint.ToString() + ")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong! (Only valid numbers)");
                        }
                    }
                    break;
                case "height":
                    {
                        try
                        {
                            numerodouble = Convert.ToDouble(Params[2]);
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `stack_height` = '" + numerodouble + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item height: " + FurnitureID + " updated (New height: " + numerodouble.ToString() + ")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong! (Only valid numbers)");
                        }
                    }
                    break;
                case "interactioncount":
                    {
                        try
                        {
                            numeroint = Convert.ToInt32(Params[2]);
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `interaction_modes_count` = '" + numeroint + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Interaction count: " + FurnitureID + " updated (New interaction count: " + numeroint.ToString() + ")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong! (Only valid numbers)");
                        }
                    }
                    break;
                case "cansit":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            if (!opcion.Equals("yes") && !opcion.Equals("no"))
                            {
                                Session.SendWhisper("Only use yes OR no)");
                                return;
                            }
                            if (opcion.Equals("yes"))
                                opcion = "1";
                            else if (opcion.Equals("no"))
                                opcion = "0";
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `can_sit` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item can_sit: " + FurnitureID + " updated");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong!");
                        }
                    }
                    break;
                case "canstack":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            if (!opcion.Equals("yes") && !opcion.Equals("no"))
                            {
                                Session.SendWhisper("Only use yes OR no)");
                                return;
                            }
                            if (opcion.Equals("yes"))
                                opcion = "1";
                            else if (opcion.Equals("no"))
                                opcion = "0";
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `can_stack` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item can_stack: " + FurnitureID + " updated");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong!");
                        }
                    }
                    break;
                case "canwalk":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            if (!opcion.Equals("yes") && !opcion.Equals("no"))
                            {
                                Session.SendWhisper("Only use yes OR no)");
                                return;
                            }
                            if (opcion.Equals("yes"))
                                opcion = "1";
                            else if (opcion.Equals("no"))
                                opcion = "0";
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `is_walkable` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item can_walk: " + FurnitureID + " updated");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong!");
                        }
                    }
                    break;
                case "market":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            if (!opcion.Equals("yes") && !opcion.Equals("no"))
                            {
                                Session.SendWhisper("Only use yes OR no)");
                                return;
                            }
                            if (opcion.Equals("yes"))
                                opcion = "1";
                            else if (opcion.Equals("no"))
                                opcion = "0";
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `is_rare` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Market place option: " + FurnitureID + " updated");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong!");
                        }
                    }
                    break;
                case "interaction":
                    {
                        try
                        {
                            opcion = Params[2].ToLower();
                            foreach (Item IItem in Items.ToList())
                            {
                                if (IItem == null)
                                    continue;
                                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                {
                                    dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                                    Item = dbClient.getRow();
                                    if (Item == null)
                                        continue;
                                    FurnitureID = Convert.ToInt32(Item[0]);
                                    dbClient.RunQuery("UPDATE `furniture` SET `interaction_type` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                                }
                                Session.SendWhisper("Item interaction: "+FurnitureID+" updated. (New interaction: "+opcion+")");
                            }
                            PlusEnvironment.GetGame().GetItemManager().Init();
                        }
                        catch (Exception)
                        {
                            Session.SendNotification("Oops! Something wrong!");
                        }
                    }
                    break;
                default:
                    {
                        Session.SendNotification("Oops! Something wrong! If you need help, see :item help");
                        return;
                    }break;
            }
        }
   }
}

Works perfectly, good job. :thumbup1:
 
Newbie Spellweaver
Joined
Aug 17, 2016
Messages
19
Reaction score
11
hahhaha thanks for translate my command! i hope you guys enjoy it in english <3

see you later :)
 
Experienced Elementalist
Joined
Nov 11, 2015
Messages
238
Reaction score
89
Code:
dbClient.RunQuery("UPDATE `furniture` SET `interaction_type` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");

Tricky, very very tricky.. I understand you will be the only one using the command but I still recommend always using prepared statements.
Code:
dbClient.SetQuery("UPDATE `furniture` SET `interaction_type` = [USER=2000182511]inter[/USER]action WHERE `id` = [USER=19862]id[/USER] LIMIT 1");
dbClient.AddParameter("interaction", opcion);
dbClient.AddParameter("id", id);
dbClient.RunQuery();

btw in a function, do use lowerCamelCase, FurnitureID -> furnitureId.
Thanks for the command though saves a lot of time
 
Newbie Spellweaver
Joined
Aug 17, 2016
Messages
19
Reaction score
11
Tricky, very very tricky.. I understand you will be the only one using the command but I still recommend always using prepared statements.
Code:
dbClient.SetQuery("UPDATE `furniture` SET `interaction_type` = @[I][B][URL="http://forum.ragezone.com/members/2000182511.html"]inter[/URL][/B][/I]action WHERE `id` = @[I][B][URL="http://forum.ragezone.com/members/19862.html"]id[/URL][/B][/I] LIMIT 1");
dbClient.AddParameter("interaction", opcion);
dbClient.AddParameter("id", id);
dbClient.RunQuery();

btw in a function, do use lowerCamelCase, FurnitureID -> furnitureId.
Thanks for the command though saves a lot of time

Yes prepared statements always be better thanks for advice!

I'm glad to see that you guys like my command!
 
Back
Top