Esempio 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));
        }
Esempio n. 2
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);
            }
        }
Esempio 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();
                }
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
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();
     }
 }
Esempio n. 6
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!");
     }
 }
Esempio n. 7
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
        }
Esempio n. 8
0
        /// <summary>
        /// Bans the player from the server
        /// </summary>
        /// <param name="player"></param>
        /// <param name="reason"></param>
        public void Ban(BasePlayer player, string reason = "")
        {
            // Check if already banned
            if (IsBanned(player))
            {
                return;
            }

            // Ban and kick user
            ServerUsers.Set(player.userID, ServerUsers.UserGroup.Banned, player.displayName, reason);
            ServerUsers.Save();
            if (IsConnected(player))
            {
                Kick(player, reason);
            }
        }
Esempio n. 9
0
        public static void banid(ConsoleSystem.Arg arg)
        {
            ulong  num  = arg.GetUInt64(0, (ulong)0);
            string str  = arg.GetString(1, "unnamed");
            string str1 = arg.GetString(2, "no reason");

            if (num < 70000000000000000L)
            {
                arg.ReplyWith(string.Concat("This doesn't appear to be a 64bit steamid: ", num));
                return;
            }
            ServerUsers.User user = ServerUsers.Get(num);
            if (user != null && user.@group == ServerUsers.UserGroup.Banned)
            {
                arg.ReplyWith(string.Concat("User ", num, " is already banned"));
                return;
            }
            ServerUsers.Set(num, ServerUsers.UserGroup.Banned, str, str1);
            arg.ReplyWith(string.Concat(new object[] { "Banned User: "******" - ", str }));
        }
Esempio n. 10
0
        public static void ownerid(Arg arg)
        {
            ulong  uInt    = arg.GetUInt64(0, 0uL);
            string @string = arg.GetString(1, "unnamed");
            string string2 = arg.GetString(2, "no reason");

            if (uInt < 70000000000000000L)
            {
                arg.ReplyWith("This doesn't appear to be a 64bit steamid: " + uInt);
                return;
            }
            ServerUsers.User user = ServerUsers.Get(uInt);
            if (user != null && user.group == ServerUsers.UserGroup.Owner)
            {
                arg.ReplyWith("User " + uInt + " is already an Owner");
                return;
            }
            ServerUsers.Set(uInt, ServerUsers.UserGroup.Owner, @string, string2, -1L);
            arg.ReplyWith("Added owner " + @string + ", steamid " + uInt);
        }
Esempio n. 11
0
        public static void banid(Arg arg)
        {
            ulong  uInt    = arg.GetUInt64(0, 0uL);
            string text    = arg.GetString(1, "unnamed");
            string @string = arg.GetString(2, "no reason");

            if (uInt < 70000000000000000L)
            {
                arg.ReplyWith("This doesn't appear to be a 64bit steamid: " + uInt);
                return;
            }
            ServerUsers.User user = ServerUsers.Get(uInt);
            if (user != null && user.group == ServerUsers.UserGroup.Banned)
            {
                arg.ReplyWith("User " + uInt + " is already banned");
            }
            else
            {
                long   expiry;
                string durationSuffix;
                if (!TryGetBanExpiry(arg, 3, out expiry, out durationSuffix))
                {
                    return;
                }
                string     text2      = "";
                BasePlayer basePlayer = BasePlayer.FindByID(uInt);
                if (basePlayer != null && basePlayer.IsConnected)
                {
                    text = basePlayer.displayName;
                    if (basePlayer.IsConnected && basePlayer.net.connection.ownerid != 0L && basePlayer.net.connection.ownerid != basePlayer.net.connection.userid)
                    {
                        text2 += $" and also banned ownerid {basePlayer.net.connection.ownerid}";
                        ServerUsers.Set(basePlayer.net.connection.ownerid, ServerUsers.UserGroup.Banned, basePlayer.displayName, arg.GetString(1, $"Family share owner of {basePlayer.net.connection.userid}"), expiry);
                    }
                    Chat.Broadcast("Kickbanning " + basePlayer.displayName + durationSuffix + " (" + @string + ")", "SERVER", "#eee", 0uL);
                    Network.Net.sv.Kick(basePlayer.net.connection, "Banned" + durationSuffix + ": " + @string);
                }
                ServerUsers.Set(uInt, ServerUsers.UserGroup.Banned, text, @string, expiry);
                arg.ReplyWith($"Banned User{durationSuffix}: {uInt} - \"{text}\" for \"{@string}\"{text2}");
            }
        }
Esempio n. 12
0
 void OnPlayerAttack(BasePlayer attacker, HitInfo info)
 {
     if (attacker != null && Armed.Contains(attacker.userID))
     {
         BasePlayer victim = info?.HitEntity.ToPlayer();
         if (victim == null)
         {
             return;
         }
         if (attacker.GetActiveItem().info?.shortname == configData.Settings.Ban_Weapon)
         {
             if (victim.IsConnected)
             {
                 victim.Kick(msg("reason").Replace("{0}", attacker.displayName));
             }
             ServerUsers.Set(victim.userID, ServerUsers.UserGroup.Banned, "", "");
             ServerUsers.Save();
             rust.BroadcastChat(null, msg("banned").Replace("{0}", attacker.displayName).Replace("{1}", victim.displayName));
         }
     }
 }