Beispiel #1
0
        void ccmdRemoveGive(ConsoleSystem.Arg arg)
        {
            if (arg.Args == null || arg.Args.Length == 0)
            {
                SendReply(arg, "remove.give PLAYER/STEAMID optional:Time");
                return;
            }
            if (arg.connection != null)
            {
                if (!hasAccess(arg.connection.player as BasePlayer, targetPermission, adminAuthLevel))
                {
                    return;
                }
            }
            BasePlayer targetPlayer;
            var        success = FindOnlinePlayer(arg.Args[0], out targetPlayer);

            if (success is string)
            {
                SendReply(arg, (string)success);
                return;
            }
            int removeTime = RemoveTimeDefault;

            if (arg.Args.Length > 1)
            {
                int.TryParse(arg.Args[1], out removeTime);
            }
            if (removeTime > MaxRemoveTime)
            {
                removeTime = MaxRemoveTime;
            }
            ToolRemover toolremover = targetPlayer.GetComponent <ToolRemover>();

            if (toolremover == null)
            {
                toolremover = targetPlayer.gameObject.AddComponent <ToolRemover>();
            }
            toolremover.endTime         = removeTime;
            toolremover.removeType      = RemoveType.Normal;
            toolremover.playerActivator = targetPlayer;
            toolremover.distance        = playerDistanceRemove;
            toolremover.RefreshDestroy();

            SendReply(arg, string.Format("Remover tool was given for {1}s to {0}", targetPlayer.displayName, removeTime.ToString()));
        }
Beispiel #2
0
        void cmdChatRemove(BasePlayer player, string command, string[] args)
        {
            int        removeTime     = RemoveTimeDefault;
            BasePlayer target         = player;
            RemoveType removetype     = RemoveType.Normal;
            int        distanceRemove = playerDistanceRemove;

            if (args.Length != 0)
            {
                switch (args[0])
                {
                case "admin":
                    if (!hasAccess(player, adminPermission, adminAuthLevel))
                    {
                        return;
                    }
                    removetype     = RemoveType.Admin;
                    distanceRemove = adminDistanceRemove;
                    if (args.Length > 1)
                    {
                        int.TryParse(args[1], out removeTime);
                    }
                    break;

                case "all":
                    if (!hasAccess(player, allPermission, adminAuthLevel))
                    {
                        return;
                    }
                    removetype     = RemoveType.All;
                    distanceRemove = allDistanceRemove;
                    if (args.Length > 1)
                    {
                        int.TryParse(args[1], out removeTime);
                    }
                    break;

                case "target":
                    if (!hasAccess(player, targetPermission, adminAuthLevel))
                    {
                        return;
                    }
                    if (args.Length == 1)
                    {
                        SendReply(player, "/remove target PLAYERNAME/STEAMID optional:Time");
                        return;
                    }
                    BasePlayer tempTarget = null;
                    var        success    = FindOnlinePlayer(args[1], out tempTarget);
                    if (success is string)
                    {
                        SendReply(player, (string)success);
                        return;
                    }
                    target = tempTarget;
                    if (args.Length > 2)
                    {
                        int.TryParse(args[2], out removeTime);
                    }

                    break;

                default:
                    if (!hasAccess(player, normalPermission, playerAuthLevel))
                    {
                        return;
                    }
                    if (overrideDisabled)
                    {
                        SendReply(player, MessageOverrideDisabled);
                        return;
                    }
                    int.TryParse(args[0], out removeTime);
                    break;
                }
            }

            if (removeTime > MaxRemoveTime)
            {
                removeTime = MaxRemoveTime;
            }

            ToolRemover toolremover = target.GetComponent <ToolRemover>();

            if (toolremover != null && args.Length == 0)
            {
                EndRemoverTool(target);
                SendReply(player, string.Format(MessageToolDeactivated, target.displayName));
                return;
            }

            if (toolremover == null)
            {
                toolremover = target.gameObject.AddComponent <ToolRemover>();
            }

            toolremover.endTime         = removeTime;
            toolremover.removeType      = removetype;
            toolremover.playerActivator = player;
            toolremover.distance        = (int)distanceRemove;
            toolremover.RefreshDestroy();
        }