using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Reflection; using Blizzard.Connections; using Blizzard.HabboHotel.Catalog; using Blizzard.HabboHotel.Rooms; namespace Blizzard.HabboHotel.Users { public class Commands { private Habbo User; private string MyCommand; internal Commands(Habbo cUser, string Command) { this.User = cUser; this.MyCommand = Command; } internal void ProcessCommands() { string mCommand = this.MyCommand.Substring(1); string[] Command = mCommand.Split(' '); try { // staff commands if (User.Rank >= 4) { switch (Command[0]) { #region Staff Commands // Owner Commands case "update_catalog": case "resetcatalog": if (User.Rank == 9) { CatalogData.InitCatalogPages(); CatalogItemData.InitCatalogItems(); foreach (KeyValuePair VirtualUser in StaticGame.VirtualUser) { int UserId = VirtualUser.Key; Habbo MyUser = VirtualUser.Value; ServerMessage SendAlert = new ServerMessage("Fy"); MyUser.SendMessage(SendAlert); } } break; case "update_furniture": case "resetfurniture": if (User.Rank == 9) { ItemsData.InitItems(); foreach (KeyValuePair VirtualUser in StaticGame.VirtualUser) { int UserId = VirtualUser.Key; Habbo MyUser = VirtualUser.Value; MyUser.SendAlert("Los muebles han sido actualizados, ¡reinicia tu sala!", 0); } } break; case "update_quests": if (User.Rank == 9) { QuestData.InitQuests(); foreach (KeyValuePair VirtualUser in StaticGame.VirtualUser) { int UserId = VirtualUser.Key; Habbo MyUser = VirtualUser.Value; MyUser.SerializeQuests(); } } break; // Admin Commands case "invisible": if (User.Rank >= 7) { string State = Command[1]; if (State == "on") { } else if(State == "off") { } else { User.SendAlert("Solo puedes introducir 'on' u 'off', no hay más parámetros", 1); } } break; // Expert mod commands case "givebadge": if (User.Rank >= 6) { int UserId = int.Parse(Command[1]); string BadgeId = Command[2]; Habbo cUser = StaticGame.VirtualUser[UserId]; cUser.SendAlert(User.UserName + " te ha enviado una placa: " + BadgeId + ", ¡disfrútala!", 2); cUser.GiveBadge(BadgeId); cUser.SerializeBadges(); } break; case "givebadgetouser": if (User.Rank >= 6) { string UserName = Command[1]; UsersData UData = UsersData.GetDataFromName(UserName); int UserId = UData.Id; string BadgeId = Command[2]; Habbo cUser = StaticGame.VirtualUser[UserId]; cUser.SendAlert(User.UserName + " te ha enviado una placa: " + BadgeId + ", ¡disfrútala!", 2); cUser.GiveBadge(BadgeId); cUser.SerializeBadges(); } break; case "userdata": if (User.Rank >= 6) { string UserName = Command[1]; UsersData UData = UsersData.GetDataFromName(UserName); string Data = "Información de Usuarios; "; if (UData != null) { Data += UserName + " (ID - " + UData.Id + ")\r\r" + "Rango: " + UData.RankName + "\r" + "Nombre Real (FB): " + UData.RealName + "\r" + "Misión: " + UData.Motto + "\r" + "Última vez Conectado/a: " + UData.LastAccess + "\r" + "Creditos / Pixeles / Recompensas:\r " + UData.Credits + " / " + UData.Pixels + " / " + UData.AchievementPoints; } else Data += "El usuario que buscas no existe"; User.SendAlert(Data, 2); } break; case "ha": case "hotelalert": if (User.Rank >= 6) { string GeneralAlert = "Alerta General (Por: " + User.UserName + "): \r"; Int32 mType = 0; string Message = BlizzardSystem.MergeParams(Command, 2); if (int.TryParse(Command[1], out mType) || mType.ToString() == "" || mType >= 2) { foreach (KeyValuePair VirtualUser in StaticGame.VirtualUser) { int UserId = VirtualUser.Key; Habbo MyUser = VirtualUser.Value; MyUser.SendAlert(Message, mType); } } else { User.SendAlert("Tipos: \r0 = Mensaje a Salas (Alerta Larga)\r1 = Mensaje de Aviso (Alerta Larga)\r2 = Alerta\r3 = Alerta MOD", 2); } } break; // Try mod commands case "whosonline": if (User.Rank >= 4) { string UsersOnLine = "Usuarios Conectados (" + StaticGame.VirtualUser.Count + "): \r"; foreach (KeyValuePair VirtualUser in StaticGame.VirtualUser) { int UserId = VirtualUser.Key; Habbo MyUser = VirtualUser.Value; UsersOnLine += MyUser.UserName + "\r"; } User.SendAlert(UsersOnLine, 0); } break; case "drink": if (User.Rank >= 2) { int DrinkId = int.Parse(Command[1]); User.CarryItem(DrinkId); } break; case "effect": if (User.Rank >= 2) { int EffectId = int.Parse(Command[1]); EffectsInventory Eff = new EffectsInventory(); Eff.ShowEffect(User, EffectId); } break; case "teleport": if (User.Rank >= 4) { string State = Command[1]; if (State.ToLower() == "on") { User.IsTeleportOn = true; } else if (State.ToLower() == "off") { User.IsTeleportOn = false; } else { User.IsTeleportOn = false; } } break; case "moonwalk": if (User.Rank >= 4) { string State = Command[1]; if (State.ToLower() == "on") { User.IsMoonWalking = true; } else if (State.ToLower() == "off") { User.IsMoonWalking = false; } else { User.IsMoonWalking = false; } } break; case "move": if (User.Rank >= 4) { int X = int.Parse(Command[1]); int Y = int.Parse(Command[2]); Room Room = StaticGame.VirtualRooms[User.CurrentRoomId]; string UserZ = Room.SecondGetHForXY(X, Y).ToString().Replace(',', '.'); if (!UserZ.Contains(".")) UserZ += ".0"; User.SetPos(X, Y, UserZ); } break; #endregion } } // normal commands switch (Command[0]) { case "commands": case "comandos": string Commands = ""; if (User.Rank == 9) { Commands += ":update_catalog - Actualiza el catálogo\n" + ":update_quests - Actualiza los retos\n" + ":update_furniture - Actualiza los muebles\n"; } if (User.Rank >= 7) { Commands += ":invisible - Te hace invisible\n"; } if(User.Rank >= 6) { Commands += ":givebadge - Le da la placa al usuario con la id \n" + ":givebadgetouser - Igual :givebadge pero con \n" + ":userdata - Información sobre \n" + ":ha - Envia a todos los usuarios (solo :ha para ver tipos)\n"; } if (User.Rank >= 4) { Commands += ":whosonline - Usuarios conectados\n" + ":teleport - Activa la función del teletransporte\n" + ":moonwalk - Caminas hacia la luna\n" + ":move - Te coloca en e \n"; } if (User.Rank >= 2) { Commands += ":effect - Da el Efecto [Comando VIP]\n" + ":drink - Da la bebida [Comando VIP]\n"; } Commands += ":staffsonline - Muestra los Staffs Conectados\n" + ":about - Información del Emulador\n" + ":info - Información breve del emulador\n"; User.SendAlert("Comandos:\n\n" + Commands, 1); break; case "about": string Information = "Información del Servidor:\n"; Information += "Blizzard Emulator v" + Assembly.GetExecutingAssembly().GetName().Version + " diseñado por Itachi\n" + "(# Más información http://blizzardemulator.es #)\n\n"; DateTime Now = DateTime.Now; TimeSpan TimeUsed = Now - BlizzardSystem.ServerStarted; Information += "SERVIDOR\n" + "El servidor lleva en línea " + TimeUsed.Days + " día(s), " + TimeUsed.Hours + " hora(s) y " + TimeUsed.Minutes + " minuto(s)\n" + "Hay " + BlizzardSystem.ActualConnections + " usuarios conectados / bajo 1 TCP Manager\n" + "El ID de tu sesión es #" + User.SessionId + "\n\n"; int usedRAM = (Convert.ToInt32(GC.GetTotalMemory(false)) / 1024) / 1024; Information += "SISTEMA\n" + "RAM en uso: " + usedRAM + "MB\n" + "Sistema Operativo: " + BlizzardSystem.SO() + "\n\n"; Information += "THREADS\n" + "Usuarios: " + StaticGame.TheardSystem.Count + "\n" + "Salas: " + StaticGame.RoomCycles.Count + "\n" + "Contadores: " + StaticGame.CounterSystem.Count + "\n" + "Freeze: " + (StaticGame.FreezeShieldsSystem.Count + StaticGame.FreezeSystem.Count + StaticGame.FreezeToGetSystem.Count + StaticGame.FreezeWaitSystem.Count + StaticGame.FreezeMoveSystem.Count).ToString() + "\n" + "Wired: " + (StaticGame.WiredMoveSystem.Count + StaticGame.WiredMoveItemsSystem.Count + StaticGame.WiredUpdateItemsSystem.Count + StaticGame.WiredPeriodicallySystem.Count).ToString() + "\n" + "\n"; User.SendAlert(Information, 1); break; case "staffsonline": List Staffs = new List(); foreach (KeyValuePair u in StaticGame.VirtualUser) { Habbo qUser = u.Value; if (qUser.Rank >= 4) Staffs.Add(qUser); else continue; } string StaffList = "Staffs Conectados:\n\n"; if (Staffs.Count > 0) { foreach (Habbo q in Staffs) StaffList += "- " + q.UserName + " (" + (UsersData.UsersRegister[q.Id]).RankName + ")\n"; } else StaffList += "Ningún Staff está conectado en este momento."; User.SendAlert(StaffList, 1); break; } } catch { } } internal bool ThereIsACommand(string Message) { string lCommand = Message.Substring(1); string[] sCommand = lCommand.Split(' '); string mCommand = sCommand[0]; if (mCommand == "commands" || mCommand == "info" || mCommand == "about" || mCommand == "staffsonline" || mCommand == "comandos" || mCommand == "userdata" && User.Rank >= 6 || mCommand == "invisible" && User.Rank >= 7 || mCommand == "whosonline" && User.Rank >= 4 || mCommand == "ha" && User.Rank >= 6 || mCommand == "hotelalert" && User.Rank >= 5 || mCommand == "teleport" && User.Rank >= 4 || mCommand == "move" && User.Rank >= 4 || mCommand == "update_quests" && User.Rank == 9 || mCommand == "update_catalog" && User.Rank == 9 || mCommand == "evolvetopet" && User.Rank == 9 || mCommand == "clone" && User.Rank == 9 || mCommand == "effect" && User.Rank >= 2 || mCommand == "givebadge" && User.Rank >= 6 || mCommand == "givebadgetouser" && User.Rank >= 6 || mCommand == "moonwalk" && User.Rank >= 4 || mCommand == "update_furniture" && User.Rank == 9 || mCommand == "resetfurniture" && User.Rank == 9 || mCommand == "drink" && User.Rank >= 2) return true; else if (StaticGame.Command.ContainsKey(mCommand)) return true; else return false; } } }