コード例 #1
0
        public void AddFriend(PList.Player friend, Fougerite.Player friending)
        {
            if (friending.UID == friend.UserID)
            {
                friending.MessageFrom(Core.Name, "You can't add yourself as a friend!");
                return;
            }
            FriendsCommand command = (FriendsCommand)ChatCommand.GetCommand("friends");
            FriendList     list    = (FriendList)command.GetFriendsLists()[friending.UID];

            if (list == null)
            {
                list = new FriendList();
            }
            if (list.isFriendWith(friend.UserID))
            {
                friending.MessageFrom(Core.Name, string.Format("You are already friends with {0}.", friend.DisplayName));
                return;
            }
            list.AddFriend(SecurityElement.Escape(friend.DisplayName), friend.UserID);
            command.GetFriendsLists()[friending.UID] = list;
            friending.MessageFrom(Core.Name, string.Format("You have added {0} to your friends list.", friend.DisplayName));
            Fougerite.Player ffriend = Fougerite.Server.GetServer().FindPlayer(friend.UserID.ToString());
            if (ffriend != null)
            {
                ffriend.MessageFrom(Core.Name, string.Format("{0} has added you to their friends list.", friending.Name));
            }
        }
コード例 #2
0
        public void AddFriend(PList.Player friend, NetUser friending)
        {
            if (friending.userID == friend.UserID)
            {
                Util.sayUser(friending.networkPlayer, Core.Name, "You can't add yourself as a friend!");
                return;
            }
            FriendsCommand command = (FriendsCommand)ChatCommand.GetCommand("friends");
            FriendList     list    = (FriendList)command.GetFriendsLists()[friending.userID];

            if (list == null)
            {
                list = new FriendList();
            }
            if (list.isFriendWith(friend.UserID))
            {
                Util.sayUser(friending.networkPlayer, Core.Name, string.Format("You are already friends with {0}.", friend.DisplayName));
                return;
            }
            list.AddFriend(friend.DisplayName, friend.UserID);
            command.GetFriendsLists()[friending.userID] = list;
            Util.sayUser(friending.networkPlayer, Core.Name, string.Format("You have added {0} to your friends list.", friend.DisplayName));
            PlayerClient client;

            if (PlayerClient.FindByUserID(friend.UserID, out client))
            {
                Util.sayUser(client.netUser.networkPlayer, Core.Name, string.Format("{0} has added you to their friends list.", friending.displayName));
            }
        }
コード例 #3
0
        public void AddFriend(Fougerite.Player friend, Fougerite.Player friending)
        {
            if (friending.UID == friend.UID)
            {
                friending.SendClientMessage("[color red]<Error>[/color] ¡No puedes agregarte a tí mismo como amigo!");
                return;
            }
            FriendsCommand command = (FriendsCommand)ChatCommand.GetCommand("amigos");
            FriendList     list    = (FriendList)command.GetFriendsLists()[friending.UID];

            if (list == null)
            {
                list = new FriendList();
            }
            if (list.isFriendWith(friend.UID))
            {
                friending.SendClientMessage(string.Format("Usted ya es amigo de {0}.", friend.Name));
                return;
            }
            list.AddFriend(SecurityElement.Escape(friend.Name), friend.UID);
            command.GetFriendsLists()[friending.UID] = list;
            friending.SendClientMessage(string.Format("Agregaste a {0} a tu lista de amigos.", friend.Name));
            if (friend != null)
            {
                friend.SendClientMessage(string.Format("{0} te agregó a su lista de amigos.", friending.Name));
            }
        }
コード例 #4
0
        public void Unfriend(PList.Player exfriend, Fougerite.Player unfriending)
        {
            FriendsCommand command     = (FriendsCommand)ChatCommand.GetCommand("amigos");
            FriendList     friendsList = (FriendList)command.GetFriendsLists()[unfriending.UID];

            friendsList.RemoveFriend(exfriend.UserID);
            command.GetFriendsLists()[unfriending.UID] = friendsList;
            unfriending.MessageFrom(Core.Name, string.Format("Removiste a {0} de tu lista de amigos.", exfriend.DisplayName));
        }
コード例 #5
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\"");
     }
 }
コード例 #6
0
        public void Unfriend(PList.Player exfriend, Fougerite.Player unfriending)
        {
            FriendsCommand command     = (FriendsCommand)ChatCommand.GetCommand("friends");
            FriendList     friendsList = (FriendList)command.GetFriendsLists()[unfriending.UID];

            friendsList.RemoveFriend(exfriend.UserID);
            command.GetFriendsLists()[unfriending.UID] = friendsList;
            unfriending.MessageFrom(Core.Name, string.Format("You have removed {0} from your friends list.", exfriend.DisplayName));
        }
コード例 #7
0
        public void Unfriend(PList.Player exfriend, NetUser unfriending)
        {
            FriendsCommand command     = (FriendsCommand)ChatCommand.GetCommand("friends");
            FriendList     friendsList = (FriendList)command.GetFriendsLists()[unfriending.userID];

            friendsList.RemoveFriend(exfriend.UserID);
            command.GetFriendsLists()[unfriending.userID] = friendsList;
            Util.sayUser(unfriending.networkPlayer, Core.Name, string.Format("You have removed {0} from your friends list.", exfriend.DisplayName));
        }
コード例 #8
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, "[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;
            }
        }
コード例 #9
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;
            }
        }
コード例 #10
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\"");
     }
 }