示例#1
0
        public override void Execute(ref ConsoleSystem.Arg Arguments, ref string[] ChatArguments)
        {
            var    pl         = Fougerite.Server.Cache[Arguments.argUser.userID];
            string playerName = string.Join(" ", ChatArguments).Trim(new char[] { ' ', '"' });

            if (playerName == string.Empty)
            {
                pl.MessageFrom(Core.Name, "Friends Management Usage:  /unfriend playerName");
                return;
            }
            FriendsCommand command     = (FriendsCommand)ChatCommand.GetCommand("friends");
            FriendList     friendsList = (FriendList)command.GetFriendsLists()[pl.UID];

            if (friendsList == null)
            {
                pl.MessageFrom(Core.Name, "You currently have no friends.");
                return;
            }
            if (friendsList.isFriendWith(playerName))
            {
                friendsList.RemoveFriend(playerName);
                pl.MessageFrom(Core.Name, "You have removed " + playerName + " from your friends list.");
                if (friendsList.HasFriends())
                {
                    command.GetFriendsLists()[pl.UID] = friendsList;
                }
                else
                {
                    command.GetFriendsLists().Remove(pl.UID);
                }
            }
            else
            {
                PList list = new PList();
                list.Add(0, "Cancel");
                foreach (KeyValuePair <ulong, string> entry in Core.userCache)
                {
                    if (friendsList.isFriendWith(entry.Key) && entry.Value.ToUpperInvariant().Contains(playerName.ToUpperInvariant()))
                    {
                        list.Add(entry.Key, entry.Value);
                    }
                }
                if (list.Count == 1)
                {
                    foreach (Fougerite.Player client in Fougerite.Server.GetServer().Players)
                    {
                        if (friendsList.isFriendWith(client.UID) && client.Name.ToUpperInvariant().Contains(playerName.ToUpperInvariant()))
                        {
                            list.Add(client.UID, client.Name);
                        }
                    }
                }
                if (list.Count == 1)
                {
                    pl.MessageFrom(Core.Name, string.Format("You are not friends with {0}.", playerName));
                    return;
                }

                pl.MessageFrom(Core.Name, string.Format("{0}  friend{1} {2}: ", ((list.Count - 1)).ToString(), (((list.Count - 1) > 1) ? "s match" : " matches"), playerName));
                for (int i = 1; i < list.Count; i++)
                {
                    pl.MessageFrom(Core.Name, string.Format("{0} - {1}", i, list.PlayerList[i].DisplayName));
                }
                pl.MessageFrom(Core.Name, "0 - Cancel");
                pl.MessageFrom(Core.Name, "Please enter the number matching the friend to remove.");
                Core.unfriendWaitList[pl.UID] = list;
            }
        }
        public override void Execute(ref ConsoleSystem.Arg Arguments, ref string[] ChatArguments)
        {
            var    pl         = Fougerite.Server.Cache[Arguments.argUser.userID];
            string playerName = string.Join(" ", ChatArguments).Trim(new char[] { ' ', '"' });

            if (playerName == string.Empty)
            {
                pl.MessageFrom(Core.Name, "[color red]<Sintaxis> /unfriend <NombreJugador>");
                return;
            }
            FriendsCommand command     = (FriendsCommand)ChatCommand.GetCommand("amigos");
            FriendList     friendsList = (FriendList)command.GetFriendsLists()[pl.UID];

            if (friendsList == null)
            {
                pl.MessageFrom(Core.Name, "Actualmente no tienes amigos (Pvta ke sad).");
                return;
            }
            if (friendsList.isFriendWith(playerName))
            {
                friendsList.RemoveFriend(playerName);
                pl.MessageFrom(Core.Name, "Removiste a " + playerName + " de tu lista de amigos.");
                if (friendsList.HasFriends())
                {
                    command.GetFriendsLists()[pl.UID] = friendsList;
                }
                else
                {
                    command.GetFriendsLists().Remove(pl.UID);
                }
            }
            else
            {
                PList list = new PList();
                list.Add(0, "Cancel");
                foreach (KeyValuePair <ulong, string> entry in Core.userCache)
                {
                    if (friendsList.isFriendWith(entry.Key) && entry.Value.ToUpperInvariant().Contains(playerName.ToUpperInvariant()))
                    {
                        list.Add(entry.Key, entry.Value);
                    }
                }
                if (list.Count == 1)
                {
                    foreach (Fougerite.Player client in Fougerite.Server.GetServer().Players)
                    {
                        if (friendsList.isFriendWith(client.UID) && client.Name.ToUpperInvariant().Contains(playerName.ToUpperInvariant()))
                        {
                            list.Add(client.UID, client.Name);
                        }
                    }
                }
                if (list.Count == 1)
                {
                    pl.MessageFrom(Core.Name, string.Format("No eres amigo de {0}.", playerName));
                    return;
                }

                pl.MessageFrom(Core.Name, string.Format("{0}  amigo{1} {2}: ", ((list.Count - 1)).ToString(), (((list.Count - 1) > 1) ? "s encontrados" : " encontrado"), playerName));
                for (int i = 1; i < list.Count; i++)
                {
                    pl.MessageFrom(Core.Name, string.Format("{0} - {1}", i, list.PlayerList[i].DisplayName));
                }
                pl.MessageFrom(Core.Name, "0 - Cancelar");
                pl.MessageFrom(Core.Name, "Selecciona el amigo al que quieres eliminar.");
                Core.unfriendWaitList[pl.UID] = list;
            }
        }
示例#3
0
 public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments)
 {
     if (ChatArguments != null)
     {
         string name = "";
         for (int i = 0; i < ChatArguments.Length; i++)
         {
             name = name + ChatArguments[i] + " ";
         }
         name = name.Trim();
         if (name != null)
         {
             PlayerClient client = null;
             try
             {
                 client = EnumerableToArray.ToArray <PlayerClient>(PlayerClient.FindAllWithName(name, StringComparison.CurrentCultureIgnoreCase))[0];
             }
             catch (Exception ex)
             {
                 client = null;
                 Logger.LogException(ex);
             }
             FriendsCommand command = (FriendsCommand)ChatCommand.GetCommand("friends");
             FriendList     list    = (FriendList)command.GetFriendsLists()[Arguments.argUser.userID];
             if (list != null)
             {
                 string realName;
                 if (client == null)
                 {
                     if (!list.isFriendWith(name))
                     {
                         Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You are not friends with " + name);
                         return;
                     }
                     list.RemoveFriend(name);
                     realName = list.GetRealName(name);
                 }
                 else
                 {
                     if (!list.isFriendWith(client.userID))
                     {
                         Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You are not friends with " + name);
                         return;
                     }
                     list.RemoveFriend(client.userID);
                     realName = client.netUser.displayName;
                 }
                 Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You have removed " + realName + " from your friends list.");
                 if (list.HasFriends())
                 {
                     command.GetFriendsLists()[Arguments.argUser.userID] = list;
                 }
                 else
                 {
                     command.GetFriendsLists().Remove(Arguments.argUser.userID);
                 }
             }
             else
             {
                 Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You currently have no friends.");
             }
         }
     }
     else
     {
         Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Friends Management Usage:  /unfriend \"playerName\"");
     }
 }