Ejemplo n.º 1
0
        public override Task <bool> Handle(ConsoleCommandEvent <MessagingConsoleCommand> request, CancellationToken cancellationToken)
        {
            if (request.Command.Echo)
            {
                this.messageBroker
                .Subscribe <EchoMessage, EchoMessageHandler>()
                .Subscribe <EntityMessage <EchoEntity>, EchoEntityMessageHandler>();

                Console.WriteLine("\r\nstart publish", Color.LimeGreen);

                for (var i = 1; i <= 2; i++)
                {
                    //Thread.Sleep(500);
                    this.messageBroker.Publish(new EchoMessage {
                        Text = $"+++ hello from echo message ({i.ToString()}-{RandomGenerator.GenerateString(3, false).ToUpper()}) +++"
                    });
                    this.messageBroker.Publish(new EntityMessage <EchoEntity> {
                        Entity = new EchoEntity {
                            Text = $"+++ hello from echo entity message ({i}-{RandomGenerator.GenerateString(3, false).ToUpper()} +++"
                        }
                    });
                }
            }

            return(Task.FromResult(true));
        }
 internal void PlayerCmd(ConsoleCommandEvent ev)
 {
     if (ev.Player.CheckPermission("fitem.dropitem") && ev.Command.ToLower().StartsWith("fitems"))
     {
         if (activeUsersFitems.Contains(ev.Player.GetUserId()))
         {
             activeUsersFitems.Remove(ev.Player.GetUserId());
             ev.ReturnMessage = "Floating items disabled.";
             return;
         }
         else
         {
             activeUsersFitems.Add(ev.Player.GetUserId());
             ev.ReturnMessage = "Floating items enabled.";
             return;
         }
     }
     if (ev.Player.CheckPermission("fitem.shootitem") && ev.Command.ToLower().StartsWith("sitems"))
     {
         if (activeUsersSitems.Contains(ev.Player.GetUserId()))
         {
             activeUsersSitems.Remove(ev.Player.GetUserId());
             ev.ReturnMessage = "Shootable items disabled.";
             return;
         }
         else
         {
             activeUsersSitems.Add(ev.Player.GetUserId());
             ev.ReturnMessage = "Shootable items enabled.";
             return;
         }
     }
 }
Ejemplo n.º 3
0
        public override Task <bool> Handle(ConsoleCommandEvent <OpenBrowserConsoleCommand> request, CancellationToken cancellationToken)
        {
            if (this.server != null)
            {
                var url = this.server?.Features?.Get <IServerAddressesFeature>()?.Addresses?.First();

                if (request.Command.Logs)
                {
                    url += "/naos/operations/logevents/dashboard";
                }
                else if (request.Command.Traces)
                {
                    url += "/naos/operations/logtraces/dashboard";
                }
                else if (request.Command.Journal)
                {
                    url += "/naos/operations/logevents/dashboard?q=TrackType=journal";
                }
                else if (request.Command.Swagger)
                {
                    url += "/swagger/index.html";
                }

                Console.WriteLine($"opening browser: {url}", Color.Gray);

                var browser =
                    IsOSPlatform(Windows) ? new ProcessStartInfo("cmd", $"/c start {url}") :
                    IsOSPlatform(OSX) ? new ProcessStartInfo("open", url) :
                    new ProcessStartInfo("xdg-open", url); //linux

                Process.Start(browser);
            }

            return(Task.FromResult(true));
        }
Ejemplo n.º 4
0
        public override async Task <bool> Handle(ConsoleCommandEvent <TracesConsoleCommand> request, CancellationToken cancellationToken)
        {
            if (request.Command.Recent)
            {
                var filterContext = LoggingFilterContext.Prepare(); // add some default criteria

                var entities = await this.repository.FindAllAsync(
                    filterContext.GetSpecifications <LogTrace>().Insert(new Specification <LogTrace>(t => t.TrackType == "trace")),
                    filterContext.GetFindOptions <LogTrace>(),
                    cancellationToken).AnyContext();

                var nodes = Node <LogTrace> .ToHierarchy(entities, l => l.SpanId, l => l.ParentSpanId, true);

                if (request.Command.Count > 0)
                {
                    nodes = nodes.Take(request.Command.Count);
                }

                await nodes.RenderConsole(
                    t => $"{t.Message} ({t.SpanId}/{t.ParentSpanId}) -> took {t.Duration.Humanize()}",
                    t => $"{t.Timestamp.ToUniversalTime():u} [{t.Kind?.ToUpper().Truncate(6, string.Empty)}] ",
                    orderBy : t => t.Ticks).AnyContext();
            }

            return(true);
        }
Ejemplo n.º 5
0
        internal void InvokeConsoleCommandEvent(Player player, string command)
        {
            var ev = new ConsoleCommandEventArgs {
                Command = command, Player = player
            };

            ConsoleCommandEvent?.Invoke(ev);
        }
Ejemplo n.º 6
0
 public void OnConsoleCommand(ConsoleCommandEvent ev)
 {
     if (!Sitrep.Events.Contains("consolecommandevent"))
     {
         return;
     }
     if (!Sitrep.CustomChannelIds.TryGetValue("consolecommandevent", out ulong channel))
     {
         channel = Sitrep.EventsId;
     }
     Send($":desktop_computer: [{ev.Sender.Role.AsString()}] {ev.Sender.Nick.DiscordSanitize()} ({ev.Sender.ParsedUserId}) použil příkaz `{ev.Command}`", channel);
 }
Ejemplo n.º 7
0
 internal void PlyCmd(ConsoleCommandEvent ev)
 {
     if (!PluginMain.ammo.ContainsKey(ev.Player))
     {
         PluginMain.ammo.Add(ev.Player, new Ammo(ev.Player));
     }
     if (ev.Command.ToLower() == "ammo")
     {
         ev.Player.SendConsoleMessage(PluginMain.ammo[ev.Player].ToString(), "cyan");
         ev.ReturnMessage = "";
     }
 }
Ejemplo n.º 8
0
        public override Task <bool> Handle(ConsoleCommandEvent <StartupTaskConsoleCommand> request, CancellationToken cancellationToken)
        {
            // TODO: provide possibility to start a specific task (task.StartAsync())

            if (request.Command.List)
            {
                foreach (var task in this.tasks.Safe()
                         .OrderBy(t => t.GetType().PrettyName()))
                {
                    Console.WriteLine($"- {task.GetType().PrettyName()}", Color.Gray);
                }
            }

            return(Task.FromResult(true));
        }
Ejemplo n.º 9
0
        internal static void InvokeConsoleCommandEvent(Player player, string command, out bool allow)
        {
            allow = true;
            if (ConsoleCommandEvent == null)
            {
                return;
            }

            var ev = new ConsoleCommandEvent
            {
                Command = command,
                Player  = player
            };

            ConsoleCommandEvent.Invoke(ev);
        }
Ejemplo n.º 10
0
        public override async Task <bool> Handle(ConsoleCommandEvent <QueueingConsoleCommand> request, CancellationToken cancellationToken)
        {
            if (request.Command.Echo)
            {
                await this.queue.ProcessItemsAsync(true, cancellationToken).AnyContext();

                for (var i = 1; i <= 5; i++)
                {
                    await this.queue.EnqueueAsync(new EchoQueueEventData { Text = $"+++ hello from queue item {i} +++" }).AnyContext();

                    //var metrics = this.queue.GetMetricsAsync().Result;
                    //Console.WriteLine(metrics.Dump());
                }
            }

            return(true);
        }
        public override async Task <bool> Handle(ConsoleCommandEvent <CustomerConsoleCommand> request, CancellationToken cancellationToken)
        {
            if (request.Command.Create)
            {
                var command = new CreateCustomerCommand(
                    new Domain.Customer
                {
                    Id        = IdGenerator.Instance.Next,
                    FirstName = "John",
                    LastName  = RandomGenerator.GenerateString(4, false),
                    Email     = $"John.{RandomGenerator.GenerateString(5, lowerCase: true)}@gmail.com"
                });

                var response = await this.mediator.Send(command).AnyContext();
            }

            return(true);
        }
Ejemplo n.º 12
0
        public void OnCallCommand(ConsoleCommandEvent ev)
        {
            if (!plugin.enable)
            {
                return;
            }

            if (ev.Command.StartsWith("mtfplist"))
            {
                if (plugin.Configs.userConsoleList != 1 && plugin.Configs.userConsoleList != 2)
                {
                    ev.ReturnMessage = "You are not allowed to see the list of MTFPlus classes in this server!";
                    return;
                }
                ev.ReturnMessage = "<color=\"white\">List:</color>";
                ev.Player.DelayListMessage();
            }
        }
        public override async Task <bool> Handle(ConsoleCommandEvent <QueueingConsoleCommand> request, CancellationToken cancellationToken)
        {
            if (request.Command.Echo)
            {
                await queue.ProcessItemsAsync(true).AnyContext();

                Console.WriteLine("\r\nstart enqueue", Color.LimeGreen);

                for (var i = 1; i <= 2; i++)
                {
                    await queue.EnqueueAsync(new EchoQueueEventData { Text = "+++ hello from queue item +++" }).AnyContext();

                    var metrics = queue.GetMetricsAsync().Result;
                    Console.WriteLine(metrics.Dump());
                }
            }

            return(true);
        }
        public override async Task <bool> Handle(ConsoleCommandEvent <JobSchedulerConsoleCommand> request, CancellationToken cancellationToken)
        {
            if (request.Command.Enable)
            {
                Console.WriteLine("\r\nenable", Color.LimeGreen);
                this.logger.LogInformation($"{LogKeys.JobScheduling:l} enabling");
                this.jobScheduler.Options.SetEnabled();
            }

            if (request.Command.Disable)
            {
                Console.WriteLine("\r\ndisable", Color.LimeGreen);
                this.logger.LogInformation($"{LogKeys.JobScheduling:l} disabling");
                this.jobScheduler.Options.SetEnabled(false);
            }

            if (request.Command.List)
            {
                foreach (var key in this.jobScheduler.Options.Registrations.Keys.Safe())
                {
                    Console.WriteLine($"[{key.Identifier}] {key.Key} ({key.Cron})");
                }
            }

            if (!request.Command.Trigger.IsNullOrEmpty())
            {
                Console.WriteLine($"\r\nstart job {request.Command.Trigger}", Color.LimeGreen);

                await this.jobScheduler.TriggerAsync(request.Command.Trigger).AnyContext();
            }

            var text = $@"status:
-enabled={this.jobScheduler.Options.Enabled}
-running={this.jobScheduler.IsRunning}";

            await Task.Run(() => System.Console.WriteLine(text), cancellationToken).AnyContext();

            return(true);
        }
Ejemplo n.º 15
0
        public void ConsoleCmd(ConsoleCommandEvent ev)
        {
            if (ev.Player.GetRole() == RoleType.Scp079)
            {
                string[] args = ev.Command.Split(' ');
                if (args[0].Equals(Plugin.CommandPrefix))
                {
                    if (args.Length >= 2)
                    {
                        if (args[1].ToLower().Equals("help") || args[1].ToLower().Equals("commands") || args[1].ToLower().Equals("?"))
                        {
                            ev.ReturnMessage = Plugin.HelpMsgTitle + "\n" +
                                               "\"." + Plugin.CommandPrefix + " a1\" - " + Plugin.HelpMsgA1 + " | Coût: " + Plugin.A1Power + " AP | Tier " + (Plugin.A1Tier + 1) + ".\n" +
                                               "\"." + Plugin.CommandPrefix + " a2\" - " + Plugin.HelpMsgA2 + " | Coût: " + Plugin.A2Power + " AP | Tier " + (Plugin.A2Tier + 1) + ".\n" +
                                               "\"." + Plugin.CommandPrefix + " a3\" - " + Plugin.HelpMsgA3 + " | Coût: " + Plugin.A3Power + " AP | Tier " + (Plugin.A3Tier + 1) + ".\n" +
                                               "\"." + Plugin.CommandPrefix + " a4\" - " + Plugin.HelpMsgA4 + " | Coût: " + Plugin.A4Power + " AP | Tier " + (Plugin.A4Tier + 1) + ".\n" +
                                               "\"." + Plugin.CommandPrefix + " a5\" - " + Plugin.HelpMsgA5 + " | Coût: " + Plugin.A5Power + " AP | Tier " + (Plugin.A5Tier + 1) + ".\n" +
                                               "\"." + Plugin.CommandPrefix + " a6\" - " + Plugin.HelpMsgA6 + " | Coût: " + Plugin.A6Cost + " Tier | Tier " + (Plugin.A6Tier + 1) + ".\n" +
                                               "\"." + Plugin.CommandPrefix + " suicide\" - " + Plugin.HelpMsgSuicide + ".\n";
                            return;
                        }

                        if (args[1].ToLower().Equals("a1"))
                        {
                            if (ev.Player.scp079PlayerScript.NetworkcurLvl < Plugin.A1Tier)
                            {
                                ev.ReturnMessage = Plugin.TierRequiredMsg.Replace("$tier", "" + (Plugin.A1Tier + 1));
                                return;
                            }
                            if (ev.Player.scp079PlayerScript.NetworkcurMana < Plugin.A1Power)
                            {
                                ev.ReturnMessage = Plugin.NoPowerMsg;
                                return;
                            }
                            if (args.Length > 3)
                            {
                                if (Plugin.A1AntiSpam > TimeBehaviour.CurrentTimestamp())
                                {
                                    ev.ReturnMessage = Plugin.AntiSpamMsg.Replace("%s", Math.Ceiling(TimeSpan.FromTicks(Plugin.A1AntiSpam - TimeBehaviour.CurrentTimestamp()).TotalSeconds).ToString());
                                    return;
                                }
                                else
                                {
                                    // .079 a1 SCP CAUSE[unknow/as/mtf/chaos] UNIT[C] UNIT[25]
                                    if (int.TryParse(args[2], out int SCP) || !String.IsNullOrWhiteSpace(args[3]))
                                    {
                                        string tts = string.Empty;
                                        tts += "BG_MTF2 BREAK_PREANNC SCP";
                                        foreach (char c in args[2])
                                        {
                                            tts += " " + c;
                                        }
                                        switch (args[3].ToLower())
                                        {
                                        case "mtf":
                                            if (args.Length > 5)
                                            {
                                                if (char.IsLetter(args[4][0]) || !String.IsNullOrWhiteSpace(args[5]))
                                                {
                                                    tts += " CONTAINEDSUCCESSFULLY CONTAINMENTUNIT NATO_" + args[4][0] + " " + args[5];
                                                }
                                                else
                                                {
                                                    ev.ReturnMessage = Plugin.FailA1Msg;
                                                    return;
                                                }
                                            }
                                            else
                                            {
                                                ev.ReturnMessage = Plugin.FailA1Msg;
                                                return;
                                            }
                                            break;

                                        case "security":
                                            tts += " SUCCESSFULLY TERMINATED BY AUTOMATIC SECURITY SYSTEM";
                                            break;

                                        case "chaos":
                                            tts += " TERMINATED BY CHAOSINSURGENCY";
                                            break;

                                        case "classed":
                                            tts += " TERMINATED BY CLASSD PERSONNEL";
                                            break;

                                        case "scientifique":
                                            tts += " TERMINATED BY SCIENCE PERSONNEL";
                                            break;

                                        case "decontamination":
                                            tts += " LOST IN DECONTAMINATION SEQUENCE";
                                            break;

                                        default:
                                            tts += " SUCCESSFULLY TERMINATED . CONTAINMENTUNIT UNKNOWN";
                                            break;
                                        }
                                        DoAnnouncement(tts, true);
                                        ev.Player.scp079PlayerScript.NetworkcurMana -= Plugin.A1Power;
                                        Plugin.A1AntiSpam = DateTime.UtcNow.AddSeconds((double)Plugin.A1TimeBetween).Ticks;
                                        ev.ReturnMessage  = Plugin.RunA1Msg;
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                ev.ReturnMessage = Plugin.FailA1Msg;
                                return;
                            }
                        }

                        if (args[1].ToLower().Equals("a2"))
                        {
                            if (ev.Player.scp079PlayerScript.NetworkcurLvl < Plugin.A2Tier)
                            {
                                ev.ReturnMessage = Plugin.TierRequiredMsg.Replace("$tier", "" + (Plugin.A2Tier + 1));
                                return;
                            }
                            if (ev.Player.scp079PlayerScript.NetworkcurMana >= Plugin.A2Power)
                            {
                                ev.Player.scp079PlayerScript.NetworkcurMana -= Plugin.A2Power;
                            }
                            else
                            {
                                ev.ReturnMessage = Plugin.NoPowerMsg;
                                return;
                            }
                            Room room = SCP079Room(ev.Player);
                            if (room == null)
                            {
                                ev.ReturnMessage = Plugin.FailA2Msg;
                                return;
                            }
                            if (room.Zone == ZoneType.Surface)
                            {
                                ev.ReturnMessage = Plugin.FailA2Msg;
                                return;
                            }
                            foreach (var item in Plugin.A2BlacklistRooms)
                            {
                                if (room.Name.ToLower().Contains(item.ToLower()))
                                {
                                    ev.ReturnMessage = Plugin.FailA2Msg;
                                    return;
                                }
                            }
                            if (Plugin.A2AntiSpam > TimeBehaviour.CurrentTimestamp())
                            {
                                ev.ReturnMessage = Plugin.AntiSpamMsg.Replace("%s", Math.Ceiling(TimeSpan.FromTicks(Plugin.A2AntiSpam - TimeBehaviour.CurrentTimestamp()).TotalSeconds).ToString());
                                return;
                            }
                            Timing.RunCoroutine(GasRoom(room, ev.Player));
                            Plugin.A2AntiSpam = DateTime.UtcNow.AddSeconds((double)Plugin.A2TimeBetween).Ticks;
                            ev.ReturnMessage  = Plugin.RunA2Msg;
                            return;
                        }

                        if (args[1].ToLower().Equals("a3"))
                        {
                            if (ev.Player.scp079PlayerScript.NetworkcurLvl < Plugin.A3Tier)
                            {
                                ev.ReturnMessage = Plugin.TierRequiredMsg.Replace("$tier", "" + (Plugin.A3Tier + 1));
                                return;
                            }
                            if (ev.Player.scp079PlayerScript.NetworkcurMana >= Plugin.A3Power)
                            {
                                ev.Player.scp079PlayerScript.NetworkcurMana -= Plugin.A3Power;
                            }
                            else
                            {
                                ev.ReturnMessage = Plugin.NoPowerMsg;
                                return;
                            }
                            Generator079.generators[0].RpcCustomOverchargeForOurBeautifulModCreators(Plugin.A3Timer, false);
                            ev.ReturnMessage = Plugin.RunA3Msg;
                            return;
                        }

                        if (args[1].ToLower().Equals("a4"))
                        {
                            if (ev.Player.scp079PlayerScript.NetworkcurLvl < Plugin.A4Tier)
                            {
                                ev.ReturnMessage = Plugin.TierRequiredMsg.Replace("$tier", "" + (Plugin.A4Tier + 1));
                                return;
                            }
                            if (ev.Player.scp079PlayerScript.NetworkcurMana >= Plugin.A4Power)
                            {
                                ev.Player.scp079PlayerScript.NetworkcurMana -= Plugin.A4Power;
                            }
                            else
                            {
                                ev.ReturnMessage = Plugin.NoPowerMsg;
                                return;
                            }
                            var             pos      = ev.Player.scp079PlayerScript.currentCamera.transform.position;
                            GrenadeManager  gm       = ev.Player.GetComponent <GrenadeManager>();
                            GrenadeSettings settings = gm.availableGrenades.FirstOrDefault(g => g.inventoryID == ItemType.GrenadeFlash);
                            FlashGrenade    flash    = GameObject.Instantiate(settings.grenadeInstance).GetComponent <FlashGrenade>();
                            flash.fuseDuration = 0.5f;
                            flash.InitData(gm, Vector3.zero, Vector3.zero, 1f);
                            flash.transform.position = pos;
                            NetworkServer.Spawn(flash.gameObject);
                            ev.ReturnMessage = Plugin.RunA4Msg;
                            return;
                        }

                        if (args[1].ToLower().Equals("suicide"))
                        {
                            ev.Player.playerStats.HurtPlayer(new PlayerStats.HitInfo(119000000, ev.Player.GetNickname(), DamageTypes.Wall, ev.Player.GetPlayerId()), ev.Player.gameObject);
                            return;
                        }

                        if (args[1].ToLower().Equals("a5"))
                        {
                            if (ev.Player.scp079PlayerScript.NetworkcurLvl < Plugin.A1Tier)
                            {
                                ev.ReturnMessage = Plugin.TierRequiredMsg.Replace("$tier", "" + (Plugin.A5Tier + 1));
                                return;
                            }
                            if (ev.Player.scp079PlayerScript.NetworkcurMana < Plugin.A5Power)
                            {
                                ev.ReturnMessage = Plugin.NoPowerMsg;
                                return;
                            }
                            if (args.Length > 2)
                            {
                                if (Plugin.A5AntiSpam > TimeBehaviour.CurrentTimestamp())
                                {
                                    ev.ReturnMessage = Plugin.AntiSpamMsg.Replace("%s", Math.Ceiling(TimeSpan.FromTicks(Plugin.A5AntiSpam - TimeBehaviour.CurrentTimestamp()).TotalSeconds).ToString());
                                    return;
                                }
                                else
                                {
                                    // .079 a5 GROUPE[unknow/mtf] UNIT[C] UNIT[25] [REMAIN SCP]
                                    if (!String.IsNullOrWhiteSpace(args[2]))
                                    {
                                        string tts = string.Empty;
                                        switch (args[2].ToLower())
                                        {
                                        case "mtf":
                                            if (args.Length > 5)
                                            {
                                                bool success = Int32.TryParse(args[5], out int scpleft);
                                                if (char.IsLetter(args[3][0]) || !String.IsNullOrWhiteSpace(args[4]) || success)
                                                {
                                                    tts += "MTFUNIT EPSILON 11 DESIGNATED NATO_" + args[3][0] + " " + args[4] + " HASENTERED ALLREMAINING ";
                                                    tts += ((scpleft <= 0) ? "NOSCPSLEFT" : ("AWAITINGRECONTAINMENT " + scpleft + ((scpleft == 1) ? " SCPSUBJECT" : " SCPSUBJECTS")));
                                                }
                                                else
                                                {
                                                    ev.ReturnMessage = Plugin.FailA5Msg;
                                                    return;
                                                }
                                            }
                                            else
                                            {
                                                ev.ReturnMessage = Plugin.FailA5Msg;
                                                return;
                                            }
                                            break;

                                        default:
                                            tts += "Danger. Alert all security .g1 personnel. .g4 Unauthorized personnel .g2 have been detected .g1 in the facility.";
                                            break;
                                        }
                                        DoAnnouncement(tts, true);
                                        ev.Player.scp079PlayerScript.NetworkcurMana -= Plugin.A5Power;
                                        Plugin.A5AntiSpam = DateTime.UtcNow.AddSeconds((double)Plugin.A5TimeBetween).Ticks;
                                        ev.ReturnMessage  = Plugin.RunA5Msg;
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                ev.ReturnMessage = Plugin.FailA5Msg;
                                return;
                            }
                        }

                        if (args[1].ToLower().Equals("a6"))
                        {
                            if (ev.Player.scp079PlayerScript.NetworkcurLvl < Plugin.A6Tier)
                            {
                                ev.ReturnMessage = Plugin.TierRequiredMsg.Replace("$tier", "" + (Plugin.A6Tier + 1));
                                return;
                            }
                            if (ev.Player.scp079PlayerScript.NetworkcurMana < Plugin.A6Power)
                            {
                                ev.ReturnMessage = Plugin.NoPowerMsg;
                                return;
                            }
                            else
                            {
                                List <ReferenceHub> riplist;
                                ReferenceHub        chosenPlayer;
                                riplist = GetHubList(RoleType.Spectator);
                                if (riplist.Count > 0)
                                {
                                    chosenPlayer = riplist[(new System.Random()).Next(riplist.Count)];
                                    int SCP = PlayerManager.localPlayer.GetComponent <CharacterClassManager>().FindRandomIdUsingDefinedTeam(Team.SCP);
                                    if (SCP != 1)
                                    {
                                        chosenPlayer.SetRole((RoleType)SCP);
                                        chosenPlayer.Broadcast(10, Plugin.NewSCPA6Msg, false);
                                        ev.Player.scp079PlayerScript.NetworkcurLvl  -= Plugin.A6Cost;
                                        ev.Player.scp079PlayerScript.NetworkcurMana -= Plugin.A6Power;
                                        Scp079.SetMaxEnergy(ev.Player, 125);
                                        Timing.CallDelayed(0.8f, () => { foreach (Room r in Map.Rooms)
                                                                         {
                                                                             if (r.Name.ToLower().Equals("HCZ_079".ToLower()))
                                                                             {
                                                                                 chosenPlayer.SetPosition(r.Position.x, r.Position.y + 1, r.Position.z);
                                                                             }
                                                                         }
                                                                         chosenPlayer.SetHealth(chosenPlayer.GetMaxHealth()); });
                                        DoAnnouncement("Alert. New containment .g1 breach detected. Cassie .g2 corruption detected. Code .g4 red.", true);
                                        ev.ReturnMessage = Plugin.RunA6Msg;
                                        return;
                                    }
                                    else
                                    {
                                        ev.ReturnMessage = Plugin.NoSCPA6Msg;
                                        return;
                                    }
                                }
                                else
                                {
                                    ev.ReturnMessage = Plugin.NoPlayerA6Msg;
                                    return;
                                }
                            }
                        }
                        ev.ReturnMessage = Plugin.HelpMsg.Replace("$prefix", "" + Plugin.CommandPrefix);
                        return;
                    }
                    ev.ReturnMessage = Plugin.HelpMsg.Replace("$prefix", "" + Plugin.CommandPrefix);
                    return;
                }
            }
        }
        /*public void UnmuteThem()
         * {
         *  foreach (var ply in PlayerManager.players)
         *  {
         *      try
         *      {
         *          if (notActualMutedPlayers.Contains(ply.GetComponent<ReferenceHub>().GetUserId()))
         *          {
         *              //Log.Debug("Unmuting player " + ply.GetComponent<ReferenceHub>().GetNickname() + " as they have no role and were muted by this plugin.");
         *              ply.GetComponent<ReferenceHub>().Unmute();
         *              ply.GetComponent<ReferenceHub>().characterClassManager.Muted = false;
         *              ply.GetComponent<ReferenceHub>().characterClassManager.SetMuted(false);
         *              notActualMutedPlayers.Remove(ply.GetComponent<ReferenceHub>().GetUserId());
         *              //ply.GetComponent<ReferenceHub>().Broadcast(3, "[NoRoleMute] You have been unmuted.", false);
         *          }
         *      }
         *      catch (NullReferenceException e)
         *      {
         *      }
         *  }
         * }*/

        internal void PlyCmd(ConsoleCommandEvent ev)
        {
        }
Ejemplo n.º 17
0
        public void OnConsoleCommand(ConsoleCommandEvent ev)
        {
            try
            {
                if (Cooldowns.CheckCooldown(Cooldowns.ChaosCmdCool))
                {
                    ev.ReturnMessage = $"<color=red>You must wait {Cooldowns.ChaosCmdCool} seconds to use abilities.</color>";
                    return;
                }

                if (ev.Player != hub)
                {
                    return;
                }

                if (ev.Command.StartsWith("emp"))
                {
                    bool Does173Exist = new bool();
                    if (!EventHandlers.ChaosDevice)
                    {
                        ev.Color         = "red";
                        ev.ReturnMessage = "You must wait until another round to access this command.";
                        return;
                    }
                    foreach (ReferenceHub hub in Player.GetHubs())
                    {
                        if (hub.GetRole() == RoleType.Scp173)
                        {
                            Does173Exist = true;
                        }
                    }
                    if (Does173Exist)
                    {
                        ev.Color         = "red";
                        ev.ReturnMessage = "Blackout cancelled. Entity in the facility has been found to directly benefit from the darkness.";
                        Does173Exist     = false;
                        return;
                    }
                    ev.Color                  = "yellow";
                    ev.ReturnMessage          = "Facility blacked out for 60 seconds.";
                    EventHandlers.ChaosDevice = false;
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Methods.DoBlackout()));
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoChsCommandCooldown()));
                }
                else if (ev.Command.StartsWith("respawn"))
                {
                    if (Cooldowns.CheckCooldown(Cooldowns.ChaosRespawnTime))
                    {
                        ev.Color         = "red";
                        ev.ReturnMessage = $"You must wait {Cooldowns.ChaosRespawnTime} seconds to respawn another wave.";
                        return;
                    }
                    GameCore.Console.singleton.TypeCommand("/SERVER_EVENT FORCE_CI_RESPAWN");
                    ev.ReturnMessage = "<color=cyan>An Chaos unit has been alerted to immediately come to your location.</color>";
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoChaosRespawnCooldown()));
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoChsCommandCooldown()));
                }
                else if (ev.Command.StartsWith("hack"))
                {
                    if (Cooldowns.CheckCooldown(Cooldowns.HackTime))
                    {
                        ev.Color         = "red";
                        ev.ReturnMessage = $"You must wait {Cooldowns.HackTime} seconds to attempt another hack.";
                        return;
                    }

                    string Cmd      = string.Empty;
                    int    CoolTime = new int();

                    if (ev.Command.Contains("scan"))
                    {
                        Cmd      = "scan";
                        CoolTime = 600;
                    }
                    else if (ev.Command.Contains("teslas"))
                    {
                        Cmd      = "teslas";
                        CoolTime = 120;
                    }
                    else
                    {
                        ev.ReturnMessage = "You must specify a command to hack: .hack (scan/teslas)";
                        return;
                    }
                    ev.ReturnMessage = null;
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Methods.HackSequence(hub, Cmd)));
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoHackCooldown(CoolTime)));
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoChsCommandCooldown()));
                }
                else if (ev.Command.StartsWith("help"))
                {
                    ev.Color         = "white";
                    ev.ReturnMessage =
                        "\n.help: Shows all commands and delays " +
                        "\n.emp: Blacksout the facility and disabled tesla gates, also lets anybody open any door - Can only be used once per round" +
                        "\n.respawn: Forces a Chaos respawn - Cooldown: 10 minutes" +
                        "\n.hack (scan/teslas): Attempts to mimick the NTF commanders ability's - Cooldowns: (scan 10 min/teslas 2 min)";
                }
            }
            catch (Exception e)
            {
                Log.Error($"BetterRespawns exception for ChaosCommander ConsoleCommand: {e}");
            }
        }
Ejemplo n.º 18
0
        public void Handler(Event he)
        {
            if (he.GetCode() == Events.Code_PlayerActionEvent)
            {
                PlayerActionEvent e = (PlayerActionEvent)he;

                if (e.Action == PlayerActionEvent.Actions.Chat)
                {
                    string message = (string)e.Data[0];

                    if (message[0] == '/')
                    {
                        if (IsOwner(e.Player.Name))
                        {
                            e.Player.SendChatMessage(
                                ConsoleReader.HandleCommand(message.Substring(1).Split(' '), e.Player.Name)
                                );

                            e.Cancelled = true;
                        }
                    }
                }

                if (e.Action == PlayerActionEvent.Actions.Born)
                {
                    if (IsOwner(e.Player.Name))
                    {
                        Server.Log("Player {0} owner is!", e.Player.Name);
                    }
                }
            }

            if (he.GetCode() == Events.Code_ConsoleCommandEvent)
            {
                ConsoleCommandEvent e = (ConsoleCommandEvent)he;

                if (e.Command.Length > 1)
                {
                    if (e.Command[0] == "addowner" && !IsOwner(e.Command[1]))
                    {
                        AddOwner(e.Command[1]);

                        e.Metadata = "New owner " + e.Command[1];

                        Server.BroadcastMessage(e.Metadata);

                        e.Cancelled = true;
                    }

                    if (e.Command[0] == "removeowner" && !IsOwner(e.Command[1]))
                    {
                        RemoveOwner(e.Command[1]);

                        e.Metadata = "Deleted owner " + e.Command[1];

                        Server.BroadcastMessage(e.Metadata);

                        e.Cancelled = true;
                    }
                }
            }
        }
Ejemplo n.º 19
0
        public void OnConsoleCommand(ConsoleCommandEvent ev)
        {
            if (Cooldowns.CheckCooldown(Cooldowns.MtfCmdCool))
            {
                ev.Color         = "red";
                ev.ReturnMessage = $"You must wait {Cooldowns.MtfCmdCool} seconds to use abilities.";
                return;
            }

            if (ev.Player != hub)
            {
                return;
            }

            if (ev.Command.StartsWith("respawn"))
            {
                if (Cooldowns.CheckCooldown(Cooldowns.MtfRespawnTime))
                {
                    ev.Color         = "red";
                    ev.ReturnMessage = $"You must wait {Cooldowns.MtfRespawnTime} seconds to respawn another wave.";
                    return;
                }

                GameCore.Console.singleton.TypeCommand("/SERVER_EVENT FORCE_MTF_RESPAWN");
                ev.Color         = "cyan";
                ev.ReturnMessage = "An MTF unit has been alerted to immediately come to your location.";
                EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoMTFRespawnCooldown()));
                EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoMtfCommandCooldown()));
            }
            else if (ev.Command.StartsWith("teslas"))
            {
                if (Cooldowns.CheckCooldown(Cooldowns.TeslasTime))
                {
                    ev.Color         = "red";
                    ev.ReturnMessage = $"Tesla gates cannot be toggled for {Cooldowns.TeslasTime} seconds.";
                    return;
                }

                if (EventHandlers.TeslaDisabled)
                {
                    EventHandlers.TeslaDisabled = false;
                    Methods.DoAnnouncement("MtfUnit Commander has activated Facility automatic security systems");
                }
                else
                {
                    EventHandlers.TeslaDisabled = true;
                    Methods.DoAnnouncement("MtfUnit Commander has Deactivated Facility automatic security systems ");
                }
                ev.Color         = "cyan";
                ev.ReturnMessage = "Tesla gates have been successfully toggled.";
                EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoTeslaCooldown()));
                EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoMtfCommandCooldown()));
            }
            else if (ev.Command.StartsWith("icom"))
            {
                if (Cooldowns.CheckCooldown(Cooldowns.IcomTime))
                {
                    ev.Color         = "red";
                    ev.ReturnMessage = $"You cannot use the intercom remotely for {Cooldowns.IcomTime} seconds.";
                    return;
                }
                if (ev.Player.IsIntercomMuted())
                {
                    ev.Color         = "red";
                    ev.ReturnMessage = "Denied as you are currently intercom muted. Contact this server's staff if you believe this is in error.";
                    return;
                }
                GameCore.Console.singleton.TypeCommand("INTERCOM-TIMEOUT");
                ev.Color         = "cyan";
                ev.ReturnMessage = "You are now live on the intercom. Thirty seconds remaining.";
                EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoIComCooldown()));
                EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoMtfCommandCooldown()));
            }
            else if (ev.Command.StartsWith("scan"))
            {
                if (Cooldowns.CheckCooldown(Cooldowns.ScanTime))
                {
                    ev.Color         = "red";
                    ev.ReturnMessage = $"You cannot scan the facility for {Cooldowns.ScanTime} seconds.";
                    return;
                }
                ev.Color         = "cyan";
                ev.ReturnMessage = "Commencing Scan.";
                EventHandlers.Coroutines.Add(Timing.RunCoroutine(Methods.DoScan("mtf")));
                EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoScanCooldown()));
                EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoMtfCommandCooldown()));
            }
            else if (ev.Command.StartsWith("lockdown"))
            {
                if (!EventHandlers.MTFLock)
                {
                    ev.Color         = "red";
                    ev.ReturnMessage = "You must wait until another round to access this command.";
                    return;
                }
                EventHandlers.Coroutines.Add(Timing.RunCoroutine(Methods.DoGateLock()));
                ev.Color              = "cyan";
                ev.ReturnMessage      = "Lockdown successful.";
                EventHandlers.MTFLock = false;
            }
            else if (ev.Command.StartsWith("help"))
            {
                ev.Color         = "white";
                ev.ReturnMessage =
                    "\n.help: Shows all commands and delays" +
                    "\n.teslas: Toggles the activation of teslas - Cooldown: 2 minutes" +
                    "\n.respawn: Forces a MTF respawn - Cooldown: 10 minutes" +
                    //"\n.icom: Allows you to speak on the intercom at will - Cooldown: 5 minutes" +
                    "\n.scan: Scans the facility for all alive people - Cooldown: 10 minutes" +
                    "\n.lockdown: Locks both Gate A and Gate B closed for one minute - Can be used once per round";
            }
            ;
        }