public void OnNewFriendship(int friendID) { var friend = Program.GameContext.PlayerController.GetClientByUserId(friendID); MessengerBuddy newFriend; if (friend == null || friend.GetHabbo() == null) { DataRow dRow; using (var dbClient = Program.DatabaseManager.GetQueryReactor()) { dbClient.SetQuery("SELECT id,username,motto,look,last_online,hide_inroom,hide_online FROM users WHERE `id` = @friendid LIMIT 1"); dbClient.AddParameter("friendid", friendID); dRow = dbClient.GetRow(); } newFriend = new MessengerBuddy(friendID, Convert.ToString(dRow["username"]), Convert.ToString(dRow["look"]), Convert.ToString(dRow["motto"]), Convert.ToInt32(dRow["last_online"]), dRow["hide_online"].ToString() == "1", dRow["hide_inroom"].ToString() == "1"); } else { var user = friend.GetHabbo(); newFriend = new MessengerBuddy(friendID, user.Username, user.Look, user.Motto, 0, user.AppearOffline, user.AllowPublicRoomStatus); newFriend.UpdateUser(friend); } if (!_friends.ContainsKey(friendID)) { _friends.Add(friendID, newFriend); } GetClient().SendPacket(SerializeUpdate(newFriend)); }
public ServerPacket SerializeUpdate(MessengerBuddy friend) { var Packet = new ServerPacket(ServerPacketHeader.FriendListUpdateMessageComposer); Packet.WriteInteger(0); // category count Packet.WriteInteger(1); // number of updates Packet.WriteInteger(0); // don't know friend.Serialize(Packet, GetClient()); return(Packet); }
public bool TryGetFriend(int UserId, out MessengerBuddy Buddy) { return(_friends.TryGetValue(UserId, out Buddy)); }