예제 #1
0
        protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            EventHandlers.LogCommandUsed((CommandSender)sender, EventHandlers.FormatArguments(arguments, 0));
            if (!CommandProcessor.CheckPermissions(((CommandSender)sender), "broadcast", PlayerPermissions.Broadcasting, "AdminTools", false))
            {
                response = "You do not have permission to use this command";
                return(false);
            }

            if (arguments.Count < 2)
            {
                response = "Usage: adminbroadcast (time) (message)";
                return(false);
            }

            if (!ushort.TryParse(arguments.At(0), out ushort t))
            {
                response = $"Invalid value for broadcast time: {arguments.At(0)}";
                return(false);
            }

            foreach (Player Pl in Player.List)
            {
                if (Pl.ReferenceHub.serverRoles.RemoteAdmin)
                {
                    Pl.Broadcast(t, EventHandlers.FormatArguments(arguments, 1) + $" - {((CommandSender)sender).Nickname}", Broadcast.BroadcastFlags.AdminChat);
                }
            }

            response = $"Message sent to all currently online staff";
            return(true);
        }
예제 #2
0
        protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            EventHandlers.LogCommandUsed((CommandSender)sender, EventHandlers.FormatArguments(arguments, 0));
            if (!CommandProcessor.CheckPermissions(((CommandSender)sender), "broadcast", PlayerPermissions.Broadcasting, "AdminTools", false))
            {
                response = "You do not have permission to use this command";
                return(false);
            }

            if (arguments.Count < 2)
            {
                response = "Usage: playerbroadcast (player id / name) (time) (message)";
                return(false);
            }

            Player Ply = Player.Get(arguments.At(0));

            if (Ply == null)
            {
                response = $"Player not found: {arguments.At(0)}";
                return(false);
            }

            if (!ushort.TryParse(arguments.At(1), out ushort time) && time <= 0)
            {
                response = $"Invalid value for duration: {arguments.At(1)}";
                return(false);
            }

            Ply.Broadcast(time, EventHandlers.FormatArguments(arguments, 2));
            response = $"Message sent to {Ply.Nickname}";
            return(true);
        }
예제 #3
0
        protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            if (!CommandProcessor.CheckPermissions(((CommandSender)sender), "forceend", PlayerPermissions.RoundEvents, "ForceRoundEnd", false))
            {
                response = "You do not have permission to run this command!";
                return(false);
            }

            if (arguments.Count != 0)
            {
                response = "Usage: forceend";
                return(false);
            }

            if (!Round.IsStarted)
            {
                response = "Please start the round before using this command!";
                return(false);
            }

            if (Player.List.Count() == 0)
            {
                response = "Please have at least 1 player before attempting to run this command";
                return(false);
            }

            RoundSummary.singleton._keepRoundOnOne = false;
            if (Player.List.Count() > 1)
            {
                RoundSummary.RoundLock = false;
                RoundSummary.singleton.ForceEnd();
            }
            response = "The round has ended now";
            return(true);
        }
예제 #4
0
        protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            EventHandlers.LogCommandUsed((CommandSender)sender, EventHandlers.FormatArguments(arguments, 0));
            if (!CommandProcessor.CheckPermissions(((CommandSender)sender), "ahp", PlayerPermissions.PlayersManagement, "AdminTools", false))
            {
                response = "You do not have permission to use this command";
                return(false);
            }

            if (arguments.Count != 2)
            {
                response = "Usage: ahp ((player id / name) or (all / *)) (value)";
                return(false);
            }

            switch (arguments.At(0))
            {
            case "*":
            case "all":
                if (!int.TryParse(arguments.At(1), out int value) || value < 0)
                {
                    response = $"Invalid value for AHP: {value}";
                    return(false);
                }

                foreach (Player Ply in Player.List)
                {
                    Ply.AdrenalineHealth = value;
                }

                response = $"Everyone's AHP was set to {value}";
                return(true);

            default:
                Player Pl = Player.Get(arguments.At(0));
                if (Pl == null)
                {
                    response = $"Player not found: {arguments.At(0)}";
                    return(false);
                }

                if (!int.TryParse(arguments.At(1), out int val) || val < 0)
                {
                    response = $"Invalid value for AHP: {val}";
                    return(false);
                }

                Pl.AdrenalineHealth = val;
                response            = $"Player {Pl.Nickname}'s AHP was set to {val}";
                return(true);
            }
        }
예제 #5
0
        protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            EventHandlers.LogCommandUsed((CommandSender)sender, EventHandlers.FormatArguments(arguments, 0));
            if (!CommandProcessor.CheckPermissions(((CommandSender)sender), "restartonend", PlayerPermissions.ServerConsoleCommands, "AdminTools", false))
            {
                response = "You do not have permission to use this command";
                return(false);
            }

            Plugin.RestartOnEnd = !Plugin.RestartOnEnd;
            response            = $"The server will{(Plugin.RestartOnEnd ? " " : " no longer ")}automatically restart the next time the round ends!";

            return(true);
        }
예제 #6
0
        protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            EventHandlers.LogCommandUsed((CommandSender)sender, EventHandlers.FormatArguments(arguments, 0));
            if (!CommandProcessor.CheckPermissions(((CommandSender)sender), "randomtp", PlayerPermissions.PlayersManagement, "AdminTools", false))
            {
                response = "You do not have permission to use this command";
                return(false);
            }

            if (arguments.Count != 1)
            {
                response = "Usage: randomtp ((player id / name) or (all / *))";
                return(false);
            }

            switch (arguments.At(0))
            {
            case "*":
            case "all":
                foreach (Player Ply in Player.List)
                {
                    Room RandRoom = Map.Rooms[Plugin.NumGen.Next(0, Map.Rooms.Count())];
                    Ply.Position = RandRoom.Position + Vector3.up;
                }

                response = $"Everyone was teleported to a random room in the facility";
                return(true);

            default:
                Player Pl = Player.Get(arguments.At(0));
                if (Pl == null)
                {
                    response = $"Player not found: {arguments.At(0)}";
                    return(false);
                }

                Room Rand = Map.Rooms[Plugin.NumGen.Next(0, Map.Rooms.Count())];
                Pl.Position = Rand.Position + Vector3.up;

                response = $"Player {Pl.Nickname} was teleported to {Rand.Name}";
                return(true);
            }
        }
예제 #7
0
        protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            EventHandlers.LogCommandUsed((CommandSender)sender, EventHandlers.FormatArguments(arguments, 0));
            if (!CommandProcessor.CheckPermissions(((CommandSender)sender), "strip", PlayerPermissions.PlayersManagement, "AdminTools", false))
            {
                response = "You do not have permission to use this command";
                return(false);
            }

            if (arguments.Count != 1)
            {
                response = "Usage: strip ((player id / name) or (all / *))";
                return(false);
            }

            switch (arguments.At(0))
            {
            case "*":
            case "all":
                foreach (Player Ply in Player.List)
                {
                    Ply.ClearInventory();
                }

                response = "Everyone's inventories have been cleared now";
                return(true);

            default:
                Player Pl = Player.Get(arguments.At(0));
                if (Pl == null)
                {
                    response = $"Player not found: {arguments.At(0)}";
                    return(false);
                }

                Pl.ClearInventory();
                response = $"Player {Pl.Nickname}'s inventory have been cleared now";
                return(true);
            }
        }
        public void ApplyTeleportEffects(Player Ply, List <string> Effects)
        {
            if (Ply == null)
            {
                return;
            }
            if (Effects.Count == 0)
            {
                return;
            }

            foreach (string effect in Effects)
            {
                string[] args = effect.Split((":").ToCharArray());
                switch (args.First().ToLower())
                {
                case "addahp":
                    if (Ply.Role == RoleType.Scp096)
                    {
                        continue;
                    }
                    try
                    {
                        Ply.AdrenalineHealth += Convert.ToInt32(args.ElementAt(1));
                    }
                    catch
                    {
                        Log.Warn($"WARNING: SCP-914 Teleportation effects configured incorrectly. \"{effect}\" arguments are not valid.");
                    }
                    break;

                case "applyeffect":
                    try
                    {
                        Ply.ReferenceHub.playerEffectsController.EnableByString(args.ElementAt(1), Convert.ToInt32(args.ElementAt(2)));
                    }
                    catch
                    {
                        Log.Warn($"WARNING: SCP-914 Teleportation effects configured incorrectly. \"{effect}\" arguments are not valid.");
                    }
                    break;

                case "broadcast":
                    try
                    {
                        int    type = Convert.ToInt32(args.ElementAt(1));
                        int    dur  = Convert.ToInt32(args.ElementAt(2));
                        string msg  = string.Join(" ", args.Skip(3));
                        IEnumerable <Player> Plrs = new List <Player> {
                        };
                        switch (type)
                        {
                        case 0:
                            Plrs = new List <Player> {
                                Ply
                            };
                            break;

                        case 1:
                            Plrs = Player.List;
                            break;

                        case 2:
                            Plrs = Player.List.Where(p => p.Team == Team.SCP);
                            break;

                        case 3:
                            Plrs = Player.List.Where(p => CommandProcessor.CheckPermissions(p.Sender, "AdminChat", PlayerPermissions.AdminChat));
                            break;

                        default:
                            Log.Warn($"WARNING: SCP-914 Teleportation effects configured incorrectly. \"{effect}\" first argument (type) is invalid.");
                            break;
                        }
                        foreach (Player ToSend in Plrs)
                        {
                            ToSend.ClearBroadcasts();
                            ToSend.Broadcast((ushort)dur, msg.Replace("{Name}", Ply.Nickname).Replace("{Room}", GetRoomName(Ply.CurrentRoom)).Replace("{Class}", $"<color={Ply.Role.GetColor().ToHex()}>{Constants.ClassStrings[Ply.Role.ToString()]}</color>") + "\n");
                        }
                    }
                    catch
                    {
                        Log.Warn($"WARNING: SCP-914 Teleportation effects configured incorrectly. \"{effect}\" arguments are not valid.");
                    }
                    break;

                case "damage":
                    try
                    {
                        int amt = Convert.ToInt32(args.ElementAt(1));
                        if (Ply.IsGodModeEnabled == false)
                        {
                            Ply.Hurt(amt, DamageTypes.Wall, "SCP-914 Teleportation");
                        }
                    }
                    catch
                    {
                        Log.Warn($"WARNING: SCP-914 Teleportation effects configured incorrectly. \"{effect}\" arguments are not valid.");
                    }
                    break;

                case "dropitems":
                    try
                    {
                        if (args.ElementAt(1) == "all" || args.ElementAt(1) == "*")
                        {
                            Ply.Inventory.ServerDropAll();
                        }
                        else
                        {
                            int amount = Convert.ToInt32(args.ElementAt(1));
                            for (int i = 0; i < amount; i++)
                            {
                                int pos = rnd.Next(0, Ply.Inventory.items.Count() - 1);
                                Ply.DropItem(Ply.Inventory.items.ElementAt(pos));
                            }
                            ;
                        }
                    }
                    catch
                    {
                        Log.Warn($"WARNING: SCP-914 Teleportation effects configured incorrectly. \"{effect}\" arguments are not valid.");
                    }
                    break;

                case "god":
                    try
                    {
                        if (!Ply.IsGodModeEnabled)     // do not toggle godmode if they already had it on - that defeats the point
                        {
                            Ply.IsGodModeEnabled = true;
                            Timing.CallDelayed((float)Convert.ToInt32(args.ElementAt(1)), () =>
                            {
                                Ply.IsGodModeEnabled = false;
                            });
                        }
                    }
                    catch
                    {
                        Log.Warn($"WARNING: SCP-914 Teleportation effects configured incorrectly. \"{effect}\" arguments are not valid.");
                    }
                    break;

                case "stamina":
                    if (Ply.Team == Team.SCP)
                    {
                        break;
                    }
                    try
                    {
                        int amt = Convert.ToInt32(args.ElementAt(1)) / 100;
                        Ply.Stamina.RemainingStamina = amt;
                    }
                    catch
                    {
                        Log.Warn($"WARNING: SCP-914 Teleportation effects configured incorrectly. \"{effect}\" arguments are not valid.");
                    }
                    break;

                default:
                    Log.Warn($"WARNING: SCP-914 Teleportation effects configured incorrectly. Invalid effect type: {effect}.");
                    break;
                }
            }
        }
예제 #9
0
        protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            EventHandlers.LogCommandUsed((CommandSender)sender, EventHandlers.FormatArguments(arguments, 0));
            if (!CommandProcessor.CheckPermissions(((CommandSender)sender), "broadcast", PlayerPermissions.Broadcasting, "AdminTools", false))
            {
                response = "You do not have permission to use this command";
                return(false);
            }

            if (arguments.Count < 1)
            {
                response = "Usage:\nbroadcast (time) (message)" +
                           "\nbroadcast user (player id / name) (time) (message)" +
                           "\nbroadcast users (player id / name group (i.e.: 1,2,3 or hello,there,hehe)) (time) (message)" +
                           "\nbroadcast group (group name) (time) (message)" +
                           "\nbroadcast groups (list of groups (i.e.: owner,admin,moderator)) (time) (message)" +
                           "\nbroadcast role (RoleType) (time) (message)" +
                           "\nbroadcast roles (RoleType group (i.e.: ClassD,Scientist,NtfCadet)) (time) (message)" +
                           "\nbroadcast (random / someone) (time) (message)" +
                           "\nbroadcast (staff / admin) (time) (message)" +
                           "\nbroadcast clearall";
                return(false);
            }

            switch (arguments.At(0))
            {
            case "user":
                if (arguments.Count < 4)
                {
                    response = "Usage: broadcast user (player id / name) (time) (message)";
                    return(false);
                }

                Player Ply = Player.Get(arguments.At(1));
                if (Ply == null)
                {
                    response = $"Player not found: {arguments.At(1)}";
                    return(false);
                }

                if (!ushort.TryParse(arguments.At(2), out ushort time) && time <= 0)
                {
                    response = $"Invalid value for duration: {arguments.At(2)}";
                    return(false);
                }

                Ply.Broadcast(time, EventHandlers.FormatArguments(arguments, 3));
                response = $"Message sent to {Ply.Nickname}";
                return(true);

            case "users":
                if (arguments.Count < 4)
                {
                    response = "Usage: broadcast users (player id / name group (i.e.: 1,2,3 or hello,there,hehe)) (time) (message)";
                    return(false);
                }

                string[]      Users   = arguments.At(1).Split(',');
                List <Player> PlyList = new List <Player>();
                foreach (string s in Users)
                {
                    if (int.TryParse(s, out int id) && Player.Get(id) != null)
                    {
                        PlyList.Add(Player.Get(id));
                    }
                    else if (Player.Get(s) != null)
                    {
                        PlyList.Add(Player.Get(s));
                    }
                }

                if (!ushort.TryParse(arguments.At(2), out ushort tme) && tme <= 0)
                {
                    response = $"Invalid value for duration: {arguments.At(2)}";
                    return(false);
                }

                foreach (Player P in PlyList)
                {
                    P.Broadcast(tme, EventHandlers.FormatArguments(arguments, 3));
                }


                StringBuilder Builder = StringBuilderPool.Shared.Rent("Message sent to players: ");
                foreach (Player P in PlyList)
                {
                    Builder.Append("\"");
                    Builder.Append(P.Nickname);
                    Builder.Append("\"");
                    Builder.Append(" ");
                }
                string message = Builder.ToString();
                StringBuilderPool.Shared.Return(Builder);
                response = message;
                return(true);

            case "group":
                if (arguments.Count < 4)
                {
                    response = "Usage: broadcast group (group) (time) (message)";
                    return(false);
                }

                UserGroup BroadcastGroup = ServerStatic.PermissionsHandler.GetGroup(arguments.At(1));
                if (BroadcastGroup == null)
                {
                    response = $"Invalid group: {arguments.At(1)}";
                    return(false);
                }

                if (!ushort.TryParse(arguments.At(2), out ushort tim) && tim <= 0)
                {
                    response = $"Invalid value for duration: {arguments.At(2)}";
                    return(false);
                }

                foreach (Player player in Player.List)
                {
                    if (player.Group.BadgeText.Equals(BroadcastGroup.BadgeText))
                    {
                        player.Broadcast(tim, EventHandlers.FormatArguments(arguments, 3));
                    }
                }

                response = $"Message sent to all members of \"{arguments.At(1)}\"";
                return(true);

            case "groups":
                if (arguments.Count < 4)
                {
                    response = "Usage: broadcast groups (list of groups (i.e.: owner,admin,moderator)) (time) (message)";
                    return(false);
                }

                string[]      Groups    = arguments.At(1).Split(',');
                List <string> GroupList = new List <string>();
                foreach (string s in Groups)
                {
                    UserGroup BroadGroup = ServerStatic.PermissionsHandler.GetGroup(s);
                    if (BroadGroup != null)
                    {
                        GroupList.Add(BroadGroup.BadgeText);
                    }
                }

                if (!ushort.TryParse(arguments.At(2), out ushort e) && e <= 0)
                {
                    response = $"Invalid value for duration: {arguments.At(2)}";
                    return(false);
                }

                foreach (Player P in Player.List)
                {
                    if (GroupList.Contains(P.Group.BadgeText))
                    {
                        P.Broadcast(e, EventHandlers.FormatArguments(arguments, 3));
                    }
                }


                StringBuilder Bdr = StringBuilderPool.Shared.Rent("Message sent to groups with badge text: ");
                foreach (string P in GroupList)
                {
                    Bdr.Append("\"");
                    Bdr.Append(P);
                    Bdr.Append("\"");
                    Bdr.Append(" ");
                }
                string ms = Bdr.ToString();
                StringBuilderPool.Shared.Return(Bdr);
                response = ms;
                return(true);

            case "role":
                if (arguments.Count < 4)
                {
                    response = "Usage: broadcast role (RoleType) (time) (message)";
                    return(false);
                }

                if (!Enum.TryParse(arguments.At(1), true, out RoleType Role))
                {
                    response = $"Invalid value for RoleType: {arguments.At(1)}";
                    return(false);
                }

                if (!ushort.TryParse(arguments.At(2), out ushort te) && te <= 0)
                {
                    response = $"Invalid value for duration: {arguments.At(2)}";
                    return(false);
                }

                foreach (Player Player in Player.List)
                {
                    if (Player.Role == Role)
                    {
                        Player.Broadcast(te, EventHandlers.FormatArguments(arguments, 3));
                    }
                }

                response = $"Message sent to all members of \"{arguments.At(1)}\"";
                return(true);

            case "roles":
                if (arguments.Count < 4)
                {
                    response = "Usage: broadcast roles (RoleType group (i.e.: ClassD, Scientist, NtfCadet)) (time) (message)";
                    return(false);
                }

                string[]        Roles    = arguments.At(1).Split(',');
                List <RoleType> RoleList = new List <RoleType>();
                foreach (string s in Roles)
                {
                    if (Enum.TryParse(s, true, out RoleType R))
                    {
                        RoleList.Add(R);
                    }
                }

                if (!ushort.TryParse(arguments.At(2), out ushort ti) && ti <= 0)
                {
                    response = $"Invalid value for duration: {arguments.At(2)}";
                    return(false);
                }

                foreach (Player P in Player.List)
                {
                    if (RoleList.Contains(P.Role))
                    {
                        P.Broadcast(ti, EventHandlers.FormatArguments(arguments, 3));
                    }
                }

                StringBuilder Build = StringBuilderPool.Shared.Rent("Message sent to roles: ");
                foreach (RoleType Ro in RoleList)
                {
                    Build.Append("\"");
                    Build.Append(Ro.ToString());
                    Build.Append("\"");
                    Build.Append(" ");
                }
                string msg = Build.ToString();
                StringBuilderPool.Shared.Return(Build);
                response = msg;
                return(true);

            case "random":
            case "someone":
                if (arguments.Count < 3)
                {
                    response = "Usage: broadcast (random / someone) (time) (message)";
                    return(false);
                }

                if (!ushort.TryParse(arguments.At(1), out ushort me) && me <= 0)
                {
                    response = $"Invalid value for duration: {arguments.At(1)}";
                    return(false);
                }

                Player Plyr = Player.List.ToList()[Plugin.NumGen.Next(0, Player.List.Count())];
                Plyr.Broadcast(me, EventHandlers.FormatArguments(arguments, 2));
                response = $"Message sent to {Plyr.Nickname}";
                return(true);

            case "staff":
            case "admin":
                if (arguments.Count < 3)
                {
                    response = "Usage: broadcast (staff / admin) (time) (message)";
                    return(false);
                }

                if (!ushort.TryParse(arguments.At(1), out ushort t))
                {
                    response = $"Invalid value for broadcast time: {arguments.At(1)}";
                    return(false);
                }

                foreach (Player Pl in Player.List)
                {
                    if (Pl.ReferenceHub.serverRoles.RemoteAdmin)
                    {
                        Pl.Broadcast(t, EventHandlers.FormatArguments(arguments, 2) + $" - {((CommandSender)sender).Nickname}", Broadcast.BroadcastFlags.AdminChat);
                    }
                }

                response = $"Message sent to all currently online staff";
                return(true);

            case "clearall":
                if (arguments.Count != 1)
                {
                    response = "Usage: broadcast clearall";
                    return(false);
                }

                PlayerManager.localPlayer.GetComponent <Broadcast>().RpcClearElements();
                response = "All current broadcasts have been cleared";
                return(true);

            default:
                if (arguments.Count < 2)
                {
                    response = "Usage: broadcast (time) (message)";
                    return(false);
                }

                if (!ushort.TryParse(arguments.At(0), out ushort tm))
                {
                    response = $"Invalid value for broadcast time: {arguments.At(0)}";
                    return(false);
                }
                Map.Broadcast(tm, EventHandlers.FormatArguments(arguments, 1));
                break;
            }
            response = "";
            return(false);
        }