Beispiel #1
0
        public void AddFriend(string name)
        {
            var friend = FriendMananger.Instance.GetFriendInfo(name);

            if (friend == null || FriendsIdList.ContainsKey(friend.CharacterId))
            {
                return;                                                                  // already add
            }
            var template = new FriendTemplate()
            {
                Id       = FriendIdManager.Instance.GetNextId(),
                FriendId = friend.CharacterId,
                Owner    = Owner.Id
            };

            FriendsIdList.Add(friend.CharacterId, template);
            FriendMananger.Instance.AddToAllFriends(template);
            Owner.SendPacket(new SCAddFriendPacket(friend, true, 0));
        }
Beispiel #2
0
 public void Load(MySqlConnection connection)
 {
     using (var command = connection.CreateCommand())
     {
         command.CommandText = "SELECT * FROM friends WHERE `owner` = @owner";
         command.Parameters.AddWithValue("@owner", Owner.Id);
         command.Prepare();
         using (var reader = command.ExecuteReader())
         {
             while (reader.Read())
             {
                 var template = new FriendTemplate()
                 {
                     Id       = reader.GetUInt32("id"),
                     FriendId = reader.GetUInt32("friend_id"),
                     Owner    = reader.GetUInt32("owner")
                 };
                 FriendsIdList.Add(template.FriendId, template);
             }
         }
     }
 }