public static void HandleAddIgnoreOpcode(ref PacketReader packet, ref WorldManager manager) { string name = packet.ReadString(); Player target = Database.Players.TryGetName(name); FriendResults result = FriendResults.FRIEND_IGNORE_NOT_FOUND; if (target != null) { if (target == manager.Character) { result = FriendResults.FRIEND_IGNORE_SELF; } else if (manager.Character.IgnoreList.Contains(target.Guid)) { result = FriendResults.FRIEND_IGNORE_ALREADY; } else { result = FriendResults.FRIEND_IGNORE_ADDED; if (manager.Character.IgnoreList.Count >= Globals.MAX_IGNORE_LIST) { result = FriendResults.FRIEND_IGNORE_FULL; } else { manager.Character.IgnoreList.Add(target.Guid); } } manager.Character.SendFriendStatus(target, result, false); } manager.Character.SendIgnoreList(); }
public static void SendFriendStatus(this Player p, Player friend, FriendResults result, bool broadcast) { FriendInfo fi = BuildFriendInfo(friend); PacketWriter pkt = new PacketWriter(Opcodes.SMSG_FRIEND_STATUS); pkt.WriteUInt8((byte)result); pkt.WriteUInt64(friend.Guid); pkt.WriteUInt8((byte)fi.Status); if (fi.Status > 0) { pkt.WriteUInt32(fi.Area); pkt.WriteUInt32(fi.Level); pkt.WriteUInt32(fi.Class); } if (broadcast) { foreach (Player player in Database.Players.Values) { if (player.FriendList.Contains(friend.Guid)) { player.Client.Send(pkt); } } } else { p.Client.Send(pkt); } }
public static void HandleAddFriendOpcode(ref PacketReader packet, ref WorldManager manager) { string name = packet.ReadString(); Player target = Database.Players.TryGetName(name); FriendResults result = FriendResults.FRIEND_OFFLINE; if (target != null) { if (target == manager.Character) { result = FriendResults.FRIEND_SELF; } else if (manager.Character.IsEnemyTo(target)) { result = FriendResults.FRIEND_ENEMY; } else if (manager.Character.FriendList.Contains(target.Guid)) { result = FriendResults.FRIEND_ALREADY; } else { if (target.IsOnline && target.LoggedIn) { result = FriendResults.FRIEND_ADDED_ONLINE; } else { result = FriendResults.FRIEND_ADDED_OFFLINE; } if (manager.Character.FriendList.Count >= Globals.MAX_FRIEND_LIST) { result = FriendResults.FRIEND_LIST_FULL; } else { manager.Character.FriendList.Add(target.Guid); } } manager.Character.SendFriendStatus(target, result, false); } manager.Character.SendFriendList(); }