Advertisement
Guest User

FurnitureCommand.cs

a guest
Jan 3rd, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 20.88 KB | None | 0 0
  1. using System.Linq;
  2. using System;
  3. using System.Text;
  4. using System.Collections.Generic;
  5.  
  6.  
  7. using Plus.Communication.Packets.Outgoing.Moderation;
  8. using Plus.HabboHotel.Items;
  9. using Plus.Communication.Packets.Outgoing.Notifications;
  10. using Plus.Database.Interfaces;
  11. using System.Data;
  12.  
  13.  
  14. namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
  15. {
  16.     class FurnitureCommand : IChatCommand
  17.     {
  18.         public string PermissionRequired
  19.         {
  20.             get { return "command_furniture"; }
  21.         }
  22.  
  23.         public string Parameters
  24.         {
  25.             get { return "(Type) (montant)"; }
  26.         }
  27.  
  28.  
  29.         public string Description
  30.         {
  31.             get { return "Correction des mobiliers."; }
  32.         }
  33.         public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
  34.         {
  35.             RoomUser RUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
  36.             List<Item> Items = Room.GetGameMap().GetRoomItemForSquare(RUser.X, RUser.Y);
  37.             if (Params.Length == 1 || Params[1] == "help")
  38.             {
  39.                 StringBuilder Lista = new StringBuilder();
  40.                 Lista.Append("Avertissement : Cette commande sert à modifier vos mobis depuis la table furniture.): \r\r");
  41.                 Lista.Append("1) :item width nombre (Edit item witdh) \r");
  42.                 Lista.Append("2) :item length number (Edit item length) \r");
  43.                 Lista.Append("3) :item height number (Edit item height) \r");
  44.                 Lista.Append("4) :item cansit oui/non (Allow / Disallow Sit on the Item) \r");
  45.                 Lista.Append("5) :item canwalk oui/non (Allow / Disallow Walk on the Item) \r");
  46.                 Lista.Append("6) :item canstack oui/non (Allow / Disallow Stack on the Item) \r");
  47.                 Lista.Append("7) :item market oui/non (Allow / Disallow Market place sell) \r");
  48.                 Lista.Append("8) :item interaction nom (Set the Item interaction) \r");
  49.                 Lista.Append("9) :item interactioncount nombre (Set the amount of interactions of the Item) \r\r");
  50.                 Lista.Append("Info : unload votre appart une fois que ton mobis est modifier.");
  51.                 Session.SendMessage(new MOTDNotificationComposer(Lista.ToString()));
  52.                 return;
  53.             }
  54.             String Type = Params[1].ToLower();
  55.             int numeroint = 0, FurnitureID = 0;
  56.             double numerodouble = 0;
  57.             DataRow Item = null;
  58.             String opcion = "";
  59.             switch (Type)
  60.             {
  61.                 case "width":
  62.                     {
  63.                         try
  64.                         {
  65.                             numeroint = Convert.ToInt32(Params[2]);
  66.                             foreach (Item IItem in Items.ToList())
  67.                             {
  68.                                 if (IItem == null)
  69.                                     continue;
  70.                                 using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  71.                                 {
  72.                                     dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
  73.                                     Item = dbClient.getRow();
  74.                                     if (Item == null)
  75.                                         continue;
  76.                                     FurnitureID = Convert.ToInt32(Item[0]);
  77.                                     dbClient.SetQuery("UPDATE `furniture` SET `width` = @NumeroInt WHERE `id` = @id LIMIT 1");
  78.                                     dbClient.AddParameter("NumeroInt", numeroint);
  79.                                     dbClient.AddParameter("id",FurnitureID );
  80.                                     dbClient.RunQuery(); //Correction Requête by Dodone
  81.                                 }
  82.                                 Session.SendWhisper("Item width: " + FurnitureID + " mise à jour (Nouveau width: " + numeroint.ToString() + ")");
  83.                             }
  84.                             PlusEnvironment.GetGame().GetItemManager().Init();
  85.                         }
  86.                         catch (Exception)
  87.                         {
  88.                             Session.SendNotification("Oops! Quelque chose ne va pas! (Entrer un nombre valide)");
  89.                         }
  90.                     }
  91.                     break;
  92.                 case "length":
  93.                     {
  94.                         try
  95.                         {
  96.                             numeroint = Convert.ToInt32(Params[2]);
  97.                             foreach (Item IItem in Items.ToList())
  98.                             {
  99.                                 if (IItem == null)
  100.                                     continue;
  101.                                 using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  102.                                 {
  103.                                     dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
  104.                                     Item = dbClient.getRow();
  105.                                     if (Item == null)
  106.                                         continue;
  107.                                     FurnitureID = Convert.ToInt32(Item[0]);
  108.                                     dbClient.SetQuery("UPDATE `furniture` SET `length` = @NumeroInt WHERE `id` = @id LIMIT 1");
  109.                                     dbClient.AddParameter("NumeroInt", numeroint);
  110.                                     dbClient.AddParameter("id", FurnitureID);
  111.                                     dbClient.RunQuery();//Correction Requête by Dodone
  112.                                 }
  113.                                 Session.SendWhisper("Item length: " + FurnitureID + " mise à jour (Nouveau length: " + numeroint.ToString() + ")");
  114.                             }
  115.                             PlusEnvironment.GetGame().GetItemManager().Init();
  116.                         }
  117.                         catch (Exception)
  118.                         {
  119.                             Session.SendNotification("Oops! Quelque chose ne va pas! (Entrer un nombre valide)");
  120.                         }
  121.                     }
  122.                     break;
  123.                 case "height":
  124.                     {
  125.                         try
  126.                         {
  127.                             numerodouble = Convert.ToDouble(Params[2]);
  128.                             foreach (Item IItem in Items.ToList())
  129.                             {
  130.                                 if (IItem == null)
  131.                                     continue;
  132.                                 using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  133.                                 {
  134.                                     dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
  135.                                     Item = dbClient.getRow();
  136.                                     if (Item == null)
  137.                                         continue;
  138.                                     FurnitureID = Convert.ToInt32(Item[0]);
  139.                                     dbClient.SetQuery("UPDATE `furniture` SET `stack_height` = @NumeroInt WHERE `id` = @id LIMIT 1");
  140.                                     dbClient.AddParameter("NumeroInt", numeroint);
  141.                                     dbClient.AddParameter("id", FurnitureID);
  142.                                     dbClient.RunQuery();//Correction Requête by Dodone
  143.                                 }
  144.                                 Session.SendWhisper("Item height: " + FurnitureID + " mise à jour (Nouveau height: " + numerodouble.ToString() + ")");
  145.                             }
  146.                             PlusEnvironment.GetGame().GetItemManager().Init();
  147.                         }
  148.                         catch (Exception)
  149.                         {
  150.                             Session.SendNotification("Oops! Quelque chose ne va pas! (Entrer un nombre valide)");
  151.                         }
  152.                     }
  153.                     break;
  154.                 case "interactioncount":
  155.                     {
  156.                         try
  157.                         {
  158.                             numeroint = Convert.ToInt32(Params[2]);
  159.                             foreach (Item IItem in Items.ToList())
  160.                             {
  161.                                 if (IItem == null)
  162.                                     continue;
  163.                                 using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  164.                                 {
  165.                                     dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
  166.                                     Item = dbClient.getRow();
  167.                                     if (Item == null)
  168.                                         continue;
  169.                                     FurnitureID = Convert.ToInt32(Item[0]);
  170.                                     dbClient.SetQuery("UPDATE `furniture` SET `interaction_modes_count` = @NumeroInt WHERE `id` = @id LIMIT 1");
  171.                                     dbClient.AddParameter("NumeroInt", numeroint);
  172.                                     dbClient.AddParameter("id", FurnitureID);
  173.                                     dbClient.RunQuery();//Correction Requête by Dodone
  174.                                 }
  175.                                 Session.SendWhisper("Interaction count: " + FurnitureID + " mise à jour (Nouvelle interaction count: " + numeroint.ToString() + ")");
  176.                             }
  177.                             PlusEnvironment.GetGame().GetItemManager().Init();
  178.                         }
  179.                         catch (Exception)
  180.                         {
  181.                             Session.SendNotification("Oops! Quelque chose ne va pas! (Entrer un nombre valide)");
  182.                         }
  183.                     }
  184.                     break;
  185.                 case "cansit":
  186.                     {
  187.                         try
  188.                         {
  189.                             opcion = Params[2].ToLower();
  190.                             if (!opcion.Equals("oui") && !opcion.Equals("non"))
  191.                             {
  192.                                 Session.SendWhisper("Utilisé : oui ou non.)");
  193.                                 return;
  194.                             }
  195.                             if (opcion.Equals("oui"))
  196.                                 opcion = "1";
  197.                             else if (opcion.Equals("non"))
  198.                                 opcion = "0";
  199.                             foreach (Item IItem in Items.ToList())
  200.                             {
  201.                                 if (IItem == null)
  202.                                     continue;
  203.                                 using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  204.                                 {
  205.                                     dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
  206.                                     Item = dbClient.getRow();
  207.                                     if (Item == null)
  208.                                         continue;
  209.                                     FurnitureID = Convert.ToInt32(Item[0]);
  210.                                     dbClient.SetQuery("UPDATE `furniture` SET `can_sit` = @Option WHERE `id` = @id LIMIT 1");
  211.                                     dbClient.AddParameter("Option", opcion);
  212.                                     dbClient.AddParameter("id", FurnitureID);
  213.                                     dbClient.RunQuery();//Correction Requête by Dodone
  214.                                 }
  215.                                 Session.SendWhisper("Item can_sit: " + FurnitureID + " mise à jour");
  216.                             }
  217.                             PlusEnvironment.GetGame().GetItemManager().Init();
  218.                         }
  219.                         catch (Exception)
  220.                         {
  221.                             Session.SendNotification("Oops! Quelque chose ne va pas! (Entrer une valeur)");
  222.                         }
  223.                     }
  224.                     break;
  225.                 case "canstack":
  226.                     {
  227.                         try
  228.                         {
  229.                             opcion = Params[2].ToLower();
  230.                             if (!opcion.Equals("oui") && !opcion.Equals("non"))
  231.                             {
  232.                                 Session.SendWhisper("Utiliser : oui ou non");
  233.                                 return;
  234.                             }
  235.                             if (opcion.Equals("oui"))
  236.                                 opcion = "1";
  237.                             else if (opcion.Equals("non"))
  238.                                 opcion = "0";
  239.                             foreach (Item IItem in Items.ToList())
  240.                             {
  241.                                 if (IItem == null)
  242.                                     continue;
  243.                                 using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  244.                                 {
  245.                                     dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
  246.                                     Item = dbClient.getRow();
  247.                                     if (Item == null)
  248.                                         continue;
  249.                                     FurnitureID = Convert.ToInt32(Item[0]);
  250.                                     dbClient.SetQuery("UPDATE `furniture` SET `can_stack` = @Option WHERE `id` = @id LIMIT 1");
  251.                                     dbClient.AddParameter("Option", opcion);
  252.                                     dbClient.AddParameter("id", FurnitureID);
  253.                                     dbClient.RunQuery();//Correction Requête by Dodone
  254.                                 }
  255.                                 Session.SendWhisper("Item can_stack: " + FurnitureID + " mise à jour");
  256.                             }
  257.                             PlusEnvironment.GetGame().GetItemManager().Init();
  258.                         }
  259.                         catch (Exception)
  260.                         {
  261.                             Session.SendNotification("Oops! Quelque chose ne va pas! (Entrer une valeur)");
  262.                         }
  263.                     }
  264.                     break;
  265.                 case "canwalk":
  266.                     {
  267.                         try
  268.                         {
  269.                             opcion = Params[2].ToLower();
  270.                             if (!opcion.Equals("oui") && !opcion.Equals("non"))
  271.                             {
  272.                                 Session.SendWhisper("Utiliser : oui ou non");
  273.                                 return;
  274.                             }
  275.                             if (opcion.Equals("oui"))
  276.                                 opcion = "1";
  277.                             else if (opcion.Equals("non"))
  278.                                 opcion = "0";
  279.                             foreach (Item IItem in Items.ToList())
  280.                             {
  281.                                 if (IItem == null)
  282.                                     continue;
  283.                                 using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  284.                                 {
  285.                                     dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
  286.                                     Item = dbClient.getRow();
  287.                                     if (Item == null)
  288.                                         continue;
  289.                                     FurnitureID = Convert.ToInt32(Item[0]);
  290.                                     dbClient.SetQuery("UPDATE `furniture` SET `is_walkable` = @Option WHERE `id` = @id LIMIT 1");
  291.                                     dbClient.AddParameter("Option", opcion);
  292.                                     dbClient.AddParameter("id", FurnitureID);
  293.                                     dbClient.RunQuery();//Correction Requête by Dodone
  294.                                 }
  295.                                 Session.SendWhisper("Item can_walk: " + FurnitureID + " mise à jour");
  296.                             }
  297.                             PlusEnvironment.GetGame().GetItemManager().Init();
  298.                         }
  299.                         catch (Exception)
  300.                         {
  301.                             Session.SendNotification("Oops! Quelque chose ne va pas! (Entrer une valeur)");
  302.                         }
  303.                     }
  304.                     break;
  305.                 case "market":
  306.                     {
  307.                         try
  308.                         {
  309.                             opcion = Params[2].ToLower();
  310.                             if (!opcion.Equals("oui") && !opcion.Equals("non"))
  311.                             {
  312.                                 Session.SendWhisper("Utiliser : oui ou non");
  313.                                 return;
  314.                             }
  315.                             if (opcion.Equals("oui"))
  316.                                 opcion = "1";
  317.                             else if (opcion.Equals("non"))
  318.                                 opcion = "0";
  319.                             foreach (Item IItem in Items.ToList())
  320.                             {
  321.                                 if (IItem == null)
  322.                                     continue;
  323.                                 using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  324.                                 {
  325.                                     dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
  326.                                     Item = dbClient.getRow();
  327.                                     if (Item == null)
  328.                                         continue;
  329.                                     FurnitureID = Convert.ToInt32(Item[0]);
  330.                                     dbClient.SetQuery("UPDATE `furniture` SET `is_rare` = @Option WHERE `id` = @id LIMIT 1");
  331.                                     dbClient.AddParameter("Option", opcion);
  332.                                     dbClient.AddParameter("id", FurnitureID);
  333.                                     dbClient.RunQuery();//Correction Requête by Dodone
  334.                                 }
  335.                                 Session.SendWhisper("Market place option: " + FurnitureID + " mise à jour");
  336.                             }
  337.                             PlusEnvironment.GetGame().GetItemManager().Init();
  338.                         }
  339.                         catch (Exception)
  340.                         {
  341.                             Session.SendNotification("Oops! Quelque chose ne va pas! (Entrer une valeur)");
  342.                         }
  343.                     }
  344.                     break;
  345.                 case "interaction":
  346.                     {
  347.                         try
  348.                         {
  349.                             opcion = Params[2].ToLower();
  350.                             foreach (Item IItem in Items.ToList())
  351.                             {
  352.                                 if (IItem == null)
  353.                                     continue;
  354.                                 using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  355.                                 {
  356.                                     dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
  357.                                     Item = dbClient.getRow();
  358.                                     if (Item == null)
  359.                                         continue;
  360.                                     FurnitureID = Convert.ToInt32(Item[0]);
  361.                                     dbClient.SetQuery("UPDATE `furniture` SET `interaction_type` = @Option WHERE `id` = @id LIMIT 1");
  362.                                     dbClient.AddParameter("Option", opcion);
  363.                                     dbClient.AddParameter("id", FurnitureID);
  364.                                     dbClient.RunQuery();//Correction Requête by Dodone
  365.                                 }
  366.                                 Session.SendWhisper("Item interaction: " + FurnitureID + " mise à jour. (Nouvelle interaction: " + opcion + ")");
  367.                             }
  368.                             PlusEnvironment.GetGame().GetItemManager().Init();
  369.                         }
  370.                         catch (Exception)
  371.                         {
  372.                             Session.SendNotification("Oops! Quelque chose ne va pas! (Entrer une valeur)");
  373.                         }
  374.                     }
  375.                     break;
  376.                 default:
  377.                     {
  378.                         Session.SendNotification("Oops! Quelque chose ne va pas! Pour vous aider, taper :item help");
  379.                         return;
  380.                     }
  381.             }
  382.         }
  383.     }
  384. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement