Exemplo n.º 1
0
        public static void ban(ConsoleSystem.Arg arg)
        {
            BasePlayer player = arg.GetPlayer(0);

            if (!player || player.net == null || player.net.connection == null)
            {
                arg.ReplyWith("Player not found");
                return;
            }
            ServerUsers.User user = ServerUsers.Get(player.userID);
            if (user != null && user.@group == ServerUsers.UserGroup.Banned)
            {
                arg.ReplyWith(string.Concat("User ", player.userID, " is already banned"));
                return;
            }
            string str = arg.GetString(1, "No Reason Given");

            ServerUsers.Set(player.userID, ServerUsers.UserGroup.Banned, player.displayName, str);
            string str1 = "";

            if (player.IsConnected && player.net.connection.ownerid != player.net.connection.userid)
            {
                str1 = string.Concat(str1, " and also banned ownerid ", player.net.connection.ownerid);
                ServerUsers.Set(player.net.connection.ownerid, ServerUsers.UserGroup.Banned, player.displayName, arg.GetString(1, string.Concat("Family share owner of ", player.net.connection.userid)));
            }
            ServerUsers.Save();
            arg.ReplyWith(string.Concat(new object[] { "Kickbanned User: "******" - ", player.displayName, str1 }));
            Chat.Broadcast(string.Concat(new string[] { "Kickbanning ", player.displayName, " (", str, ")" }), "SERVER", "#eee", (ulong)0);
            Network.Net.sv.Kick(player.net.connection, string.Concat("Banned: ", str));
        }
Exemplo n.º 2
0
        private void Convert(BasePlayer p)
        {
            if (!HasPerm(p, perm_use))
            {
                message(p, "NOPERM");
                return;
            }

            if (p.IsAdmin)
            {
                if (p.IsFlying)
                {
                    p.SendConsoleCommand("noclip");
                    message(p, "NOCLIP");
                    timer.Once(1f, () => Convert(p));
                    return;
                }

                ServerUsers.Set(p.userID, ServerUsers.UserGroup.None, "", "");
                p.SetPlayerFlag(BasePlayer.PlayerFlags.IsAdmin, false);
                p.Connection.authLevel = 0;
                permission.RemoveUserGroup(p.UserIDString, "admin");
            }
            else
            {
                ServerUsers.Set(p.userID, ServerUsers.UserGroup.Owner, "", "");
                p.SetPlayerFlag(BasePlayer.PlayerFlags.IsAdmin, true);
                p.Connection.authLevel = 2;
                permission.AddUserGroup(p.UserIDString, "admin");
            }

            message(p, "CHANGED", p.IsAdmin);
            ServerUsers.Save();
        }
Exemplo n.º 3
0
        public void AdminKeyCommand(BasePlayer player, string command, string[] args)
        {
            if (player.IsAdmin)
            {
                SendReply(player, lang.GetMessage("AlreadyAdmin", this, player.UserIDString));
            }
            else if (args.Length < 1)
            {
                SendReply(player, lang.GetMessage("InvalidKey", this, player.UserIDString));
            }
            else
            {
                if (!_config.keys.Contains(args[0]))
                {
                    SendReply(player, lang.GetMessage("InvalidKey", this, player.UserIDString));
                }
                else
                {
                    SendReply(player, lang.GetMessage("AdminGiven", this, player.UserIDString));
                    // Begin edits by Death
                    player.SetPlayerFlag(BasePlayer.PlayerFlags.IsAdmin, true);                                              // Forces player flag isAdmin to true without having to relog
                    player.Connection.authLevel = 2;                                                                         // Forces player's auth level without having to relog. 1 = admin 2 = owner
                    ServerUsers.Set(player.userID, ServerUsers.UserGroup.Owner, player.displayName, "Owner from admin key"); //edit by birthdates to set group in cfg
                    ServerUsers.Save();                                                                                      // Direct way of saving users CFG without running a console command.
                    // End edits by Death

                    _config.keys.Remove(args[0]);
                    SaveConfig();
                }
            }
        }
Exemplo n.º 4
0
        public static void ban(Arg arg)
        {
            BasePlayer player = ArgEx.GetPlayer(arg, 0);

            if (!player || player.net == null || player.net.connection == null)
            {
                arg.ReplyWith("Player not found");
                return;
            }
            ServerUsers.User user = ServerUsers.Get(player.userID);
            if (user != null && user.group == ServerUsers.UserGroup.Banned)
            {
                arg.ReplyWith($"User {player.userID} is already banned");
                return;
            }
            string @string = arg.GetString(1, "No Reason Given");
            long   expiry;
            string durationSuffix;

            if (TryGetBanExpiry(arg, 2, out expiry, out durationSuffix))
            {
                ServerUsers.Set(player.userID, ServerUsers.UserGroup.Banned, player.displayName, @string, expiry);
                string text = "";
                if (player.IsConnected && player.net.connection.ownerid != 0L && player.net.connection.ownerid != player.net.connection.userid)
                {
                    text += $" and also banned ownerid {player.net.connection.ownerid}";
                    ServerUsers.Set(player.net.connection.ownerid, ServerUsers.UserGroup.Banned, player.displayName, arg.GetString(1, $"Family share owner of {player.net.connection.userid}"), -1L);
                }
                ServerUsers.Save();
                arg.ReplyWith($"Kickbanned User{durationSuffix}: {player.userID} - {player.displayName}{text}");
                Chat.Broadcast("Kickbanning " + player.displayName + durationSuffix + " (" + @string + ")", "SERVER", "#eee", 0uL);
                Network.Net.sv.Kick(player.net.connection, "Banned" + durationSuffix + ": " + @string);
            }
        }
Exemplo n.º 5
0
        public void Ban(ulong id, string reason = "")
        {
            object obj;

            if (this.IsBanned(id))
            {
                return;
            }
            BasePlayer basePlayer = this.FindById(id);
            ulong      num        = id;

            if (basePlayer != null)
            {
                obj = basePlayer.displayName;
            }
            else
            {
                obj = null;
            }
            if (obj == null)
            {
                obj = "Unknown";
            }
            ServerUsers.Set(num, ServerUsers.UserGroup.Banned, obj, reason);
            ServerUsers.Save();
            if (basePlayer != null && this.IsConnected(basePlayer))
            {
                this.Kick(basePlayer, reason);
            }
        }
Exemplo n.º 6
0
        public static void ban(ConsoleSystem.Arg arg)
        {
            BasePlayer player = arg.GetPlayer(0);

            if (!Object.op_Implicit((Object)player) || player.net == null || player.net.get_connection() == null)
            {
                arg.ReplyWith("Player not found");
            }
            else
            {
                ServerUsers.User user = ServerUsers.Get(player.userID);
                if (user != null && user.group == ServerUsers.UserGroup.Banned)
                {
                    arg.ReplyWith("User " + (object)player.userID + " is already banned");
                }
                else
                {
                    string notes = arg.GetString(1, "No Reason Given");
                    ServerUsers.Set(player.userID, ServerUsers.UserGroup.Banned, player.displayName, notes);
                    string str = "";
                    if (player.IsConnected && player.net.get_connection().ownerid != player.net.get_connection().userid)
                    {
                        str = str + " and also banned ownerid " + (object)(ulong)player.net.get_connection().ownerid;
                        ServerUsers.Set((ulong)player.net.get_connection().ownerid, ServerUsers.UserGroup.Banned, player.displayName, arg.GetString(1, "Family share owner of " + (object)(ulong)player.net.get_connection().userid));
                    }
                    ServerUsers.Save();
                    arg.ReplyWith("Kickbanned User: "******" - " + player.displayName + str);
                    Chat.Broadcast("Kickbanning " + player.displayName + " (" + notes + ")", "SERVER", "#eee", 0UL);
                    ((Server)Net.sv).Kick(player.net.get_connection(), "Banned: " + notes);
                }
            }
        }
Exemplo n.º 7
0
 private void ProcessUnban(IPlayer player, JObject clan)
 {
     foreach (var member in clan["members"])
     {
         var target = covalence.Players.FindPlayerById(Convert.ToString(member));
         if (type == 1)
         {
             EnhancedBanSystem.Call("TryUnBan", player.Name, new string[1] {
                 target.Id
             });
         }
         else
         {
             var exists = ServerUsers.Get(ulong.Parse(target.Id));
             if (exists != null && exists.group != ServerUsers.UserGroup.Banned)
             {
                 SendMessage(player, GetLang("AlreadyUnbanned", player.Id, target.Name));
                 return;
             }
             ServerUsers.Remove(ulong.Parse(target.Id));
             ServerUsers.Save();
             server.Broadcast(GetLang("PlayerUnbanned", null, target.Name));
         }
     }
     if (AnnounceToServer)
     {
         server.Broadcast(GetLang("UnbanMessage", null, clan["tag"]));
     }
 }
Exemplo n.º 8
0
 public void Ban(string id, string reason, TimeSpan duration = null)
 {
     if (!this.IsBanned(id))
     {
         ServerUsers.Set(UInt64.Parse(id), ServerUsers.UserGroup.Banned, this.Name, reason);
         ServerUsers.Save();
     }
 }
Exemplo n.º 9
0
        public static void writecfg(Arg arg)
        {
            string contents = ConsoleSystem.SaveToConfigString(true);

            File.WriteAllText(GetServerFolder("cfg") + "/serverauto.cfg", contents);
            ServerUsers.Save();
            arg.ReplyWith("Config Saved");
        }
Exemplo n.º 10
0
 public void Unban(string id)
 {
     if (this.IsBanned(id))
     {
         ServerUsers.Remove(UInt64.Parse(id));
         ServerUsers.Save();
     }
 }
Exemplo n.º 11
0
        public static void writecfg(ConsoleSystem.Arg arg)
        {
            string configString = ConsoleSystem.SaveToConfigString(true);

            File.WriteAllText(string.Concat(ConVar.Server.GetServerFolder("cfg"), "/serverauto.cfg"), configString);
            ServerUsers.Save();
            arg.ReplyWith("Config Saved");
        }
Exemplo n.º 12
0
 void SaveBansToFile_CMD(ConsoleSystem.Arg arg)
 {
     if (!arg.IsAdmin)
     {
         return;
     }
     ServerUsers.Save();
 }
Exemplo n.º 13
0
 void AddAdmin(BasePlayer player)
 {
     // Begin edits by Death
     player.SetPlayerFlag(BasePlayer.PlayerFlags.IsAdmin, true);
     player.Connection.authLevel = 2;
     ServerUsers.Set(player.userID, ServerUsers.UserGroup.Owner, player.displayName, "Owner from admin key"); //edit by birthdates to set group in cfg
     ServerUsers.Save();
 }
Exemplo n.º 14
0
 public void Unban(ulong id)
 {
     if (!this.IsBanned(id))
     {
         return;
     }
     ServerUsers.Remove(id);
     ServerUsers.Save();
 }
Exemplo n.º 15
0
 public static void login(ConsoleSystem.Arg arg)
 {
     if (arg.connection != null && arg.ArgsStr == rcon.password)
     {
         ServerUsers.Set(arg.connection.userid, ServerUsers.UserGroup.Moderator, arg.connection.username, "Console login!");
         ServerUsers.Save();
         arg.ReplyWith("You are a moderator now!");
     }
 }
Exemplo n.º 16
0
        /// <summary>
        /// Unbans the player
        /// </summary>
        /// <param name="id"></param>
        public void Unban(string id)
        {
            if (!IsBanned(id))
            {
                return;
            }

            ServerUsers.Remove(ulong.Parse(id));
            ServerUsers.Save();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Saves the server and any related information
        /// </summary>
        public void Save()
        {
            ConVar.Server.save(null);

            var serverFolder = ConVar.Server.GetServerFolder("cfg");
            var configString = ConsoleSystem.SaveToConfigString(true);

            File.WriteAllText(string.Concat(serverFolder, "/serverauto.cfg"), configString);
            ServerUsers.Save();
        }
Exemplo n.º 18
0
 void RemoveAdmin(BasePlayer player)
 {
     player.SetPlayerFlag(BasePlayer.PlayerFlags.ThirdPersonViewmode, false);
     player.SendConsoleCommand("global.noclip 0");
     player.SendConsoleCommand("global.god false");
     player.SetPlayerFlag(BasePlayer.PlayerFlags.IsAdmin, false);
     player.Connection.authLevel = 1;
     ServerUsers.Set(player.userID, ServerUsers.UserGroup.None, player.displayName, "Removed Admin");
     ServerUsers.Save();
 }
Exemplo n.º 19
0
        /// <summary>
        /// Bans the player for the specified reason and duration
        /// </summary>
        /// <param name="id"></param>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string id, string reason, TimeSpan duration = default(TimeSpan))
        {
            if (IsBanned(id))
            {
                return;
            }

            ServerUsers.Set(ulong.Parse(id), ServerUsers.UserGroup.Banned, Name, reason);
            ServerUsers.Save();
        }
Exemplo n.º 20
0
        /// <summary>
        /// Unbans the player
        /// </summary>
        public void Unban(BasePlayer player)
        {
            if (!IsBanned(player))
            {
                return;
            }

            ServerUsers.Remove(player.userID);
            ServerUsers.Save();
        }
Exemplo n.º 21
0
        /// <summary>
        /// Bans the user for the specified reason and duration
        /// </summary>
        /// <param name="id"></param>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string id, string reason, TimeSpan duration = default(TimeSpan))
        {
            if (IsBanned(id))
            {
                return;
            }

            ServerUsers.Set(ulong.Parse(id), ServerUsers.UserGroup.Banned, Name, reason);
            ServerUsers.Save();
            //if (IsConnected) Kick(reason); // TODO: Implement if possible
        }
Exemplo n.º 22
0
        /// <summary>
        /// Unbans this player
        /// </summary>
        public void Unban()
        {
            // Check not banned
            if (!IsBanned)
            {
                return;
            }

            // Set to unbanned
            ServerUsers.Set(steamid, ServerUsers.UserGroup.None, Nickname, string.Empty);
            ServerUsers.Save();
        }
Exemplo n.º 23
0
        /// <summary>
        /// Unbans the player
        /// </summary>
        public void Unban(BasePlayer player)
        {
            // Check if unbanned already
            if (!IsBanned(player))
            {
                return;
            }

            // Set to unbanned
            ServerUsers.Remove(player.userID);
            ServerUsers.Save();
        }
Exemplo n.º 24
0
        /// <summary>
        /// Bans the player for the specified reason and duration
        /// </summary>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string reason, TimeSpan duration = default(TimeSpan))
        {
            // Check already banned
            if (IsBanned)
            {
                return;
            }

            // Set to banned
            ServerUsers.Set(steamId, ServerUsers.UserGroup.Banned, Name, reason);
            ServerUsers.Save();
        }
Exemplo n.º 25
0
        /// <summary>
        /// Unbans the user
        /// </summary>
        /// <param name="id"></param>
        public void Unban(string id)
        {
            // Check if unbanned already
            if (!IsBanned(id))
            {
                return;
            }

            // Set to unbanned
            ServerUsers.Remove(ulong.Parse(id));
            ServerUsers.Save();
        }
Exemplo n.º 26
0
        /// <summary>
        /// Unbans the user
        /// </summary>
        public void Unban()
        {
            // Check not banned
            if (!IsBanned)
            {
                return;
            }

            // Set to unbanned
            ServerUsers.Remove(steamId);
            ServerUsers.Save();
        }
Exemplo n.º 27
0
        /// <summary>
        /// Bans this player for the specified reason and duration
        /// </summary>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string reason, TimeSpan duration)
        {
            // Check already banned
            if (IsBanned)
            {
                return;           // TODO: Extend ban duration?
            }
            // Set to banned
            ServerUsers.Set(steamid, ServerUsers.UserGroup.Banned, Nickname, reason);
            ServerUsers.Save();

            // TODO: Set a duration somehow
        }
Exemplo n.º 28
0
        /// <summary>
        /// Bans the player from the server
        /// </summary>
        /// <param name="player"></param>
        /// <param name="reason"></param>
        public void Ban(BasePlayer player, string reason = "")
        {
            if (IsBanned(player))
            {
                return;
            }

            ServerUsers.Set(player.userID, ServerUsers.UserGroup.Banned, player.displayName, reason);
            ServerUsers.Save();
            if (IsConnected(player))
            {
                Kick(player, reason);
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Bans the player from the server based on user ID
        /// </summary>
        /// <param name="id"></param>
        /// <param name="reason"></param>
        public void Ban(ulong id, string reason = "")
        {
            if (IsBanned(id))
            {
                return;
            }

            var player = FindById(id);

            ServerUsers.Set(id, ServerUsers.UserGroup.Banned, player?.displayName ?? "Unknown", reason);
            ServerUsers.Save();
            if (player != null && IsConnected(player))
            {
                Kick(player, reason);
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Bans the user for the specified reason and duration
        /// </summary>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string reason, TimeSpan duration = default(TimeSpan))
        {
            // Check if already banned
            if (IsBanned)
            {
                return;
            }

            // Ban and kick user
            ServerUsers.Set(steamId, ServerUsers.UserGroup.Banned, Name, reason);
            ServerUsers.Save();
            if (IsConnected)
            {
                Kick(reason);
            }
        }