using System; using System.Collections.Generic; using System.Text; using Uber.Storage; using Uber.HabboHotel.Items; using Uber.HabboHotel.GameClients; using Uber.Messages; using Uber.HabboHotel.Rooms; namespace Uber.HabboHotel.Misc { class ChatCommandHandler { public static Boolean Parse(GameClient Session, string Input) { if (Input.Length <= 0 || Input == "") { return false; } string[] Params = Input.Split(' '); string TargetUser = null; GameClient TargetClient = null; Room TargetRoom = null; RoomUser TargetRoomUser = null; switch (Params[0].ToLower()) { #region Debugging/Development case "userinfo": if (!Session.GetHabbo().IsUltraVip) { SendChatMessage(Session, "Buy Ultra VIP to use this command!"); return false; } string Username = null; if ((Username = Params[1]) == null) { SendChatMessage(Session, "The username you've typed in is invalid!"); return true; } TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(Username); if (TargetClient == null) { SendChatMessage(Session,"This user is'nt online!"); return true; } StringBuilder Builderer = new StringBuilder(); Builderer.AppendLine("User details of: " + TargetClient.GetHabbo().Username); Builderer.AppendLine("Credits: " + TargetClient.GetHabbo().Credits); Builderer.AppendLine("Pixels: " + TargetClient.GetHabbo().ActivityPoints); Builderer.AppendLine("Rank: " + TargetClient.GetHabbo().Rank); Builderer.AppendLine("Motto: " + TargetClient.GetHabbo().Motto); Builderer.AppendLine("Respect: " + TargetClient.GetHabbo().Respect); Builderer.AppendLine((TargetClient.GetHabbo().IsUltraVip) ? "Ultra-Vip: true" : "Ultra-Vip: false"); Builderer.AppendLine("Minutes-Online: " + TargetClient.GetHabbo().GetTotalMinutes); Session.SendMotd(Convert.ToString(Builderer)); return true; case "whosonline": if (!Session.GetHabbo().IsUltraVip) { SendChatMessage(Session, "Buy Ultra VIP to use this command!"); return false; } var UserList = UberEnvironment.GetGame().GetClientManager().Clients; var UsersToDisplay = new List(); StringBuilder Builder = new StringBuilder(); Builder.AppendLine("These Users are online:"); for (int i = 0; i < UserList.Count; i++) { GameClient Client = UserList[i]; if (Client == null) { continue; } UsersToDisplay.Add(Client.GetHabbo().Username); } for (int i = 0; i < UsersToDisplay.Count; i++) { Builder.AppendLine((UsersToDisplay[i] != null) ? "- " + UsersToDisplay[i] : "- Empty username."); } Session.SendMotd(Convert.ToString(Builder)); return true; case "addbadge": { string Badge = ""; try { Badge = Params[1]; } catch { return false; } if (Session.GetHabbo().Rank <= 1 || Badge == "" || Badge.Length < 3) { return false; } Session.GetHabbo().GetBadgeComponent().GiveBadge(Badge, true); SendChatMessage(Session, "Badge given: " + Badge); return true; } case "brb": { if (!Session.GetHabbo().IsUltraVip) { SendChatMessage(Session, "Buy Ultra VIP to use this command!"); return false; } TargetRoom = Session.GetHabbo().CurrentRoom; TargetRoomUser = TargetRoom.GetRoomUserByHabbo(Session.GetHabbo().Username); if (TargetRoom == null || TargetRoomUser == null) { return false; } if (!Session.GetHabbo().IsBRB) { Session.GetHabbo().IsBRB = true; TargetRoom.ApplyUserEffect(TargetRoomUser, 10, true); ReloadRoomUser(TargetRoomUser, TargetRoom, Session, true); SendChatMessage(Session, "You're now BRB, enjoy it!"); } else if (Session.GetHabbo().IsBRB) { Session.GetHabbo().IsBRB = false; TargetRoom.ApplyUserEffect(TargetRoomUser, 0, true); ReloadRoomUser(TargetRoomUser, TargetRoom, Session, false); SendChatMessage(Session, "You're now back, enjoy it!"); } return true; } case "update_quests": if (Session.GetHabbo().HasFuse("fuse_admin")) { UberEnvironment.GetGame().GetQuestManager().InitQuests(); return true; } return false; case "update_inventory": if (Session.GetHabbo().HasFuse("fuse_admin")) { Session.GetHabbo().GetInventoryComponent().UpdateItems(true); return true; } return false; case "update_bots": if (Session.GetHabbo().HasFuse("fuse_admin")) { UberEnvironment.GetGame().GetBotManager().LoadBots(); return true; } return false; case "update_catalog": if (Session.GetHabbo().HasFuse("fuse_admin")) { UberEnvironment.GetGame().GetCatalog().Initialize(); UberEnvironment.GetGame().GetClientManager().BroadcastMessage(new ServerMessage(441)); return true; } return false; case "update_config": if (Session.GetHabbo().HasFuse("fuse_admin")) { UberEnvironment.GetGame().GetGameConfiguration().UpdateConfig(); Session.SendNotif("Configuration has been reloaded."); return true; } return false; case "update_navigator": if (Session.GetHabbo().HasFuse("fuse_admin")) { UberEnvironment.GetGame().GetNavigator().Initialize(); Session.SendNotif("Navigator has been updated."); return true; } return false; case "t": if (Session.GetHabbo().HasFuse("fuse_admin")) { TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (TargetRoom == null) { return false; } TargetRoomUser = TargetRoom.GetRoomUserByHabbo(Session.GetHabbo().Id); if (TargetRoomUser == null) { return false; } Session.SendNotif("X: " + TargetRoomUser.X + " - Y: " + TargetRoomUser.Y + " - Z: " + TargetRoomUser.Z + " - Rot: " + TargetRoomUser.RotBody); return true; } return false; case "override": if (Session.GetHabbo().HasFuse("fuse_mod")) { TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (TargetRoom == null) { return false; } TargetRoomUser = TargetRoom.GetRoomUserByHabbo(Session.GetHabbo().Id); if (TargetRoomUser == null) { return false; } if (TargetRoomUser.AllowOverride) { TargetRoomUser.AllowOverride = false; SendChatMessage(Session, "Walking override has been disabled."); } else { TargetRoomUser.AllowOverride = true; SendChatMessage(Session, "Walking override has been enabled."); } return true; } return false; case "update_defs": if (Session.GetHabbo().HasFuse("fuse_admin")) { UberEnvironment.GetGame().GetItemManager().LoadItems(); Session.SendNotif("Item defenitions reloaded successfully."); return true; } return false; case "blockfriends": if (!Session.GetHabbo().IsUltraVip) { SendChatMessage(Session, "Buy Ultra VIP to use this command!"); return false; } using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { if (Session.GetHabbo().BlockNewFriends) { dbClient.ExecuteQuery("UPDATE users SET block_newfriends = '0' WHERE id = '" + Session.GetHabbo().Id + "' LIMIT 1"); Session.GetHabbo().BlockNewFriends = false; SendChatMessage(Session, "Your friend requests has been enabled."); } else { dbClient.ExecuteQuery("UPDATE users SET block_newfriends = '1' WHERE id = '" + Session.GetHabbo().Id + "' LIMIT 1"); Session.GetHabbo().BlockNewFriends = true; SendChatMessage(Session, "Your friend requests has been disabled."); } } return true; case "setmax": if (Session.GetHabbo().HasFuse("fuse_admin")) { TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (TargetRoom != null) { int usersMax; if (int.TryParse(Params[1], out usersMax)) { TargetRoom.UsersMax = usersMax; SendChatMessage(Session, "Room limit has been set to: " + usersMax); return true; } } } return false; #endregion #region General Commands case "pickall": TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (TargetRoom != null && TargetRoom.CheckRights(Session, true)) { var ToRemove = new List(); ToRemove.AddRange(TargetRoom.Items); foreach (RoomItem Item in ToRemove) { TargetRoom.RemoveFurniture(Session, Item.Id, false); Session.GetHabbo().GetInventoryComponent().AddItem(Item.Id, Item.BaseItem, Item.ExtraData, false); } Session.GetHabbo().GetInventoryComponent().UpdateItems(true); return true; } return false; case "unload": TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (TargetRoom != null && TargetRoom.CheckRights(Session, true)) { UberEnvironment.GetGame().GetRoomManager().UnloadRoom(TargetRoom.RoomId); return true; } return false; case "moonwalk": if (!Session.GetHabbo().IsUltraVip) { SendChatMessage(Session, "Buy Ultra VIP to use this command!"); return false; } TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (TargetRoom == null) { return false; } TargetRoomUser = TargetRoom.GetRoomUserByHabbo(Session.GetHabbo().Id); if (TargetRoomUser == null) { return false; } if (TargetRoomUser.WalkBackwards) { TargetRoomUser.WalkBackwards = false; SendChatMessage(Session, "You will now walk normally."); } else { TargetRoomUser.WalkBackwards = true; SendChatMessage(Session, "You will now walk backwards."); } return true; case "teleport": if (Session.GetHabbo().HasFuse("fuse_admin")) { TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (TargetRoom == null) { return false; } TargetRoomUser = TargetRoom.GetRoomUserByHabbo(Session.GetHabbo().Id); if (TargetRoomUser == null) { return false; } if (TargetRoomUser.TeleportMode) { TargetRoomUser.TeleportMode = false; SendChatMessage(Session, "Teleport mode disabled."); } else { TargetRoomUser.TeleportMode = true; SendChatMessage(Session, "Teleport mode enabled."); } return true; } return false; case "uptime": if (!Session.GetHabbo().IsUltraVip) { SendChatMessage(Session, "Buy Ultra VIP to use this command!"); return false; } DateTime Now = DateTime.Now; TimeSpan TimeUsed = Now - UberEnvironment.ServerStarted; Session.SendNotif("Server is running for: " + TimeUsed.Days + " day(s), " + TimeUsed.Hours + " hour(s) and " + TimeUsed.Minutes + " minute(s)"); return true; case "info": case "details": case "about": Session.SendNotif("This server is proudly powered by uberEmulator.\nCopyright (c) 2009, Roy 'Meth0d'\n\nhttp://www.meth0d.org", "http://www.meth0d.org/uber/"); return true; case "empty": if (!Session.GetHabbo().IsUltraVip) { SendChatMessage(Session, "Buy Ultra VIP to use this command!"); return false; } Session.GetHabbo().GetInventoryComponent().ClearItems(); SendChatMessage(Session, "Your inventory items has been emptied."); return true; case "emptypets": if (!Session.GetHabbo().IsUltraVip) { SendChatMessage(Session, "Buy Ultra VIP to use this command!"); return false; } Session.GetHabbo().GetInventoryComponent().ClearPets(); SendChatMessage(Session, "Your pets from your inventory have been deleted."); return true; #endregion #region Moderation Commands case "muteroom": { if (Session.GetHabbo().HasFuse("fuse_mod")) { Room Room = Session.GetHabbo().CurrentRoom; if (Room != null) { if (!Room.IsMuted) { Room.IsMuted = true; Session.SendNotif("Room Muted"); } else if (Room.IsMuted) { Room.IsMuted = false; Session.SendNotif("Room unMuted"); } } return true; } } return false; case "invisible": if (Session.GetHabbo().HasFuse("fuse_mod")) { if (Session.GetHabbo().SpectatorMode) { Session.GetHabbo().SpectatorMode = false; Session.SendNotif("Spectator mode disabled. Reload the room to apply changes."); } else { Session.GetHabbo().SpectatorMode = true; Session.SendNotif("Spectator mode enabled. Reload the room to apply changes."); } return true; } return false; case "appearoffline": if (Session.GetHabbo().HasFuse("fuse_mod")) { if (Session.GetHabbo().GetMessenger().AppearOffline) { Session.GetHabbo().GetMessenger().AppearOffline = false; Session.GetHabbo().GetMessenger().OnStatusChanged(true); Session.SendNotif("You are now back online to everyone on messenger."); } else { Session.GetHabbo().GetMessenger().AppearOffline = true; Session.GetHabbo().GetMessenger().OnStatusChanged(true); Session.SendNotif("You are now temporarily appear offline to everyone on messenger."); } return true; } return false; case "unloadid": if (Session.GetHabbo().HasFuse("fuse_admin")) { uint RoomId; if (uint.TryParse(Params[1], out RoomId)) { if (UberEnvironment.GetGame().GetRoomManager().IsRoomLoaded(RoomId)) { UberEnvironment.GetGame().GetRoomManager().UnloadRoom(RoomId); return true; } else { Session.SendNotif("This room is not loaded, unable to unload."); return true; } } return false; } return false; case "ha": if (Session.GetHabbo().HasFuse("fuse_mod")) { string Notice = Input.Substring(3); ServerMessage HotelAlert = new ServerMessage(139); HotelAlert.AppendStringWithBreak("Message from Hotel Management:\r\n" + Notice + "\r\n- " + Session.GetHabbo().Username); UberEnvironment.GetGame().GetClientManager().BroadcastMessage(HotelAlert); SendChatMessage(Session, "You sent out a hotel alert, abuse of this command will result in punishment!"); return true; } return false; case "msgstaff": if (Session.GetHabbo().HasFuse("fuse_mod")) { string Notice = Input.Substring(3); ServerMessage StaffMessage = new ServerMessage(139); StaffMessage.AppendStringWithBreak("Message from Staff User: " + Session.GetHabbo().Username + "\r\n" + Notice); UberEnvironment.GetGame().GetClientManager().BroadcastMessage(StaffMessage, "fuse_mod"); return true; } return false; case "credits": if (Session.GetHabbo().HasFuse("fuse_sysadmin")) { TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(Params[1]); if (TargetClient != null) { int creditsToAdd; if (int.TryParse(Params[2], out creditsToAdd)) { if (creditsToAdd > 5000 || Session.GetHabbo().Credits >= 25000) { Session.SendNotif("You cannot add that amount of credits to your account!"); return true; } TargetClient.GetHabbo().Credits = TargetClient.GetHabbo().Credits + creditsToAdd; TargetClient.GetHabbo().UpdateCreditsBalance(true); TargetClient.SendNotif(Session.GetHabbo().Username + " has awarded you " + creditsToAdd.ToString() + " credits!"); Session.SendNotif("Credit balance updated successfully."); return true; } else { Session.SendNotif("Please enter a valid amount of credits."); return true; } } else { Session.SendNotif("User could not be found."); return true; } } return false; case "pixels": if (Session.GetHabbo().HasFuse("fuse_sysadmin")) { TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(Params[1]); if (TargetClient != null) { int creditsToAdd; if (int.TryParse(Params[2], out creditsToAdd)) { if (creditsToAdd > 5000 || Session.GetHabbo().ActivityPoints >= 25000) { Session.SendNotif("You cannot add that amount of pixels to your account!"); return true; } TargetClient.GetHabbo().ActivityPoints = TargetClient.GetHabbo().ActivityPoints + creditsToAdd; TargetClient.GetHabbo().UpdateActivityPointsBalance(true); TargetClient.SendNotif(Session.GetHabbo().Username + " has awarded you " + creditsToAdd.ToString() + " pixels!"); Session.SendNotif("Pixel balance updated successfully."); return true; } else { Session.SendNotif("Please enter a valid amount of pixels."); return true; } } else { Session.SendNotif("User could not be not found."); return true; } } return false; case "ban": if (Session.GetHabbo().HasFuse("fuse_ban")) { TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(Params[1]); if (TargetClient == null) { Session.SendNotif("User not found."); return true; } if (TargetClient.GetHabbo().Rank >= Session.GetHabbo().Rank) { Session.SendNotif("You are not allowed to ban that user."); return true; } int BanTime = 0; try { BanTime = int.Parse(Params[2]); } catch (FormatException) { } if (BanTime <= 600) { Session.SendNotif("Ban time is in seconds and must be at least than 600 seconds (ten minutes). For more specific preset ban times, use the mod tool."); } UberEnvironment.GetGame().GetBanManager().BanUser(TargetClient, Session.GetHabbo().Username, BanTime, MergeParams(Params, 3), false); return true; } return false; case "superban": if (Session.GetHabbo().HasFuse("fuse_superban")) { TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(Params[1]); if (TargetClient == null) { Session.SendNotif("User not found."); return true; } if (TargetClient.GetHabbo().Rank >= Session.GetHabbo().Rank) { Session.SendNotif("You are not allowed to ban that user."); return true; } UberEnvironment.GetGame().GetBanManager().BanUser(TargetClient, Session.GetHabbo().Username, 360000000, MergeParams(Params, 2), false); return true; } return false; case "roomkick": if (Session.GetHabbo().HasFuse("fuse_roomkick")) { TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (TargetRoom == null) { return false; } bool GenericMsg = true; string ModMsg = MergeParams(Params, 1); if (ModMsg.Length > 0) { GenericMsg = false; } var UsersToKick = new List(); foreach (RoomUser RoomUser in TargetRoom.UserList) { if (RoomUser.GetClient().GetHabbo().Rank >= Session.GetHabbo().Rank) { continue; } if (!GenericMsg) { RoomUser.GetClient().SendNotif("You have been kicked by an moderator: " + ModMsg); } UsersToKick.Add(RoomUser); } foreach (RoomUser RoomUser in UsersToKick) { TargetRoom.RemoveUserFromRoom(RoomUser.GetClient(), true, GenericMsg); } return true; } return false; case "roomalert": if (Session.GetHabbo().HasFuse("fuse_roomalert")) { TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (TargetRoom == null) { return false; } string Msg = MergeParams(Params, 1); foreach (RoomUser RoomUser in TargetRoom.UserList) { RoomUser.GetClient().SendNotif(Msg); } return true; } return false; case "mute": if (Session.GetHabbo().HasFuse("fuse_mute")) { TargetUser = Params[1]; TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(TargetUser); if (TargetClient == null || TargetClient.GetHabbo() == null) { Session.SendNotif("Could not find user: " + TargetUser); return true; } if (TargetClient.GetHabbo().Rank >= Session.GetHabbo().Rank) { Session.SendNotif("You are not allowed to (un)mute that user."); return true; } TargetClient.GetHabbo().Mute(); return true; } return false; case "unmute": if (Session.GetHabbo().HasFuse("fuse_mute")) { TargetUser = Params[1]; TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(TargetUser); if (TargetClient == null || TargetClient.GetHabbo() == null) { Session.SendNotif("Could not find user: " + TargetUser); return true; } if (TargetClient.GetHabbo().Rank >= Session.GetHabbo().Rank) { Session.SendNotif("You are not allowed to (un)mute that user."); return true; } TargetClient.GetHabbo().Unmute(); return true; } return false; case "alert": if (Session.GetHabbo().HasFuse("fuse_alert")) { TargetUser = Params[1]; TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(TargetUser); if (TargetClient == null) { Session.SendNotif("Could not find user: " + TargetUser); return true; } TargetClient.SendNotif(MergeParams(Params, 2), Session.GetHabbo().HasFuse("fuse_admin")); return true; } return false; case "softkick": case "kick": if (Session.GetHabbo().HasFuse("fuse_kick")) { TargetUser = Params[1]; TargetClient = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(TargetUser); if (TargetClient == null) { Session.SendNotif("Could not find user: " + TargetUser); return true; } if (Session.GetHabbo().Rank <= TargetClient.GetHabbo().Rank) { Session.SendNotif("You are not allowed to kick that user."); return true; } if (TargetClient.GetHabbo().CurrentRoomId < 1) { Session.SendNotif("That user is not in a room and can not be kicked."); return true; } TargetRoom = UberEnvironment.GetGame().GetRoomManager().GetRoom(TargetClient.GetHabbo().CurrentRoomId); if (TargetRoom == null) { return true; } TargetRoom.RemoveUserFromRoom(TargetClient, true, false); if (Params.Length > 2) { TargetClient.SendNotif("A moderator has kicked you from the room for the following reason: " + MergeParams(Params, 2)); } else { TargetClient.SendNotif("A moderator has kicked you from the room."); } return true; } return false; #endregion } return false; } public static string MergeParams(string[] Params, int Start) { StringBuilder MergedParams = new StringBuilder(); for (int i = 0; i < Params.Length; i++) { if (i < Start) { continue; } if (i > Start) { MergedParams.Append(" "); } MergedParams.Append(Params[i]); } return MergedParams.ToString(); } public static void SendChatMessage(GameClient Session, string Message) { ServerMessage TellMsg = new ServerMessage(); TellMsg.Init(25); TellMsg.AppendInt32(Session.GetHabbo().CurrentRoom.GetRoomUserByHabbo(Session.GetHabbo().Username).VirtualId); TellMsg.AppendStringWithBreak(Message); TellMsg.AppendBoolean(false); Session.GetConnection().SendMessage(TellMsg); } public static void ReloadRoomUser(RoomUser User, Room Room, GameClient Session, Boolean BRB) { if (User == null || Room == null || Session == null) { return; } ServerMessage RoomUpdate = new ServerMessage(266); RoomUpdate.AppendInt32(User.VirtualId); RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Look); RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Gender.ToLower()); RoomUpdate.AppendStringWithBreak((BRB) ? "BRB - " + Session.GetHabbo().Motto : Session.GetHabbo().Motto); RoomUpdate.AppendInt32(Session.GetHabbo().GetAchievementScore()); Room.SendMessage(RoomUpdate); } } }