Exemplo n.º 1
0
 public async void OnSendingConsoleCommand(SendingConsoleCommandEventArgs ev)
 {
     if (Instance.Config.EventsToLog.SendingConsoleCommands)
     {
         await Network.SendAsync(new RemoteCommand("log", "commands", string.Format(Language.HasRunClientConsoleCommand, ev.Player.Nickname, ev.Player.UserId ?? Language.DedicatedServer, ev.Player.Role, ev.Name, string.Join(" ", ev.Arguments)))).ConfigureAwait(false);
     }
 }
Exemplo n.º 2
0
 public static void TryScanPersonnel(Player pl, SendingConsoleCommandEventArgs ev = null)
 {
     if (ev == null)
     {
         ScanController.INSTANCE.PersonnelCassie();
         return;
     }
     if (GetAccessLevel(pl, ev) < 3)
     {
         if (GetAccessLevel(pl) != -1)
         {
             pl.Broadcast(5, "Вашего уровня допуска недостаточно для активации данного протокола");
         }
         ev.ReturnMessage = "Вашего уровня допуска недостаточно для активации данного протокола"; return;
     }
     if (Time.time - lastScanTime < scanCooldown)
     {
         ev.ReturnMessage = "Протоколы сканирования были недавно активированы, в данный момент активация невозможна";
         pl.Broadcast(5, "Протоколы сканирования были недавно активированы, в данный момент активация невозможна");
     }
     else
     {
         ev.ReturnMessage = "Протокол успешно активирован";
         lastScanTime     = Time.time;
         ScanController.INSTANCE.PersonnelCassie();
     }
 }
Exemplo n.º 3
0
        internal void OnSendingConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            if (!Badges.ContainsKey(ev.Player.UserId))
            {
                return;
            }
            switch (ev.Name.ToLower())
            {
            default:
                return;

            case "hidetag":
                if (ev.Player.BadgeHidden)
                {
                    return;
                }
                ev.Player.BadgeHidden = true;
                return;

            case "showtag":
                if (!ev.Player.BadgeHidden)
                {
                    return;
                }
                ev.Player.BadgeHidden = false;
                return;
            }
        }
Exemplo n.º 4
0
 public static void TryBlockGates(Player pl, SendingConsoleCommandEventArgs ev = null)
 {
     if (ev == null)
     {
         Log.Info("hmm ev == null");
         ProtocolController.INSTANCE.BlockGates();
         return;
     }
     if (GetAccessLevel(pl, ev) < 1)
     {
         if (GetAccessLevel(pl) != -1)
         {
             pl.Broadcast(5, "Вашего уровня допуска недостаточно для активации данного протокола");
         }
         ev.ReturnMessage = "Вашего уровня допуска недостаточно для активации данного протокола"; return;
     }
     if (Time.time - lastProtocolTime < protocolCooldown)
     {
         ev.ReturnMessage = "Один из протоколов был недавно активирован, активация следующего протокола возможна через " + (protocolCooldown - Time.time + lastProtocolTime) + " секунд";
         pl.Broadcast(5, "Один из протоколов был недавно активирован, активация следующего протокола возможна через " + (protocolCooldown - Time.time + lastProtocolTime) + " секунд");
     }
     else
     {
         ev.ReturnMessage = "Протокол успешно активирован";
         lastProtocolTime = Time.time;
         ProtocolController.INSTANCE.BlockGates();
     }
 }
Exemplo n.º 5
0
        public void OnConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            if (ev.Name.ToLower().StartsWith("eh"))
            {
                ev.Player.ReferenceHub.hints.Show(new TextHint("Test Hints", new HintParameter[]
                {
                    new StringHintParameter("")
                }, HintEffectPresets.FadeInAndOut(0.25f, 1f, 0f)));
            }

            /* No longer used.
             * try
             * {
             *      switch (ev.Command)
             *      {
             *              case "back":
             *                      {
             *                              Log.Info("Back command ran");
             *                              string userid = ev.Player.UserId;
             *                              if (hubAFKList.Contains(userid))
             *                                      hubAFKList.Remove(userid);
             *                              if (hubAFKToBeKickedList.Contains(userid))
             *                                      hubAFKToBeKickedList.Remove(userid);
             *                              ev.Player.SetOverwatch(false);
             *
             *                              ev.ReturnMessage = "[KingsSCPSL] You have been removed from the AFK list!";
             *                              break;
             *                      }
             *      }
             * }
             * catch (Exception e)
             * {
             *      Log.Error($"Handling command error: {e}");
             * }*/
        }
Exemplo n.º 6
0
        public void OnSendingConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            if (ev.Name.StartsWith("call"))
            {
                if (PlayersCooldown.TryGetValue(ev.Player.UserId, out float EndOfCooldown))
                {
                    if (EndOfCooldown > Time.time)
                    {
                        ev.ReturnMessage = Plugin.Config.CooldownMessage.Replace("SEC", (EndOfCooldown - Time.time).ToString());
                        return;
                    }
                    PlayersCooldown.Remove(ev.Player.UserId);
                }

                ev.ReturnMessage = Plugin.Config.ReplyMessage;
                PlayersCooldown.Add(ev.Player.UserId, Time.time + Plugin.Config.Cooldown);

                string msgToAdm = Plugin.Config.MessageToAdmins
                                  .Replace("PLAYERNAME", ev.Player.Nickname)
                                  .Replace("MESSAGE", System.String.Join(" ", ev.Arguments));
                Log.Info(msgToAdm);
                foreach (Player player in Player.List)
                {
                    if (player.RemoteAdminAccess)
                    {
                        player.Broadcast(Plugin.Config.DurationBroadcast, msgToAdm);
                    }
                }
            }
        }
Exemplo n.º 7
0
 internal static void OnSendingConsoleCommand(SendingConsoleCommandEventArgs ev)
 {
     Exiled.API.Features.Log.Debug("foo");
     Type[] typelist = GetTypesInNamespace(Assembly.GetExecutingAssembly(), "Bobux.Commands");
     foreach (Type i in typelist)
     {
         if (typeof(ICommand).IsAssignableFrom(i))
         {
             Exiled.API.Features.Log.Debug(i.Name);
             ConstructorInfo m = i.GetConstructor(Type.EmptyTypes);
             //too lazy to properly check for interfaces
             if (m != null)
             {
                 ICommand j = m.Invoke(new object[] { }) as ICommand;
                 Exiled.API.Features.Log.Debug("baz");
                 if (GetCapitalizations(new List <string> {
                     j.Command
                 }.Concat(j.Aliases).ToArray()).Contains(ev.Name))
                 {
                     if (j is IUserCommand)
                     {
                         string executeOut = "";
                         j.Execute(new ArraySegment <string>(ev.Arguments.ToArray()), new ExiledPlayerCast(ev.Player), out executeOut);
                         ev.ReturnMessage = executeOut;
                         //ev.Player.SendConsoleMessage(executeOut, "white");
                         ev.Allow = false;
                         return;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
 public static void OnClientCommand(SendingConsoleCommandEventArgs ev)
 {
     ev.Allow = false;
     if (ev.Name.ToLower().Equals("cr"))
     {
         SCP049AbilityController.CallZombieReinforcement(ev.Player, SCP049AbilityController.AbilityCooldown, ev);
     }
 }
 public async void OnSendingConsoleCommand(SendingConsoleCommandEventArgs ev)
 {
     if (Instance.Config.EventsToLog.SendingConsoleCommands)
     {
         if (ev.Name == "sr" || ev.Name.StartsWith("keypress"))
         {
             return;
         }
         await Network.SendAsync(new RemoteCommand("log", "commands", string.Format(Language.HasRunClientConsoleCommand, ev.Player.Nickname, ev.Player.UserId ?? Language.DedicatedServer, ev.Player.Role.Translate(), ev.Name, string.Join(" ", ev.Arguments)))).ConfigureAwait(false);
     }
 }
Exemplo n.º 10
0
 public void a(SendingConsoleCommandEventArgs ev)
 {
     if (ev.Name.ToLower() == "sh")
     {
         string msg = "1. " + (shPlayers.Count > 0) + "\n2. " + test;
         foreach (int player in shPlayers)
         {
             msg += "- " + Player.Get(player).Nickname + "\n";
         }
         ev.ReturnMessage = msg;
     }
 }
        public static void CallZombieReinforcement(Player p, ushort cd, SendingConsoleCommandEventArgs ev)
        {
            // List of spectators to randomly choose from later
            List <Player> list = Player.List.Where(r => r.Role == RoleType.Spectator).ToList();

            // Only 049 is allowed to use this command
            if (p.Role != RoleType.Scp049)
            {
                ev.ReturnMessage = DocRework.config.Translation_Active_PermissionDenied;
                return;
            }

            if (CureCounter < DocRework.config.MinCures)
            {
                ev.ReturnMessage = DocRework.config.Translation_Active_NotEnoughRevives;
                return;
            }

            // Pretty self-explanatory i think
            if (cd > 0)
            {
                ev.ReturnMessage = DocRework.config.Translation_Active_OnCooldown + cd;
                return;
            }

            // If the list is empty it means no spectators can be chosen.
            if (list.IsEmpty())
            {
                ev.ReturnMessage = DocRework.config.Translation_Active_NoSpectators;
                return;
            }

            // Get a random player from the spectator list and spawn it as 049-2 then tp it to doc.
            var index = 0;

            index += new System.Random().Next(list.Count);
            var selected = list[index];

            selected.SetRole(RoleType.Scp0492);
            selected.Health = selected.MaxHealth;

            Timing.CallDelayed(0.5f, () =>
            {
                selected.Position = new Vector3(p.Position.x, p.Position.y, p.Position.z);
            });

            index = 0;

            AbilityCooldown = DocRework.config.Cooldown;
            Timing.RunCoroutine(StartCooldownTimer(), "SCP049_Active_Cooldown");
        }
Exemplo n.º 12
0
        public void onConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            //Request
            if (ev.Player.Team == Team.SCP && ev.Name == Plugin.pluginInstance.Config.requestSwap)

            {
                if (playersToSwap.Contains(ev.Player))
                {
                    ev.Player.SendConsoleMessage("You already sent a request", "red");
                    return;
                }
                if (ev.Arguments is null)
                {
                    ev.Player.SendConsoleMessage($"Invalid arguments. Command syntax: {Plugin.pluginInstance.Config.requestSwap} <class to swap>. Classes: classd, scientist, facilityguard, scp, all", "red");
                    return;
                }
                ev.Allow = true;
                requestSwap(ev.Player, ev.Arguments);

                ev.ReturnMessage = "";
            }
            //Accept
            else if (ev.Name == Plugin.pluginInstance.Config.acceptSwap)
            {
                if (ev.Player.Role == RoleType.Spectator)
                {
                    ev.Player.SendConsoleMessage($"You can't ask for a swap", "red");
                    return;
                }
                else if (playersToSwap.Count < 1)
                {
                    ev.Player.SendConsoleMessage($"There are no requests", "red");
                }
                else if (ev.Arguments is null)
                {
                    ev.Player.SendConsoleMessage($"Invalid arguments. Command syntax: {Plugin.pluginInstance.Config.acceptSwap} <player id to swap>.", "red");
                    return;
                }
                else if (ev.Player.Id == int.Parse(ev.Arguments[0]))
                {
                    ev.Player.SendConsoleMessage($"You can't swap yourself", "red");
                    return;
                }


                else
                {
                    acceptSwap(ev.Player, ev.Arguments);
                }
            }
        }
Exemplo n.º 13
0
        private static bool Prefix(RemoteAdmin.QueryProcessor __instance, ref string query, bool encrypted)
        {
            (string name, string[] arguments) = query.ExtractCommand();
            var ev = new SendingConsoleCommandEventArgs(API.Features.Player.Get(__instance.gameObject), name, arguments.ToList(), encrypted);

            Server.OnSendingConsoleCommand(ev);

            if (!string.IsNullOrEmpty(ev.ReturnMessage))
            {
                __instance.GCT.SendToClient(__instance.connectionToClient, ev.ReturnMessage, ev.Color);
            }

            return(ev.Allow);
        }
Exemplo n.º 14
0
        public void OnConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            string cmd = ev.Name;

            foreach (string arg in ev.Arguments)
            {
                cmd += $" {arg}";
            }
            tcp.SendData(new Command
            {
                eventName = "ConsoleCommand",
                sender    = PlyToUser(ev.Player),
                command   = cmd
            });
        }
Exemplo n.º 15
0
        internal void OnConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            string cmd = ev.Name.ToLower();

            if ((cmd == "killfeed" || cmd == "kf") && ev.Player.ReferenceHub.serverRoles.RemoteAdmin)
            {
                ev.IsAllowed = false;
                ev.Color     = "white";
                if (killFeedPlayers.Contains(ev.Player))
                {
                    killFeedPlayers.Remove(ev.Player);
                    ev.ReturnMessage = "You have disabled the kill feed.";
                }
                else
                {
                    killFeedPlayers.Add(ev.Player);
                    ev.ReturnMessage = "You have enabled the kill feed.";
                }
            }
        }
Exemplo n.º 16
0
        internal void SendingConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            if (Plugin.Instance.Config.SendingConsoleCommand == "")
            {
                return;
            }
            string message = Plugin.Instance.Config.SendingConsoleCommand.Replace("%name%", ev.Player.Nickname.ToString());

            message = message.Replace("%encrypted%", ev.IsEncrypted.ToString());
            message = message.Replace("%command%", ev.Name.ToString());
            string args = string.Join(", ", ev.Arguments);

            message = message.Replace("%args%", args);


            if (Plugin.Instance.Config.debug_to_console)
            {
                Log.Debug(message: "[ " + Plugin.Instance.Config.server_name + "] " + message);
            }
            Plugin.sendWebHook(Plugin.Instance.Config.server_url, message, Plugin.Instance.Config.server_name);
        }
Exemplo n.º 17
0
 private static int GetAccessLevel(Player pl, SendingConsoleCommandEventArgs ev = null)
 {
     if (pl.CurrentItem.uniq != 0 && pl.CurrentItem.id.IsKeycard())
     {
         if (pl.CurrentItem.id == ItemType.KeycardJanitor || pl.CurrentItem.id == ItemType.KeycardChaosInsurgency || pl.CurrentItem.id == ItemType.KeycardZoneManager || pl.CurrentItem.id == ItemType.KeycardScientist || pl.CurrentItem.id == ItemType.KeycardScientistMajor)
         {
             return(0);
         }
         else if (pl.CurrentItem.id == ItemType.KeycardSeniorGuard || pl.CurrentItem.id == ItemType.KeycardGuard)
         {
             return(1);
         }
         else if (pl.CurrentItem.id == ItemType.KeycardNTFLieutenant)
         {
             return(2);
         }
         else if (pl.CurrentItem.id == ItemType.KeycardContainmentEngineer)
         {
             return(3);
         }
         else if (pl.CurrentItem.id == ItemType.KeycardNTFCommander)
         {
             return(4);
         }
         else if (pl.CurrentItem.id == ItemType.KeycardFacilityManager)
         {
             return(5);
         }
         else if (pl.CurrentItem.id == ItemType.KeycardO5)
         {
             return(6);
         }
     }
     if (ev != null)
     {
         ev.ReturnMessage = "Возьмите ключ-карту в руки чтобы активировать протокол";
     }
     pl.Broadcast(5, "Возьмите ключ-карту в руки чтобы активировать протокол");
     return(-1);
 }
Exemplo n.º 18
0
 public static void TryHCZDecontain(Player pl, SendingConsoleCommandEventArgs ev = null)
 {
     if (ev == null)
     {
         ProtocolController.INSTANCE.HCZDecont();
         return;
     }
     if (GetAccessLevel(pl, ev) < 4)
     {
         if (GetAccessLevel(pl) != -1)
         {
             pl.Broadcast(5, "Вашего уровня допуска недостаточно для активации данного протокола");
         }
         ev.ReturnMessage = "Вашего уровня допуска недостаточно для активации данного протокола"; return;
     }
     if (Time.time - lastProtocolTime < protocolCooldown)
     {
         ev.ReturnMessage = "Один из протоколов был недавно активирован, активация следующего протокола возможна через " + (protocolCooldown - Time.time + lastProtocolTime) + " секунд";
         pl.Broadcast(5, "Один из протоколов был недавно активирован, активация следующего протокола возможна через " + (protocolCooldown - Time.time + lastProtocolTime) + " секунд");
     }
     else
     {
         if (!ProtocolController.INSTANCE.IsDecontGoing())
         {
             ev.ReturnMessage = "Протокол успешно активирован";
             lastProtocolTime = Time.time;
             ProtocolController.INSTANCE.HCZDecont();
         }
         else if (ProtocolController.HCZDecontWasActivated)
         {
             ev.ReturnMessage = "Уже была запущена деконтаминация тяжёлой зоны, так что воспользуйтесь другим протоколом";
         }
         else
         {
             ev.ReturnMessage = "В данный момент уже происходит деконтаминация одной из Зон содержания";
         }
     }
 }
Exemplo n.º 19
0
        public void OnConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            string cmd = ev.Name.ToLower();

            if (cmd == "level" || cmd == "lvl")
            {
                ev.Allow = false;
                Player player = ev.Arguments.Count == 0 ? ev.Player : Player.Get(ev.Arguments[0]);
                string name;
                bool   hasData = pInfoDict.ContainsKey(player.UserId);
                if (player != null)
                {
                    name = player.Nickname;
                }
                else
                {
                    name = hasData ? pInfoDict[ev.Player.UserId].level.ToString() : "[NO DATA]";
                }
                ev.ReturnMessage =
                    $"Player: {name} ({player.UserId})\n" +
                    $"Level: {(hasData ? pInfoDict[player.UserId].level.ToString() : "[NO DATA]")}\n" +
                    $"XP: {(hasData ? $"{pInfoDict[player.UserId].xp.ToString()} / {XpToLevelUp(player.UserId)}" : "[NO DATA]")}" + (PlayerXP.instance.Config.KarmaEnabled ? "\n" +
                                                                                                                                     $"Karma: {(hasData ? pInfoDict[player.UserId].karma.ToString() : "[NO DATA]")}" : "");
            }
            else if (cmd == "leaderboard" || cmd == "lb")
            {
                ev.Allow = false;
                string output;
                int    num = 5;
                if (ev.Arguments.Count > 0 && int.TryParse(ev.Arguments[0], out int n))
                {
                    num = n;
                }
                if (num > 15)
                {
                    ev.Color         = "red";
                    ev.ReturnMessage = "Leaderboards can be no larger than 15.";
                    return;
                }
                if (pInfoDict.Count != 0)
                {
                    output = $"Top {num} Players:\n";

                    for (int i = 0; i < num; i++)
                    {
                        if (pInfoDict.Count == i)
                        {
                            break;
                        }
                        string     userid = pInfoDict.ElementAt(i).Key;
                        PlayerInfo info   = pInfoDict[userid];
                        output += $"{i + 1}) {info.name} ({userid}) | Level: {info.level} | XP: {info.xp} / {XpToLevelUp(userid)}{(PlayerXP.instance.Config.KarmaEnabled ? $" | Karma: {info.karma}" : "")}";
                        if (i != pInfoDict.Count - 1)
                        {
                            output += "\n";
                        }
                        else
                        {
                            break;
                        }
                    }

                    ev.Color         = "yellow";
                    ev.ReturnMessage = output;
                }
                else
                {
                    ev.Color         = "red";
                    ev.ReturnMessage = "Error: there is not enough data to display the leaderboard.";
                }
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// Called when sending a command through in-game console.
 /// </summary>
 /// <param name="ev">The <see cref="SendingConsoleCommandEventArgs"/> instance.</param>
 public static void OnSendingConsoleCommand(SendingConsoleCommandEventArgs ev) => SendingConsoleCommand.InvokeSafely(ev);
Exemplo n.º 21
0
        public void OnConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            string cmd = ev.Name.ToLower();

            if (cmd == "level" || cmd == "lvl" || cmd == "nivel")
            {
                ev.Allow = false;
                Player player = ev.Arguments.Count == 0 ? ev.Player : Player.Get(ev.Arguments[0]);
                string name;
                int    id;
                id = player.Id;
                bool hasData = pInfoDict.ContainsKey(player.UserId);
                name             = player.Nickname;
                ev.ReturnMessage =
                    $"Estadisticas\n" +
                    $"Para ver los Stats de otro jugadr .lvl [nombre del jugador]\n" +
                    $"Usuario: {name}\n" +
                    $"ID: {id}\n" +
                    $"SteamID: [No disponible]\n" +
                    $"Nivel: {(hasData ? pInfoDict[player.UserId].level.ToString() : "[NO DATA]")}\n" +
                    $"Experiencia | EXP: {(hasData ? $"{pInfoDict[player.UserId].xp.ToString()} / {XpToLevelUp(player.UserId)}" : "[NO DATA]")}" + (PlayerXP.instance.Config.KarmaEnabled ? "\n" +
                                                                                                                                                    $"Karma: {(hasData ? pInfoDict[player.UserId].karma.ToString() : "[NO DATA]")}" : "");
            }
            else if (cmd == "leaderboard" || cmd == "lb" || cmd == "tabla" || cmd == "top")
            {
                ev.Allow = false;
                string output;
                int    num = 10;
                if (ev.Arguments.Count > 0 && int.TryParse(ev.Arguments[0], out int n))
                {
                    num = n;
                }
                if (num > 15)
                {
                    ev.Color         = "red";
                    ev.ReturnMessage = "Las tablas de clasificación no pueden tener más de 15 lineas.";
                    return;
                }
                if (pInfoDict.Count != 0)
                {
                    output = $"Top {num} Jugadores:\n";

                    for (int i = 0; i < num; i++)
                    {
                        if (pInfoDict.Count == i)
                        {
                            break;
                        }
                        string     userid = pInfoDict.ElementAt(i).Key;
                        PlayerInfo info   = pInfoDict[userid];
                        output += $"{i + 1}) {info.name} | Nivel: {info.level} | XP: {info.xp} / {XpToLevelUp(userid)}{(PlayerXP.instance.Config.KarmaEnabled ? $" | Karma: {info.karma}" : "")}";
                        if (i != pInfoDict.Count - 1)
                        {
                            output += "\n";
                        }
                        else
                        {
                            break;
                        }
                    }

                    ev.Color         = "yellow";
                    ev.ReturnMessage = output;
                }
                else
                {
                    ev.Color         = "red";
                    ev.ReturnMessage = "Error: there is not enough data to display the leaderboard.";
                }
            }
        }
Exemplo n.º 22
0
        public void AttemptRevive(SendingConsoleCommandEventArgs ev, SubClass subClass, bool necro = false)
        {
            Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} attempt", Subclass.Instance.Config.Debug);
            AbilityType ability = necro ? AbilityType.Necromancy : AbilityType.Revive;

            if (TrackingAndMethods.OnCooldown(ev.Player, ability, subClass))
            {
                Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} on cooldown", Subclass.Instance.Config.Debug);
                TrackingAndMethods.DisplayCooldown(ev.Player, necro ? AbilityType.Necromancy : AbilityType.Revive, subClass, necro ? "necromancy" : "revive", Time.time);
                return;
            }

            List <Collider> colliders = Physics.OverlapSphere(ev.Player.Position, 3f).Where(e => e.gameObject.GetComponentInParent <Ragdoll>() != null).ToList();

            colliders.Sort((Collider x, Collider y) =>
            {
                return(Vector3.Distance(x.gameObject.transform.position, ev.Player.Position).CompareTo(Vector3.Distance(y.gameObject.transform.position, ev.Player.Position)));
            });

            if (colliders.Count == 0)
            {
                ev.Player.Broadcast(2, Subclass.Instance.Config.ReviveFailedNoBodyMessage);
                Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} overlap did not hit a ragdoll", Subclass.Instance.Config.Debug);
                return;
            }

            Ragdoll doll = colliders[0].gameObject.GetComponentInParent <Ragdoll>();

            if (doll.owner == null)
            {
                Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} failed", Subclass.Instance.Config.Debug);
                ev.Player.Broadcast(2, Subclass.Instance.Config.CantReviveMessage);
                return;
            }

            if (doll.owner.DeathCause.GetDamageType() == DamageTypes.Lure)
            {
                Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} failed", Subclass.Instance.Config.Debug);
                ev.Player.Broadcast(2, Subclass.Instance.Config.CantReviveMessage);
                return;
            }

            EPlayer owner = EPlayer.Get(colliders[0].gameObject.GetComponentInParent <Ragdoll>().owner.PlayerId);

            if (owner != null && !owner.IsAlive)
            {
                bool revived = false;
                if (!necro && TrackingAndMethods.GetPreviousTeam(owner) != null &&
                    TrackingAndMethods.GetPreviousTeam(owner) == ev.Player.Team)
                {
                    if (TrackingAndMethods.PlayersThatJustGotAClass.ContainsKey(owner))
                    {
                        TrackingAndMethods.PlayersThatJustGotAClass[owner] = Time.time + 3f;
                    }
                    else
                    {
                        TrackingAndMethods.PlayersThatJustGotAClass.Add(owner, Time.time + 3f);
                    }

                    owner.SetRole((RoleType)TrackingAndMethods.GetPreviousRole(owner), true);

                    if (TrackingAndMethods.PreviousSubclasses.ContainsKey(owner) && TrackingAndMethods.PreviousSubclasses[owner].AffectsRoles.Contains((RoleType)TrackingAndMethods.GetPreviousRole(owner)))
                    {
                        TrackingAndMethods.AddClass(owner, TrackingAndMethods.PreviousSubclasses[owner], false, true);
                    }

                    owner.Inventory.Clear();
                    revived = true;
                }
                else if (necro)
                {
                    owner.Role = RoleType.Scp0492;
                    TrackingAndMethods.AddZombie(ev.Player, owner);
                    owner.IsFriendlyFireEnabled = true;
                    revived = true;
                }
                if (revived)
                {
                    Timing.CallDelayed(0.2f, () =>
                    {
                        owner.ReferenceHub.playerMovementSync.OverridePosition(ev.Player.Position + new Vector3(0.3f, 1f, 0), 0, true);
                    });
                    UnityEngine.Object.DestroyImmediate(doll.gameObject, true);
                    TrackingAndMethods.AddCooldown(ev.Player, ability);
                    TrackingAndMethods.UseAbility(ev.Player, ability, subClass);
                    Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} succeeded", Subclass.Instance.Config.Debug);
                }
                else
                {
                    Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} failed", Subclass.Instance.Config.Debug);
                    ev.Player.Broadcast(2, Subclass.Instance.Config.CantReviveMessage);
                }
            }
            else
            {
                Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} failed", Subclass.Instance.Config.Debug);
                ev.Player.Broadcast(2, Subclass.Instance.Config.CantReviveMessage);
            }
        }
Exemplo n.º 23
0
        internal static void ServerEvents_SendingConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            if (!Enabled || !ev.Name.Equals("pnt", StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            var player       = ev.Player;
            var commands     = ev.Arguments;
            var commandCount = commands.Count;

            ev.Allow = false;

            if (commandCount > 0)
            {
                var currentCommand = commands[0].ToLowerInvariant().Trim();

                switch (currentCommand)
                {
                case "crosshair" when _useCrossHair:
                    ev.ReturnMessage = "Already using crosshair";
                    break;

                case "crosshair":
                    _useCrossHair    = true;
                    ev.ReturnMessage = "Using crosshair";
                    break;

                case "help":
                    ev.ReturnMessage = HelpMessage;
                    break;

                case "player" when !_useCrossHair:
                    ev.ReturnMessage = "Already using player position";
                    break;

                case "player":
                    _useCrossHair    = false;
                    ev.ReturnMessage = "Using player position";
                    break;

                case "load":
                    if (commandCount == 2)
                    {
                        currentCommand   = commands[1];
                        ev.ReturnMessage = LoadPoints(currentCommand)
                                                        ? $"{currentCommand} loaded successfully with {_currentLoadedPointList.RawPoints.Count} point(s)."
                                                        : $"{currentCommand} does not exist, created new point list.";
                    }
                    else
                    {
                        ev.ReturnMessage = "Error: Don't use spaces in your name.";
                    }

                    break;

                case "save":
                    ev.ReturnMessage = Save()
                                                ? "Save Successful"
                                                : "Load/Create a list first!";
                    break;

                case "add":

                    if (commandCount > 2)
                    {
                        ev.ReturnMessage = "Error: Don't use spaces in your name.";
                    }
                    else if (_currentLoadedPointList != null)
                    {
                        currentCommand = commandCount == 2 ? commands[1].ToLowerInvariant() : string.Empty;

                        var     scp049Component = player.GameObject.GetComponent <Scp049_2PlayerScript>();
                        Vector3 position;
                        Vector3 rotation;

                        if (_useCrossHair)
                        {
                            var scp106Component = player.GameObject.GetComponent <Scp106PlayerScript>();
                            var cameraRotation  = scp049Component.plyCam.transform.forward;
                            Physics.Raycast(scp049Component.plyCam.transform.position, cameraRotation,
                                            out var where,
                                            40f, scp106Component.teleportPlacementMask);
                            rotation = new Vector3(-cameraRotation.x, cameraRotation.y, -cameraRotation.z);
                            position = @where.point + (Vector3.up * 0.1f);
                        }
                        else
                        {
                            var froward = scp049Component.plyCam.transform.forward;
                            rotation = new Vector3(-froward.x, froward.y, -froward.z);
                            position = player.Position + (Vector3.up * 0.1f);
                        }

                        var closestRoom = player.CurrentRoom;
                        var roomName    = closestRoom.Type;

                        _currentLoadedPointList.RawPoints.Add(new RawPoint(currentCommand, roomName,
                                                                           closestRoom.Transform.InverseTransformPoint(position),
                                                                           closestRoom.Transform.InverseTransformDirection(rotation)));
                        ev.ReturnMessage =
                            $"Created point! Room: [{roomName}] ID: [{currentCommand}]";
                    }
                    else
                    {
                        ev.ReturnMessage = "Load/Create a list first!";
                    }

                    break;

                default:
                    ev.ReturnMessage = "Invalid Command. Type .pnt help";
                    break;
                }
            }
        }
Exemplo n.º 24
0
        public void AttemptRevive(SendingConsoleCommandEventArgs ev, SubClass subClass, bool necro = false)
        {
            Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} attempt", Subclass.Instance.Config.Debug);
            AbilityType ability = necro ? AbilityType.Necromancy : AbilityType.Revive;

            if (Tracking.OnCooldown(ev.Player, ability, subClass))
            {
                Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} on cooldown", Subclass.Instance.Config.Debug);
                Tracking.DisplayCooldown(ev.Player, necro ? AbilityType.Necromancy : AbilityType.Revive, subClass, necro ? "necromancy" : "revive", Time.time);
                return;
            }

            List <Collider> colliders = Physics.OverlapSphere(ev.Player.Position, 3f).Where(e => e.gameObject.GetComponentInParent <Ragdoll>() != null).ToList();

            colliders.Sort((Collider x, Collider y) =>
            {
                return(Vector3.Distance(x.gameObject.transform.position, ev.Player.Position).CompareTo(Vector3.Distance(y.gameObject.transform.position, ev.Player.Position)));
            });

            if (colliders.Count == 0)
            {
                ev.ReturnMessage = "You must be near a dead body to use this command";
                ev.Player.Broadcast(2, "You must be near a dead body.");
                Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} overlap did not hit a ragdoll", Subclass.Instance.Config.Debug);
                return;
            }

            Ragdoll doll = colliders[0].gameObject.GetComponentInParent <Ragdoll>();

            if (doll.owner == null)
            {
                Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} failed", Subclass.Instance.Config.Debug);
                ev.ReturnMessage = "This player is not revivable.";
                ev.Player.Broadcast(2, "This player is not revivable.");
                return;
            }

            EPlayer owner = EPlayer.Get(colliders[0].gameObject.GetComponentInParent <Ragdoll>().owner.PlayerId);

            if (owner != null && !owner.IsAlive)
            {
                if (!necro && Tracking.GetPreviousTeam(owner) != null &&
                    Tracking.GetPreviousTeam(owner) == ev.Player.Team)
                {
                    owner.Role = (RoleType)Tracking.GetPreviousRole(owner);
                }
                else if (necro)
                {
                    owner.Role = RoleType.Scp0492;
                    Tracking.AddZombie(ev.Player, owner);
                    owner.IsFriendlyFireEnabled = true;
                }
                if (owner.Role != RoleType.Spectator)
                {
                    Timing.CallDelayed(0.2f, () =>
                    {
                        owner.Position = colliders[0].gameObject.transform.position + new Vector3(0, 1f, 0);
                    });
                    UnityEngine.Object.DestroyImmediate(doll.gameObject, true);
                    Tracking.AddCooldown(ev.Player, ability);
                    Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} succeeded", Subclass.Instance.Config.Debug);
                }
                else
                {
                    Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} failed", Subclass.Instance.Config.Debug);
                    ev.ReturnMessage = "This player is not revivable.";
                    ev.Player.Broadcast(2, "This player is not revivable.");
                }
            }
            else
            {
                Log.Debug($"Player {ev.Player.Nickname} {(necro ? "necromancy" : "revive")} failed", Subclass.Instance.Config.Debug);
                ev.ReturnMessage = "This player is not revivable.";
                ev.Player.Broadcast(2, "This player is not revivable.");
            }
        }
Exemplo n.º 25
0
        // https://github.com/galaxy119/EXILED/blob/master/EXILED_Main/Extensions/Player.cs


        public void ConsoleCmd(SendingConsoleCommandEventArgs ev)
        {
            if (ev.Player.Role.Equals(RoleType.Scp079))
            {
                if (ev.Name.Equals(plugin.Config.b079_prefix))
                {
                    ev.Allow = false;
                    if (ev.Arguments.IsEmpty())
                    {
                        ev.ReturnMessage = plugin.Config.b079_help_title + "\n" +
                                           "\"." + plugin.Config.b079_prefix + " a1\" - " + plugin.Config.b079_help_a1 + " - " + plugin.Config.b079_a1_power + "+ AP - Tier " + (plugin.Config.b079_a1_tier + 1) + "+\n" +
                                           "\"." + plugin.Config.b079_prefix + " a2\" - " + plugin.Config.b079_help_a2 + " - " + plugin.Config.b079_a2_power + "+ AP - Tier " + (plugin.Config.b079_a2_tier + 1) + "+\n" +
                                           "\"." + plugin.Config.b079_prefix + " a3\" - " + plugin.Config.b079_help_a3 + " - " + plugin.Config.b079_a3_power + "+ AP - Tier " + (plugin.Config.b079_a3_tier + 1) + "+\n" +
                                           "\"." + plugin.Config.b079_prefix + " a4\" - " + plugin.Config.b079_help_a4 + " - " + plugin.Config.b079_a4_power + "+ AP - Tier " + (plugin.Config.b079_a4_tier + 1) + "+\n";
                        return;
                    }
                    if (ev.Arguments.Count >= 1)
                    {
                        if (ev.Arguments[0].ToLower().Equals("help") || ev.Arguments[0].ToLower().Equals("commands") || ev.Arguments[0].ToLower().Equals("?"))
                        {
                            ev.ReturnMessage = plugin.Config.b079_help_title + "\n" +
                                               "\"." + plugin.Config.b079_prefix + " a1\" - " + plugin.Config.b079_help_a1 + " - " + plugin.Config.b079_a1_power + "+ AP - Tier " + (plugin.Config.b079_a1_tier + 1) + "+\n" +
                                               "\"." + plugin.Config.b079_prefix + " a2\" - " + plugin.Config.b079_help_a2 + " - " + plugin.Config.b079_a2_power + "+ AP - Tier " + (plugin.Config.b079_a2_tier + 1) + "+\n" +
                                               "\"." + plugin.Config.b079_prefix + " a3\" - " + plugin.Config.b079_help_a3 + " - " + plugin.Config.b079_a3_power + "+ AP - Tier " + (plugin.Config.b079_a3_tier + 1) + "+\n" +
                                               "\"." + plugin.Config.b079_prefix + " a4\" - " + plugin.Config.b079_help_a4 + " - " + plugin.Config.b079_a4_power + "+ AP - Tier " + (plugin.Config.b079_a4_tier + 1) + "+\n";
                            return;
                        }

                        if (ev.Arguments[0].ToLower().Equals("a1"))
                        {
                            if (ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurLvl < plugin.Config.b079_a1_tier)
                            {
                                ev.ReturnMessage = plugin.Config.b079_msg_tier_required.Replace("$tier", "" + (plugin.Config.b079_a1_tier + 1));
                                return;
                            }
                            if (ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurMana >= plugin.Config.b079_a1_power)
                            {
                                ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurMana -= plugin.Config.b079_a1_power;
                            }
                            else
                            {
                                ev.ReturnMessage = plugin.Config.b079_msg_no_power;
                                return;
                            }
                            var cams = GetSCPCameras();
                            if (cams.Count > 0)
                            {
                                Camera079 cam = cams[UnityEngine.Random.Range(0, cams.Count)];
                                ev.Player.ReferenceHub.scp079PlayerScript.CmdSwitchCamera(cam.cameraId, false);
                                ev.ReturnMessage = plugin.Config.b079_msg_a1_run;
                                return;
                            }
                            else
                            {
                                ev.ReturnMessage = plugin.Config.b079_msg_a1_fail;
                                ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurMana += plugin.Config.b079_a1_power;
                                return;
                            }
                        }

                        if (ev.Arguments[0].ToLower().Equals("a2"))
                        {
                            if (ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurLvl < plugin.Config.b079_a2_tier)
                            {
                                ev.ReturnMessage = plugin.Config.b079_msg_tier_required.Replace("$tier", "" + (plugin.Config.b079_a2_tier + 1));
                                return;
                            }
                            if (ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurMana >= plugin.Config.b079_a2_power)
                            {
                                ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurMana -= plugin.Config.b079_a2_power;
                            }
                            else
                            {
                                ev.ReturnMessage = plugin.Config.b079_msg_no_power;
                                return;
                            }
                            if (Time.timeSinceLevelLoad - a2cooldown < plugin.Config.b079_a2_cooldown)
                            {
                                ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurMana += plugin.Config.b079_a2_power;
                                ev.ReturnMessage = plugin.Config.b079_msg_a2_fail;
                                return;
                            }
                            Room room = ev.Player.CurrentRoom;
                            if (room == null)
                            {
                                ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurMana += plugin.Config.b079_a2_power;
                                ev.ReturnMessage = plugin.Config.b079_msg_a2_fail;
                                return;
                            }
                            if (room.Zone == ZoneType.Surface)
                            {
                                ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurMana += plugin.Config.b079_a2_power;
                                ev.ReturnMessage = plugin.Config.b079_msg_a2_fail;
                                return;
                            }
                            foreach (var item in plugin.Config.b079_a2_blacklisted_rooms)
                            {
                                if (room.Name.ToLower().Contains(item.ToLower()))
                                {
                                    ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurMana += plugin.Config.b079_a2_power;
                                    ev.ReturnMessage = plugin.Config.b079_msg_a2_fail;
                                    return;
                                }
                            }
                            Timing.RunCoroutine(GasRoom(room, ev.Player.ReferenceHub));
                            ev.ReturnMessage = plugin.Config.b079_msg_a2_run;
                            return;
                        }

                        if (ev.Arguments[0].ToLower().Equals("a3"))
                        {
                            if (ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurLvl < plugin.Config.b079_a3_tier)
                            {
                                ev.ReturnMessage = plugin.Config.b079_msg_tier_required.Replace("$tier", "" + (plugin.Config.b079_a3_tier + 1));
                                return;
                            }
                            if (ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurMana >= plugin.Config.b079_a3_power)
                            {
                                ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurMana -= plugin.Config.b079_a3_power;
                            }
                            else
                            {
                                ev.ReturnMessage = plugin.Config.b079_msg_no_power;
                                return;
                            }
                            Generator079.Generators[0].ServerOvercharge(plugin.Config.b079_a3_timer, false);
                            ev.ReturnMessage = plugin.Config.b079_msg_a3_run;
                            return;
                        }

                        if (ev.Arguments[0].ToLower().Equals("a4"))
                        {
                            if (ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurLvl < plugin.Config.b079_a4_tier)
                            {
                                ev.ReturnMessage = plugin.Config.b079_msg_tier_required.Replace("$tier", "" + (plugin.Config.b079_a4_tier + 1));
                                return;
                            }
                            if (a4cooldown >= Time.time)
                            {
                                ev.ReturnMessage = $"<color=red>This ability is in CoolDown ({(int) (a4cooldown - Time.time)})</color>";
                                return;
                            }
                            if (ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurMana >= plugin.Config.b079_a4_power)
                            {
                                ev.Player.ReferenceHub.scp079PlayerScript.NetworkcurMana -= plugin.Config.b079_a4_power;
                            }
                            else
                            {
                                ev.ReturnMessage = plugin.Config.b079_msg_no_power;
                                return;
                            }
                            a4cooldown = Time.time + 5f;
                            var             pos      = ev.Player.ReferenceHub.scp079PlayerScript.currentCamera.transform.position;
                            GrenadeManager  gm       = ev.Player.ReferenceHub.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.Config.b079_msg_a4_run;
                            return;
                        }
                        ev.ReturnMessage = plugin.Config.b079_msg_help_cmd_fail.Replace("$prefix", "" + plugin.Config.b079_prefix);
                        return;
                    }
                    ev.ReturnMessage = plugin.Config.b079_msg_help_cmd_fail.Replace("$prefix", "" + plugin.Config.b079_prefix);
                    return;
                }
            }
        }
Exemplo n.º 26
0
        public void OnConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            string cmd = ev.Name.ToLower();

            if (cmd == "level" || cmd == "lvl" || cmd == "seviye")
            {
                ev.Allow = false;
                Player player = ev.Arguments.Count == 0 ? ev.Player : Player.Get(ev.Arguments[0]);
                string name;
                int    id;
                id = player.Id;
                bool hasData = pInfoDict.ContainsKey(player.UserId);
                name             = player.Nickname;
                ev.ReturnMessage =
                    $"XP Istatistiklerin\n" +
                    $"Başka bir oyuncunun istatistiklerini görmek için .level [oyuncu ismi]\n" +
                    $"Adı: {name}\n" +
                    $"IDsi: {id}\n" +
                    $"SteamID: [Müsait değil]\n" +
                    $"Seviye: {(hasData ? pInfoDict[player.UserId].level.ToString() : "[NO DATA]")}\n" +
                    $"XP: {(hasData ? $"{pInfoDict[player.UserId].xp.ToString()} / {XpToLevelUp(player.UserId)}" : "[NO DATA]")}" + (PlayerXP.instance.Config.KarmaEnabled ? "\n" +
                                                                                                                                     $"Karma: {(hasData ? pInfoDict[player.UserId].karma.ToString() : "[NO DATA]")}" : "");
            }
            else if (cmd == "leaderboard" || cmd == "lb" || cmd == "siralama" || cmd == "top")
            {
                ev.Allow = false;
                string output;
                int    num = 10;
                if (ev.Arguments.Count > 0 && int.TryParse(ev.Arguments[0], out int n))
                {
                    num = n;
                }
                if (num > 15)
                {
                    ev.Color         = "red";
                    ev.ReturnMessage = "Sıralama tablosunda 15'den fazla veri gösterilmez.";
                    return;
                }
                if (pInfoDict.Count != 0)
                {
                    output = $"En iyi {num} oyuncu:\n";

                    for (int i = 0; i < num; i++)
                    {
                        if (pInfoDict.Count == i)
                        {
                            break;
                        }
                        string     userid = pInfoDict.ElementAt(i).Key;
                        PlayerInfo info   = pInfoDict[userid];
                        output += $"{i + 1}) {info.name} | Seviye: {info.level} | XP: {info.xp} / {XpToLevelUp(userid)}{(PlayerXP.instance.Config.KarmaEnabled ? $" | Karma: {info.karma}" : "")}";
                        if (i != pInfoDict.Count - 1)
                        {
                            output += "\n";
                        }
                        else
                        {
                            break;
                        }
                    }

                    ev.Color         = "yellow";
                    ev.ReturnMessage = output;
                }
                else
                {
                    ev.Color         = "red";
                    ev.ReturnMessage = "Hata: Sıralama için gösterilebilecek bir veri bulunamadı.";
                }
            }
        }
Exemplo n.º 27
0
 public void OnConsoleCommand(SendingConsoleCommandEventArgs ev)
 {
 }
Exemplo n.º 28
0
        public void OnConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            string[] args = ev.Arguments.ToArray();
            foreach (string str in args)
            {
                str.ToLower();
            }

            string command = ev.Name.ToLower();

            switch (command)
            {
            case "ps1":
                if (ScanMod.config.enableScanning)
                {
                    ExtraMethods.TryScanSCP(ev.Player, ev);
                }
                break;

            case "ps4":
                if (ScanMod.config.enableScanning)
                {
                    ExtraMethods.TryScanPersonnel(ev.Player, ev);
                }
                break;

            case "ps5":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryBlackout(ev.Player, 30f, ev);
                }
                break;

            case "pl1":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryBlockGates(ev.Player, ev);
                }
                break;

            case "pl2":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryBlockCheckpointAndGates(ev.Player, ev);
                }
                break;

            case "pl3":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryBlockDoors(ev.Player, ev);
                }
                break;

            case "pb2":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryLCZDecontain(ev.Player, ev);
                }
                break;

            case "pb3":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryHCZDecontain(ev.Player, ev);
                }
                break;

            case "pb4":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryLCZAndHCZDecontain(ev.Player, ev);
                }
                break;

            case "pb5":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryNuke(ev.Player, ev);
                }
                break;

            case "106":
            {
                if (ScanMod.config.enable106overhaul)
                {
                    if (args[0].Equals("help"))
                    {
                        ev.ReturnMessage = "Для SCP 106 доступны следующие команды:\n.106 help - вывод доступных команд\n.106 damage урон задержка и .106 damage default - для установления своего урона в КИ и возвращения его к стандартному";
                    }
                    else if (args[0].Equals("damage"))
                    {
                        if (args[1].Equals("default"))
                        {
                            PocketProperties.customDamageEnabled = false;
                            PocketProperties.customDamage        = 1f;
                            PocketProperties.customDelay         = 1f;
                            ev.ReturnMessage = "Урон в КИ успешно изменён на стандартный";
                        }
                        else
                        {
                            if (float.TryParse(args[1], out float damage) && float.TryParse(args[2], out float delay))
                            {
                                PocketProperties.customDamage        = damage;
                                PocketProperties.customDelay         = delay;
                                PocketProperties.customDamageEnabled = true;
                                ev.ReturnMessage = "Урон в КИ успешно изменён";
                            }
                            else
                            {
                                ev.ReturnMessage = "Ошибка. Введите команду в формате .106 damage урон задержка";
                            }
                        }
                    }
                    else if (args[0].Equals("escape"))
                    {
                        int exits;
                        try
                        {
                            exits = int.Parse(args[2]);
                        }
                        catch
                        {
                            ev.ReturnMessage = "Ошибка. Введите команду в формате .106 escape кол-во выходов";
                            break;
                        }
                        if (exits > -1 && exits < 9)
                        {
                            ExtraMethods.SetPocketExits(exits);
                            ev.ReturnMessage = "Количество выходов из КИ установлено на " + exits;
                        }
                        else
                        {
                            ev.ReturnMessage = "Ошибка. Кол-во выходов должно быть от 0 до 8";
                        }
                    }
                    else if (args[0].Equals("cycle"))
                    {
                        if (PocketProperties.cycledPocket)
                        {
                            ev.ReturnMessage = "Замена смерти на обманный побег в КИ отключена";
                            PocketProperties.cycledPocket = false;
                        }
                        else
                        {
                            ev.ReturnMessage = "Замена смерти на обманный побег в КИ включена";
                            PocketProperties.cycledPocket = true;
                        }
                    }
                    else
                    {
                        ev.ReturnMessage = "Чтобы получить список команд введите .106 help";
                    }
                }
                break;
            }

            case "173":
            {
                if (ScanMod.config.enableRPItems)
                {
                    AdditionalPlayerAbilities abilities = ev.Player.GameObject.GetComponentInParent <AdditionalPlayerAbilities>();
                    if (abilities == null)
                    {
                        ev.ReturnMessage = "Player doesn't have abilities component";
                        Log.Error("Player doesn't have abilities component");
                    }
                    else
                    {
                        if (abilities.has173ammo)
                        {
                            abilities.Charge173Ammo();
                            ev.ReturnMessage = "Вы зарядили спец-патрон для SCP 173";
                            ev.Player.Broadcast(5, "Вы зарядили спец-патрон для SCP 173");
                        }
                        else
                        {
                            ev.ReturnMessage = "У вас нет спец-патрона для SCP 173";
                            ev.Player.Broadcast(5, "У вас нет спец-патрона для SCP 173");
                        }
                    }
                }
                break;
            }
            }
        }
        public void OnConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            Plugin.Log.Debug($"{ev.Player.Nickname} used the command: '{ev.Name}'");
            if (ev.Name.ToLower() == "specmode")
            {
                if (!Plugin.GhostSettings.ContainsKey(ev.Player.UserId))
                {
                    Plugin.GhostSettings.Add(ev.Player.UserId, new GhostSettings());
                }

                if (RateLimited.Contains(ev.Player))
                {
                    ev.Player.ClearBroadcasts();
                    ev.Player.Broadcast(1, Translation.Translation.GetText().RateLimited);
                    ev.ReturnMessage = Translation.Translation.GetText().RateLimited;
                    ev.Color         = "red";
                    return;
                }

                RateLimited.Add(ev.Player);
                Timing.CallDelayed(Instance.Config.RateLimitTime, () => RateLimited.Remove(ev.Player));

                switch (Plugin.GhostSettings[ev.Player.UserId].Specmode)
                {
                case GhostSettings.Specmodes.Normal:
                    Plugin.GhostSettings[ev.Player.UserId].Specmode = GhostSettings.Specmodes.Ghost;

                    if (Plugin.GhostSettings.ContainsKey(ev.Player.UserId) && Plugin.GhostSettings[ev.Player.UserId].Specmode == GhostSettings.Specmodes.Ghost && ev.Player.Role == RoleType.Spectator)
                    {
                        Plugin.Log.Debug($"{ev.Player.Nickname} added to list of ghost spectators.");
                        GhostList.Add(ev.Player);
                        Timing.RunCoroutine(SpawnGhost(ev.Player, 0.1f));
                    }

                    ev.ReturnMessage = Translation.Translation.GetText().SpecmodeGhost;
                    ev.Color         = "blue";
                    ev.IsAllowed     = false;
                    break;

                case GhostSettings.Specmodes.Ghost:
                    Plugin.GhostSettings[ev.Player.UserId].Specmode = GhostSettings.Specmodes.Normal;

                    if (GhostList.Contains(ev.Player))
                    {
                        Plugin.Log.Debug($"{ev.Player.Nickname} removed from list of ghost spectators.");
                        GhostList.Remove(ev.Player);
                        ev.Player.SetGhostMode(false);
                        ev.Player.ClearInventory();
                        ev.Player.Role = RoleType.Spectator;
                    }

                    ev.ReturnMessage = Translation.Translation.GetText().SpecmodeNormal;
                    ev.Color         = "blue";
                    ev.IsAllowed     = false;
                    break;

                default:
                    Plugin.GhostSettings[ev.Player.UserId].Specmode = GhostSettings.Specmodes.Normal;

                    if (GhostList.Contains(ev.Player))
                    {
                        Plugin.Log.Debug($"{ev.Player.Nickname} removed from list of ghost spectators.");
                        GhostList.Remove(ev.Player);
                        ev.Player.SetGhostMode(false);
                        ev.Player.ClearInventory();
                        ev.Player.Role = RoleType.Spectator;
                    }

                    ev.ReturnMessage = Translation.Translation.GetText().SpecmodeNormal;
                    ev.Color         = "blue";
                    ev.IsAllowed     = false;
                    break;
                }
            }
            else if (ev.Name.ToLower() == "specboard")
            {
                if (!Plugin.GhostSettings.ContainsKey(ev.Player.UserId))
                {
                    Plugin.GhostSettings.Add(ev.Player.UserId, new GhostSettings());
                }

                Plugin.GhostSettings[ev.Player.UserId].Specboard =
                    !Plugin.GhostSettings[ev.Player.UserId].Specboard;

                ev.ReturnMessage = "You have " + (Plugin.GhostSettings[ev.Player.UserId].Specboard ? "enabled" : "disabled") + " specboard mode.";
                ev.Color         = "Magenta";
                ev.IsAllowed     = false;
            }
        }
Exemplo n.º 30
0
        public void OnSendingConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            Log.Debug($"Player {ev.Player.Nickname} sent a console command", Subclass.Instance.Config.Debug);
            ev.IsAllowed = false;
            switch (ev.Name)
            {
            case "revive":
                Log.Debug($"Player {ev.Player.Nickname} is attempting to revive", Subclass.Instance.Config.Debug);
                if (Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) && Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.Revive))
                {
                    SubClass subClass = Tracking.PlayersWithSubclasses[ev.Player];
                    AttemptRevive(ev, subClass);
                }
                else
                {
                    ev.ReturnMessage = "You don't have the ability to revive!";
                }
                break;

            case "necro":
                Log.Debug($"Player {ev.Player.Nickname} is attempting to necro", Subclass.Instance.Config.Debug);
                if (Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) && Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.Necromancy))
                {
                    SubClass subClass = Tracking.PlayersWithSubclasses[ev.Player];
                    AttemptRevive(ev, subClass, true);
                }
                else
                {
                    ev.ReturnMessage = "You don't have the ability to necro!";
                }
                break;

            case "locate":
                if (ev.Player.Role != RoleType.Scp93953 && ev.Player.Role != RoleType.Scp93989 &&
                    (!Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) ||
                     !Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.Scp939Vision)))
                {
                    Log.Debug($"Player {ev.Player.Nickname} failed to echolocate", Subclass.Instance.Config.Debug);
                    ev.ReturnMessage = "You must be SCP-939 or have a subclass with its visuals to use this command";
                    return;
                }

                if (Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) && Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.Echolocate))
                {
                    SubClass subClass = Tracking.PlayersWithSubclasses[ev.Player];
                    if (Tracking.OnCooldown(ev.Player, AbilityType.Echolocate, subClass))
                    {
                        Log.Debug($"Player {ev.Player.Nickname} failed to echolocate", Subclass.Instance.Config.Debug);
                        Tracking.DisplayCooldown(ev.Player, AbilityType.Echolocate, subClass, "echolocation", Time.time);
                        return;
                    }

                    Collider[] colliders = Physics.OverlapSphere(ev.Player.Position, subClass.FloatOptions.ContainsKey("EcholocateRadius") ? subClass.FloatOptions["EcholocateRadius"] : 10f);

                    foreach (Collider PlayerCollider in colliders.Where(c => EPlayer.Get(c.gameObject) != null))
                    {
                        EPlayer.Get(PlayerCollider.gameObject).ReferenceHub.footstepSync?.CmdScp939Noise(100f);
                    }

                    Tracking.AddCooldown(ev.Player, AbilityType.Echolocate);
                    Log.Debug($"Player {ev.Player.Nickname} successfully used echolocate", Subclass.Instance.Config.Debug);
                }
                break;

            case "noclip":
                Log.Debug($"Player {ev.Player.Nickname} is attempting to noclip", Subclass.Instance.Config.Debug);
                if (Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) && Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.NoClip))
                {
                    SubClass subClass = Tracking.PlayersWithSubclasses[ev.Player];
                    if (Tracking.OnCooldown(ev.Player, AbilityType.NoClip, subClass))
                    {
                        Log.Debug($"Player {ev.Player.Nickname} failed to noclip - cooldown", Subclass.Instance.Config.Debug);
                        Tracking.DisplayCooldown(ev.Player, AbilityType.NoClip, subClass, "noclip", Time.time);
                        return;
                    }
                    bool previous = ev.Player.NoClipEnabled;
                    ev.Player.NoClipEnabled = !ev.Player.NoClipEnabled;
                    Tracking.AddCooldown(ev.Player, AbilityType.NoClip);
                    if (subClass.FloatOptions.ContainsKey("NoClipTime"))
                    {
                        Timing.CallDelayed(subClass.FloatOptions["NoClipTime"], () =>
                        {
                            if (ev.Player.NoClipEnabled != previous)
                            {
                                ev.Player.NoClipEnabled = previous;
                            }
                        });
                    }
                    Log.Debug($"Player {ev.Player.Nickname} successfully noclipped", Subclass.Instance.Config.Debug);
                }
                else
                {
                    ev.ReturnMessage = "You must have the noclip ability to use this command";
                    Log.Debug($"Player {ev.Player.Nickname} could not noclip", Subclass.Instance.Config.Debug);
                }
                break;

            case "flash":
                if (Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) && Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.FlashOnCommand))
                {
                    SubClass subClass = Tracking.PlayersWithSubclasses[ev.Player];
                    if (Tracking.OnCooldown(ev.Player, AbilityType.FlashOnCommand, subClass))
                    {
                        Log.Debug($"Player {ev.Player.Nickname} failed to flash on command", Subclass.Instance.Config.Debug);
                        Tracking.DisplayCooldown(ev.Player, AbilityType.FlashOnCommand, subClass, "flash", Time.time);
                        return;
                    }

                    // Credit to KoukoCocoa's AdminTools for the grenade spawn script below, I was lost. https://github.com/KoukoCocoa/AdminTools/
                    GrenadeManager  grenadeManager = ev.Player.ReferenceHub.gameObject.GetComponent <GrenadeManager>();
                    GrenadeSettings settings       = grenadeManager.availableGrenades.FirstOrDefault(g => g.inventoryID == ItemType.GrenadeFlash);
                    Grenade         grenade        = UnityEngine.Object.Instantiate(settings.grenadeInstance).GetComponent <Grenade>();
                    grenade.fuseDuration = subClass.FloatOptions.ContainsKey("FlashOnCommandFuseTimer") ? subClass.FloatOptions["FlashOnCommandFuseTimer"] : 0.3f;
                    grenade.FullInitData(grenadeManager, ev.Player.Position, Quaternion.Euler(grenade.throwStartAngle),
                                         grenade.throwLinearVelocityOffset, grenade.throwAngularVelocity);
                    NetworkServer.Spawn(grenade.gameObject);
                    Tracking.AddCooldown(ev.Player, AbilityType.FlashOnCommand);
                    Log.Debug($"Player {ev.Player.Nickname} successfully used flash on commad", Subclass.Instance.Config.Debug);
                }
                else
                {
                    ev.ReturnMessage = "You must have the flash on command ability to use this command";
                    Log.Debug($"Player {ev.Player.Nickname} could not flash on command", Subclass.Instance.Config.Debug);
                }
                break;

            case "invis":
                if (!Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) || !Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.InvisibleOnCommand))
                {
                    ev.ReturnMessage = "You must have the invisible on command ability to use this command";
                    Log.Debug($"Player {ev.Player.Nickname} could not go invisible on command", Subclass.Instance.Config.Debug);
                    return;
                }
                Scp268 scp268 = ev.Player.ReferenceHub.playerEffectsController.GetEffect <Scp268>();
                if (scp268 != null)
                {
                    SubClass subClass = Tracking.PlayersWithSubclasses[ev.Player];

                    if (scp268.Enabled)
                    {
                        Log.Debug($"Player {ev.Player.Nickname} failed to go invisible on command", Subclass.Instance.Config.Debug);
                        ev.Player.Broadcast(3, "You're already invisible!");
                        return;
                    }

                    if (Tracking.OnCooldown(ev.Player, AbilityType.InvisibleOnCommand, subClass))
                    {
                        Log.Debug($"Player {ev.Player.Nickname} failed to go invisible on command", Subclass.Instance.Config.Debug);
                        Tracking.DisplayCooldown(ev.Player, AbilityType.InvisibleOnCommand, subClass, "invisible", Time.time);
                        return;
                    }

                    //scp268.Duration = subClass.FloatOptions.ContainsKey("InvisibleOnCommandDuration") ?
                    //    subClass.FloatOptions["InvisibleOnCommandDuration"]*2f : 30f*2f;

                    //ev.Player.ReferenceHub.playerEffectsController.EnableEffect(scp268);

                    ev.Player.ReferenceHub.playerEffectsController.EnableEffect <Scp268>();
                    Tracking.PlayersInvisibleByCommand.Add(ev.Player);
                    Timing.CallDelayed(subClass.FloatOptions.ContainsKey("InvisibleOnCommandDuration") ?
                                       subClass.FloatOptions["InvisibleOnCommandDuration"] : 30f, () => {
                        if (Tracking.PlayersInvisibleByCommand.Contains(ev.Player))
                        {
                            Tracking.PlayersInvisibleByCommand.Remove(ev.Player);
                        }
                        if (scp268.Enabled)
                        {
                            ev.Player.ReferenceHub.playerEffectsController.DisableEffect <Scp268>();
                        }
                    });

                    Tracking.AddCooldown(ev.Player, AbilityType.InvisibleOnCommand);
                }
                break;

            default:
                ev.IsAllowed = true;
                break;
            }
        }