using System; using System.Collections.Generic; using System.Linq; using System.Text; using Blizzard.Connections; namespace Blizzard.HabboHotel.Users { class HabboConsole { internal Habbo User; internal HabboConsole(Habbo cUser) { User = cUser; } #region Init the Console internal void InitConsole() { try { FriendsData F = FriendsData.AllFriends[User.Id]; BuildMessage ConsoleBuiler = new BuildMessage(); ServerMessage ConsoleR = new ServerMessage("@L"); ConsoleR.AddInt(900); // Max Friends (must be db..?) ConsoleR.AddInt(200); // Normal ConsoleR.AddInt(500); // HC ConsoleR.AddInt(900); // VIP ConsoleR.AddInt(F.Categorys.Count); if (F.Categorys.Count > 0) { foreach (KeyValuePair Category in F.Categorys) { ConsoleR.AddInt(Category.Key); ConsoleR.AddStringWithBreak(Category.Value); } } ConsoleR.AddInt(F.Friends.Count); // Count friends // Add Friends if (F.Friends.Count > 0) { foreach (KeyValuePair Friend in F.Friends) { // Append all friends try { int FriendID = Friend.Key; int CategoryID = Friend.Value; UsersData DUser = UsersData.UsersRegister[FriendID]; Habbo zUser = null; if (DUser.IsOnline) zUser = StaticGame.VirtualUser[FriendID]; ConsoleR.AddInt(FriendID); // Id ConsoleR.AddStringWithBreak(DUser.UserName); // Name ConsoleR.AddBoolean(true); // ? ConsoleR.AddBoolean(DUser.IsOnline); // Is Online? if (zUser != null) ConsoleR.AddBoolean(zUser.IsOnRoom); // is in Room? else ConsoleR.AddBoolean(false); ConsoleR.AddStringWithBreak(DUser.Look); // Look ConsoleR.AddInt(CategoryID); // Category ID ConsoleR.AddStringWithBreak(DUser.Motto); // Motto ConsoleR.AddStringWithBreak(DUser.LastAccess); // Last time online ConsoleR.AddStringWithBreak(DUser.RealName); ConsoleR.AddChar(2); } catch (Exception e) { BlizzardSystem.WriteLine("Console Error: " + e.ToString()); } } } ConsoleBuiler.AddPacket(ConsoleR); ServerMessage Requests = new ServerMessage("Dz"); Requests.AddInt(F.Request.Count); Requests.AddInt(F.Request.Count); foreach (KeyValuePair sRequest in F.Request) { int RequestId = sRequest.Key; UsersData RequestedUser = UsersData.UsersRegister[RequestId]; Requests.AddInt(RequestedUser.Id); Requests.AddStringWithBreak(RequestedUser.UserName); Requests.AddStringWithBreak(RequestedUser.Id.ToString()); } ConsoleBuiler.AddPacket(Requests); User.SendBuilder(ConsoleBuiler); } catch { } } internal void FollowFriend() { int FollowId = User.ActualClientMessage.GetNextInt(); Habbo cUser = StaticGame.VirtualUser[FollowId]; if (cUser.IsOnRoom) { RoomsData cRoom = RoomsData.Rooms[cUser.CurrentRoomId]; if (cRoom == null) return; ServerMessage GoToRoom = new ServerMessage("@{"); GoToRoom.AddInt(cRoom.Id); GoToRoom.AddStringWithBreak(cRoom.Name); User.SendMessage(GoToRoom); } } #endregion #region Requests internal void SendRequest() { FriendsData F = FriendsData.AllFriends[User.Id]; string Separe = User.ActualPacket; string[] String1 = Separe.Split('@'); string Username = BlizzardSystem.MergeParams(String1, 2).Substring(1); ServerMessage NewRequest = new ServerMessage("BD"); UsersData FriendData = null; foreach (UsersData Us in UsersData.UsersRegistered) { if(Us.UserName.Contains(Username)) FriendData = Us; } if (FriendData == null) return; NewRequest.AddInt(User.Id); NewRequest.AddStringWithBreak(User.UserName); NewRequest.AddStringWithBreak(User.Id.ToString()); // Send if the user is online! if (StaticGame.VirtualUser.ContainsKey(FriendData.Id)) { Habbo fUser = StaticGame.VirtualUser[FriendData.Id]; fUser.SendMessage(NewRequest); } Updater.SQLStoExecute.Add("INSERT INTO users_friends (userid, friendid, categoryid, is_request) VALUES (" + User.Id + ", " + FriendData.Id + ", 0, '1');"); // Add a unrequested friend Updater.SQLStoExecute.Add("INSERT INTO users_friends (userid, friendid, categoryid, is_request) VALUES (" + FriendData.Id + ", " + User.Id + ", 0, '1');"); // Add a unrequested friend } internal void AcceptFriend() { FriendsData F = FriendsData.AllFriends[User.Id]; string Separe = User.ActualPacket; int ID = HabboEncode.decodeVL64(Separe.Substring(3)); Updater.SQLStoExecute.Add("UPDATE users_friends SET is_request = '0' WHERE userid = '" + User.Id + "' AND friendid = '" + ID + "' LIMIT 1;"); Updater.SQLStoExecute.Add("UPDATE users_friends SET is_request = '0' WHERE userid = '" + ID + "' AND friendid = '" + User.Id + "' LIMIT 1;"); this.AddFriend(ID); // Update the console online! :D } internal void DeleteFriend() { FriendsData F = FriendsData.AllFriends[User.Id]; string Separe = User.ActualPacket; int ID = HabboEncode.decodeVL64(Separe.Substring(4)); Updater.SQLStoExecute.Add("REMOVE FROM users_friends WHERE userid = '" + User.Id + "' AND friendid = '" + ID + "' LIMIT 1;"); Updater.SQLStoExecute.Add("REMOVE FROM users_friends WHERE userid = '" + ID + "' AND friendid = '" + User.Id + "' LIMIT 1;"); } internal void AddFriend(int Id) { if (StaticGame.VirtualUser.ContainsKey(Id)) { #region Send Message to He Habbo sUser = StaticGame.VirtualUser[Id]; FriendsData F = FriendsData.AllFriends[Id]; if (!F.Friends.ContainsKey(User.Id)) { F.Friends.Add(User.Id, 0); } ServerMessage AddFriend = new ServerMessage("@M"); AddFriend.AddInt(F.Categorys.Count); if (F.Categorys.Count > 0) { foreach (KeyValuePair Category in F.Categorys) { AddFriend.AddInt(Category.Key); AddFriend.AddStringWithBreak(Category.Value); } } // Add Now the new user UsersData MyData = UsersData.UsersRegister[User.Id]; AddFriend.AddInt(1); AddFriend.AddInt(0); // Process this NOW! AddFriend.AddInt(MyData.Id); AddFriend.AddStringWithBreak(MyData.UserName); AddFriend.AddBoolean(true); AddFriend.AddBoolean(MyData.IsOnline); AddFriend.AddBoolean(User.IsOnRoom); AddFriend.AddStringWithBreak(MyData.Look); AddFriend.AddInt(0); AddFriend.AddStringWithBreak(MyData.Motto); AddFriend.AddStringWithBreak(MyData.LastAccess); AddFriend.AddStringWithBreak(MyData.RealName); // Facebook Name AddFriend.AddBoolean(false); sUser.SendMessage(AddFriend); #endregion #region He sends to me FriendsData S = FriendsData.AllFriends[User.Id]; ServerMessage sAddFriend = new ServerMessage("@M"); sAddFriend.AddInt(S.Categorys.Count); if (S.Categorys.Count > 0) { foreach (KeyValuePair Category in S.Categorys) { sAddFriend.AddInt(Category.Key); sAddFriend.AddStringWithBreak(Category.Value); } } // Add Now the new user UsersData sMyData = UsersData.UsersRegister[Id]; Habbo zUser = StaticGame.VirtualUser[Id]; sAddFriend.AddInt(1); sAddFriend.AddInt(0); // Process this NOW! sAddFriend.AddInt(sMyData.Id); sAddFriend.AddStringWithBreak(sMyData.UserName); sAddFriend.AddBoolean(true); sAddFriend.AddBoolean(sMyData.IsOnline); sAddFriend.AddBoolean(zUser.IsOnRoom); sAddFriend.AddStringWithBreak(sMyData.Look); sAddFriend.AddInt(0); sAddFriend.AddStringWithBreak(sMyData.Motto); sAddFriend.AddStringWithBreak(sMyData.LastAccess); sAddFriend.AddStringWithBreak(sMyData.RealName); // Facebook Name sAddFriend.AddBoolean(false); User.SendMessage(sAddFriend); #endregion } } #endregion #region Searching Friends internal void GetSearch() { FriendsData F = FriendsData.AllFriends[User.Id]; string Name = User.ActualPacket.Substring(4); ServerMessage SConsole = new ServerMessage("Fs"); try { List sFriends = new List(); List notFriends = new List(); foreach (UsersData fUser in UsersData.UsersRegistered) { if (fUser.UserName.ToLower().Contains(Name.ToLower()) && fUser.Id != User.Id) { int i = 0; foreach (KeyValuePair Frends in F.Friends) { i++; if (!sFriends.Contains(fUser.Id) && !notFriends.Contains(fUser.Id)) { int FriendId = Frends.Key; if (fUser.Id == FriendId) sFriends.Add(fUser.Id); else if(i < F.Friends.Count) continue; else notFriends.Add(fUser.Id); } } } else continue; } SConsole.AddInt(sFriends.Count); // Add our friends if (sFriends.Count > 0) { foreach (int sId in sFriends) { this.GetUserForSearch(SConsole, sId); } } SConsole.AddInt(notFriends.Count); // Add other friends if (notFriends.Count > 0) { foreach (int oId in notFriends) { this.GetUserForSearch(SConsole, oId); } } } catch { } User.SendMessage(SConsole); } internal void GetUserForSearch(ServerMessage ConsoleR, int UserId) { UsersData DUser = UsersData.UsersRegister[UserId]; Habbo zUser = null; if (DUser.IsOnline) zUser = StaticGame.VirtualUser[UserId]; ConsoleR.AddInt(DUser.Id); // Add ID ConsoleR.AddStringWithBreak(DUser.UserName); // Add Name ConsoleR.AddStringWithBreak(DUser.Motto); // Add Motto ConsoleR.AddBoolean(DUser.IsOnline); // Is Online? if (zUser != null) ConsoleR.AddBoolean(zUser.IsOnRoom); // Is on Room? else ConsoleR.AddBoolean(false); ConsoleR.AddChar(2); // Char ConsoleR.AddInt(0); // CategoryId LOL? ConsoleR.AddStringWithBreak(DUser.Look); // Add Look ConsoleR.AddStringWithBreak(DUser.LastAccess); // Add LastOnline D: ConsoleR.AddChar(2); // Char } #endregion #region Other Functions internal void UpdateMyFriends() { FriendsData F = FriendsData.AllFriends[User.Id]; foreach (KeyValuePair Uzerz in StaticGame.VirtualUser) { int UserId = Uzerz.Key; Habbo Habbos = Uzerz.Value; foreach (KeyValuePair Frends in F.Friends) { int FriendId = Frends.Key; if (UserId == FriendId) { // It's a friend! Send packet! ServerMessage AddFriend = new ServerMessage("@M"); AddFriend.AddInt(F.Categorys.Count); if (F.Categorys.Count > 0) { foreach (KeyValuePair Category in F.Categorys) { AddFriend.AddInt(Category.Key); AddFriend.AddStringWithBreak(Category.Value); } } // Add Now the new user AddFriend.AddInt(1); AddFriend.AddInt(0); // Process this NOW! UsersData MyData = UsersData.UsersRegister[User.Id]; AddFriend.AddInt(User.Id); AddFriend.AddStringWithBreak(User.UserName); AddFriend.AddBoolean(true); AddFriend.AddBoolean(User.IsOnline); AddFriend.AddBoolean(User.IsOnRoom); AddFriend.AddStringWithBreak(MyData.Look); AddFriend.AddInt(Frends.Value); AddFriend.AddStringWithBreak(MyData.Motto); AddFriend.AddStringWithBreak(MyData.LastAccess); AddFriend.AddStringWithBreak(MyData.RealName); // Facebook Name AddFriend.AddBoolean(false); Habbos.SendMessage(AddFriend); } } } } internal void ConsoleChat() { string Separe = User.ActualPacket; int Id = HabboEncode.decodeVL64(Separe.Substring(2)); string[] String1 = Separe.Split('@'); string Message = BlizzardSystem.MergeParams(String1, 2).Substring(1); ServerMessage ConsoleChat = new ServerMessage("BF"); try { if (StaticGame.VirtualUser.ContainsKey(Id)) { Habbo CUser = StaticGame.VirtualUser[Id]; ConsoleChat.AddInt(User.Id); // Conversation ID ConsoleChat.AddString(Message); // Message CUser.SendMessage(ConsoleChat); // Send the conv } } catch { } } #endregion #region Friend Stream internal void UseFriendStream() { // Gu@ > Disable // GuA > Enable /* * NvKtA|crNJ25793695{char2}darii0{char2}m{char2}http://www.habbo.com/habbo-imaging/badge/ACH_RespectEarned1cac0bb4e40fef936b80a44dc12e5cf8d.png {char2}IKACH_RespectEarned1{char2}vQ|xzNK25793695{char2}darii0{char2}m{char2}http://www.habbo.com/habbo-imaging/avatar/hr-165-31.hd-195-6.ch-3109-64-72.lg-3116-64-62.sh-295-62.ca-1801-91,s-2.g-0.d-2.h-2.a-0,9b68348713d77719325d1a724b5cd709.gif {char2}IPATroller{char2}tOd}zNI25793695{char2}darii0{char2}m{char2}http://www.habbo.com/habbo-imaging/avatar/hr-165-31.hd-195-6.ch-3109-64-72.lg-3116-64-62.sh-295-62.ca-1801-91,s-2.g-0.d-2.h-2.a-0,9b68348713d77719325d1a724b5cd709.gif {char2}JJ29542009{char2}julian6820's room{char2}{char1} */ if (User.ActualPacket.Contains("@")) { // Disable } else { // tOd}zNI25793695{char2}darii0{char2}m{char2}http://www.habbo.com/habbo-imaging/avatar/hr-165-31.hd-195-6.ch-3109-64-72.lg-3116-64-62.sh-295-62.ca-1801-91,s-2.g-0.d-2.h-2.a-0,9b68348713d77719325d1a724b5cd709.gif {char2}JJ29542009{char2}julian6820's room{char2} // vQ|xzNK25793695{char2}darii0{char2}m{char2}http://www.habbo.com/habbo-imaging/avatar/hr-165-31.hd-195-6.ch-3109-64-72.lg-3116-64-62.sh-295-62.ca-1801-91,s-2.g-0.d-2.h-2.a-0,9b68348713d77719325d1a724b5cd709.gif {char2}IPATroller{char2}tOd}zNI25793695 // tA|crNJ25793695{char2}darii0{char2}m{char2}http://www.habbo.com/habbo-imaging/badge/ACH_RespectEarned1cac0bb4e40fef936b80a44dc12e5cf8d.png {char2}IKACH_RespectEarned1 ServerMessage SerializeFriendStream = new ServerMessage("Nv"); SerializeFriendStream.AddInt(3); // Count? UsersData D = UsersData.UsersRegister[User.Id]; SerializeFriendStream.AddInt(User.Id); // Type? SerializeFriendStream.AddInt(2); // Type? SerializeFriendStream.AddStringWithBreak(User.Id.ToString()); // UserId SerializeFriendStream.AddStringWithBreak(User.UserName); // UserName SerializeFriendStream.AddStringWithBreak(D.Gender.ToLower()); // Gender SerializeFriendStream.AddStringWithBreak("http://www.habbo.com/habbo-imaging/badge/ACH_RespectEarned1cac0bb4e40fef936b80a44dc12e5cf8d.png"); // Badge SerializeFriendStream.AddInt(1); // Minutes ago! SerializeFriendStream.AddInt(3); // Type? // Achievement SerializeFriendStream.AddStringWithBreak("ACH_RespectEarned1"); // Achievement Name SerializeFriendStream.AddInt(User.Id); // Type? SerializeFriendStream.AddInt(3); // Type? SerializeFriendStream.AddStringWithBreak(User.Id.ToString()); // UserId SerializeFriendStream.AddStringWithBreak(User.UserName); // UserName SerializeFriendStream.AddStringWithBreak(D.Gender.ToLower()); // Gender SerializeFriendStream.AddStringWithBreak("http://blisard.habbo.sc/head.gif?figure=" + D.Look + ".gif"); // Look (NEED HASH) SerializeFriendStream.AddInt(6); // Minutes ago! SerializeFriendStream.AddInt(4); // Type? // Motto SerializeFriendStream.AddStringWithBreak(User.Motto); // RoomId SerializeFriendStream.AddInt(User.Id); // Type? SerializeFriendStream.AddInt(1); // Type? SerializeFriendStream.AddStringWithBreak(User.Id.ToString()); // UserId SerializeFriendStream.AddStringWithBreak(User.UserName); // UserName SerializeFriendStream.AddStringWithBreak(D.Gender.ToLower()); // Gender SerializeFriendStream.AddStringWithBreak("http://blisard.habbo.sc/head.gif?figure=" + D.Look + ".gif"); // Look SerializeFriendStream.AddInt(15); // Minutes ago! SerializeFriendStream.AddInt(2); // Type? // Rooms SerializeFriendStream.AddStringWithBreak("1"); // RoomId SerializeFriendStream.AddStringWithBreak("Itachi's room"); // RoomName User.SendMessage(SerializeFriendStream); } } #endregion } }