Ejemplo n.º 1
0
        public void AddFlags(Administrator administrator, NetUser myAdmin)
        {
            List <string> flags = (List <string>)Core.adminFlagsList[myAdmin.userID];

            Core.adminFlagsList.Remove(myAdmin.userID);

            foreach (string properName in flags)
            {
                if (properName == "RCON" && !Administrator.GetAdmin(myAdmin.userID).HasPermission("RCON"))
                {
                    Util.sayUser(myAdmin.networkPlayer, Core.Name, "You can't add the RCON flag to anyone's permissions.");
                    Administrator.NotifyAdmins(string.Format("{0} attempted to add the {1} flag to {2}'s permissions.", myAdmin.displayName, properName, administrator.DisplayName));
                }
                else if (administrator.HasPermission(properName))
                {
                    Util.sayUser(myAdmin.networkPlayer, Core.Name, string.Format("{0} already has the {1} flag.", administrator.DisplayName, properName));
                }
                else
                {
                    administrator.Flags.Add(properName);
                    Administrator.NotifyAdmins(string.Format("{0} added the {1} flag to {2}'s permissions.", myAdmin.displayName, properName, administrator.DisplayName));
                    if (properName == "RCON")
                    {
                        PlayerClient adminclient;
                        if (PlayerClient.FindByUserID(administrator.UserID, out adminclient))
                        {
                            adminclient.netUser.admin = true;
                        }
                    }
                }
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 3
0
        public void DoorShare(PList.Player friend, NetUser sharing)
        {
            if (friend.UserID == sharing.userID)
            {
                Util.sayUser(sharing.networkPlayer, Core.Name, "Why would you share with yourself?");
                return;
            }
            ArrayList shareList = (ArrayList)shared_doors[sharing.userID];

            if (shareList == null)
            {
                shareList = new ArrayList();
                shared_doors.Add(sharing.userID, shareList);
            }
            if (shareList.Contains(friend.UserID))
            {
                Util.sayUser(sharing.networkPlayer, Core.Name, string.Format("You have already shared doors with {0}.", friend.DisplayName));
                return;
            }
            shareList.Add(friend.UserID);
            Util.sayUser(sharing.networkPlayer, Core.Name, string.Format("You have shared doors with {0}.", friend.DisplayName));
            PlayerClient client;

            if (PlayerClient.FindByUserID(friend.UserID, out client))
            {
                Util.sayUser(client.netPlayer, Core.Name, string.Format("{0} has shared doors with you.", sharing.displayName));
            }
        }
Ejemplo n.º 4
0
        public void BanPlayer(PList.Player ban, NetUser myAdmin)
        {
            if (ban.UserID == myAdmin.userID)
            {
                Util.sayUser(myAdmin.networkPlayer, Core.Name, "Seriously? You can't ban yourself.");
                return;
            }
            if (Administrator.IsAdmin(ban.UserID) && !Administrator.GetAdmin(myAdmin.userID).HasPermission("RCON"))
            {
                Util.sayUser(myAdmin.networkPlayer, Core.Name, ban.DisplayName + " is an administrator. You can't ban administrators.");
                return;
            }
            if (RustPP.Core.blackList.Contains(ban.UserID))
            {
                Logger.LogError(string.Format("[BanPlayer] {0}, id={1} already on blackList.", ban.DisplayName, ban.UserID));
                Core.blackList.Remove(ban.UserID);
            }
            Core.blackList.Add(ban);
            Administrator.DeleteAdmin(ban.UserID);
            Administrator.NotifyAdmins(string.Format("{0} has been banned by {1}.", ban.DisplayName, myAdmin.displayName));
            PlayerClient client;

            if (PlayerClient.FindByUserID(ban.UserID, out client))
            {
                client.netUser.Kick(NetError.Facepunch_Kick_Ban, true);
            }
        }
Ejemplo n.º 5
0
 public static void MessageClan(ClanData clan, string text)
 {
     try
     {
         if (!text.IsEmpty())
         {
             if (clan != null)
             {
                 string text2 = Core.ChatClanIcon;
                 if (text2 == "")
                 {
                     text2 = "<" + (clan.Abbr.IsEmpty() ? clan.Name : clan.Abbr) + ">";
                 }
                 text = "chat.add " + Helper.QuoteSafe(text2) + " " + Helper.QuoteSafe(Helper.GetChatTextColor(Core.ChatClanColor) + text.Trim(new char[]
                 {
                     '"'
                 }));
                 foreach (UserData current in clan.Members.Keys)
                 {
                     PlayerClient playerClient;
                     if (PlayerClient.FindByUserID(current.SteamID, out playerClient))
                     {
                         ConsoleNetworker.SendClientCommand(playerClient.netPlayer, text);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Debug.Log("ERROR: " + ex.Message);
     }
 }
Ejemplo n.º 6
0
 public static void MessageClan(ClanData clan, string text, [Optional, DefaultParameterValue(null)] NetUser AsUser)
 {
     try
     {
         if (!text.IsEmpty() && (clan != null))
         {
             string chatClanIcon = Core.ChatClanIcon;
             if (chatClanIcon == "")
             {
                 chatClanIcon = "<" + (clan.Abbr.IsEmpty() ? clan.Name : clan.Abbr) + ">";
             }
             if (AsUser != null)
             {
                 chatClanIcon = AsUser.displayName + Core.ChatDivider + chatClanIcon;
             }
             text = "chat.add " + Helper.QuoteSafe(chatClanIcon) + " " + Helper.QuoteSafe(Helper.GetChatTextColor(Core.ChatClanColor) + text.Trim(new char[] { '"' }));
             foreach (UserData data in clan.Members.Keys)
             {
                 PlayerClient client;
                 if (PlayerClient.FindByUserID(data.SteamID, out client))
                 {
                     ConsoleNetworker.SendClientCommand(client.netPlayer, text);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         Debug.Log("ERROR: " + exception.Message);
     }
 }
Ejemplo n.º 7
0
        public void UnmutePlayer(PList.Player unmute, NetUser myAdmin)
        {
            Core.muteList.Remove(unmute.UserID);
            Administrator.NotifyAdmins(string.Format("{0} has been unmuted by {1}.", unmute.DisplayName, myAdmin.displayName));
            PlayerClient client;

            if (PlayerClient.FindByUserID(unmute.UserID, out client))
            {
                Util.sayUser(client.netPlayer, Core.Name, string.Format("You have been unmuted by {0}", myAdmin.displayName));
            }
        }
Ejemplo n.º 8
0
        public void UnshareDoors(PList.Player exfriend, NetUser unsharing)
        {
            ShareCommand command = (ShareCommand)ChatCommand.GetCommand("share");
            ArrayList    list    = (ArrayList)command.GetSharedDoors()[unsharing.userID];

            list.Remove(exfriend.UserID);
            Util.sayUser(unsharing.networkPlayer, Core.Name, string.Format("{0} can use your doors no longer.", exfriend.DisplayName));
            PlayerClient client;

            if (PlayerClient.FindByUserID(exfriend.UserID, out client))
            {
                Util.sayUser(client.netPlayer, Core.Name, string.Format("{0} is no longer sharing his doors with you.", unsharing.displayName));
            }
        }
Ejemplo n.º 9
0
        public void PartialNameKill(ref ConsoleSystem.Arg Arguments, int id)
        {
            if (id == 0)
            {
                Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Cancelled!");
                return;
            }
            PList        list = (PList)Core.killWaitList[Arguments.argUser.userID];
            PlayerClient client;

            if (PlayerClient.FindByUserID(list.PlayerList[id].UserID, out client))
            {
                KillPlayer(client, Arguments.argUser.playerClient);
            }
        }
Ejemplo n.º 10
0
        public override void Execute(ref ConsoleSystem.Arg Arguments, ref string[] ChatArguments)
        {
            string playerName = string.Join(" ", ChatArguments).Trim(new char[] { ' ', '"' });

            if (playerName == string.Empty)
            {
                Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Sharing Doors Usage:  /unshare playerName");
                return;
            }
            ShareCommand command   = (ShareCommand)ChatCommand.GetCommand("share");
            ArrayList    shareList = (ArrayList)command.GetSharedDoors()[Arguments.argUser.userID];

            if (shareList == null)
            {
                Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You aren't sharing doors with anyone.");
                return;
            }
            PList list = new PList();

            list.Add(0, "Cancel");
            foreach (ulong id in shareList)
            {
                if (Core.userCache.ContainsKey(id))
                {
                    if (Core.userCache[id].Equals(playerName, StringComparison.OrdinalIgnoreCase))
                    {
                        UnshareDoors(new PList.Player(id, Core.userCache[id]), Arguments.argUser);
                        return;
                    }
                    else if (Core.userCache[id].ToUpperInvariant().Contains(playerName.ToUpperInvariant()))
                    {
                        list.Add(id, Core.userCache[id]);
                    }
                }
                else
                {
                    PlayerClient client;
                    if (PlayerClient.FindByUserID(id, out client))
                    {
                        if (client.netUser.displayName.Equals(playerName, StringComparison.OrdinalIgnoreCase))
                        {
                            UnshareDoors(new PList.Player(id, client.netUser.displayName), Arguments.argUser);
                            return;
                        }
                    }
                }
            }
            if (list.Count == 1)
            {
                Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, string.Format("You aren't sharing doors with {0}.", playerName));
                return;
            }
            Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, string.Format("{0}  players{1} {2}: ", ((list.Count - 1)).ToString(), (((list.Count - 1) > 1) ? "s match" : " matches"), playerName));
            for (int i = 1; i < list.Count; i++)
            {
                Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, string.Format("{0} - {1}", i, list.PlayerList[i].DisplayName));
            }
            Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "0 - Cancel");
            Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Please enter the number matching the player you won't share doors with.");
            Core.unshareWaitList[Arguments.argUser.userID] = list;
        }
Ejemplo n.º 11
0
        public void OutputList(ref ConsoleSystem.Arg arg)
        {
            List <string> onlineFriends  = new List <string>();
            List <string> offlineFriends = new List <string>();

            foreach (Friend friend in this)
            {
                PlayerClient client;
                if (PlayerClient.FindByUserID(friend.GetUserID(), out client))
                {
                    onlineFriends.Add(client.netUser.displayName);
                    friend.SetDisplayName(client.netUser.displayName);
                }
                else
                {
                    offlineFriends.Add(friend.GetDisplayName());
                }
            }

            int friendsPerRow = 7;

            Util.sayUser(arg.argUser.networkPlayer, Core.Name,
                         string.Format("You currently have {0} friend{1} online:",
                                       (onlineFriends.Count == 0 ? "no" : onlineFriends.Count.ToString()), ((onlineFriends.Count != 1) ? "s" : string.Empty)));

            if (onlineFriends.Count <= friendsPerRow && onlineFriends.Count > 0)
            {
                Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Join(", ", onlineFriends.ToArray()));
            }
            else if (onlineFriends.Count > 0)
            {
                int i = friendsPerRow;
                for (; i <= onlineFriends.Count; i += friendsPerRow)
                {
                    Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Join(", ", onlineFriends.GetRange(i - friendsPerRow, friendsPerRow).ToArray()));
                }
                if (offlineFriends.Count % friendsPerRow > 0 || i - friendsPerRow == friendsPerRow)
                {
                    Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Join(", ", onlineFriends.GetRange(i - friendsPerRow, offlineFriends.Count % friendsPerRow).ToArray()));
                }
            }

            Util.sayUser(arg.argUser.networkPlayer, Core.Name,
                         string.Format("You have {0} offline friend{1}:",
                                       (offlineFriends.Count == 0 ? "no" : offlineFriends.Count.ToString()), ((offlineFriends.Count != 1) ? "s" : string.Empty)));

            if (offlineFriends.Count <= friendsPerRow && offlineFriends.Count > 0)
            {
                Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Join(", ", offlineFriends.ToArray()));
            }
            else if (offlineFriends.Count > 0)
            {
                int i = friendsPerRow;
                for (; i <= offlineFriends.Count; i += friendsPerRow)
                {
                    Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Join(", ", offlineFriends.GetRange(i - friendsPerRow, friendsPerRow).ToArray()));
                }
                if (offlineFriends.Count % friendsPerRow > 0 || i - friendsPerRow == friendsPerRow)
                {
                    Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Join(", ", offlineFriends.GetRange(i - friendsPerRow, offlineFriends.Count % friendsPerRow).ToArray()));
                }
            }
        }