Esempio n. 1
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 (client == null)
             {
                 Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "No player found with the name: " + name);
             }
             else if (Arguments.argUser.userID == client.userID)
             {
                 Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You can't add yourself as a friend!");
             }
             else
             {
                 if (list != null)
                 {
                     if (list.isFriendWith(client.userID))
                     {
                         Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You are already friend with " + client.netUser.displayName + ".");
                         return;
                     }
                 }
                 else
                 {
                     list = new FriendList();
                 }
                 list.AddFriend(client.netUser.displayName, client.userID);
                 command.GetFriendsLists()[Arguments.argUser.userID] = list;
                 Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You have added " + client.netUser.displayName + " to your friend list.");
             }
         }
     }
     else
     {
         Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Friends Management Usage:  /addfriend \"playerName\"");
     }
 }
Esempio n. 2
0
 public static IEnumerable <PlayerClient> FindAllWithName(string name)
 {
     return(PlayerClient.FindAllWithName(name, StringComparison.InvariantCultureIgnoreCase));
 }
Esempio n. 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\"");
     }
 }