Esempio n. 1
0
        public (string response, string color) OnCall(ReferenceHub sender, string[] args)
        {
            if (!sender.CheckPermission("tc.mute"))
            {
                return(Language.CommandNotEnoughPermissionsError, "red");
            }

            if (args.Length < 2)
            {
                return(string.Format(Language.CommandNotEnoughParametersError, 2, Usage), "red");
            }

            ReferenceHub target = Player.GetPlayer(args[0]);

            Collections.Chat.Player chatPlayer = args[0].GetChatPlayer();

            if (chatPlayer == null)
            {
                return(string.Format(Language.PlayerNotFoundError, args[0]), "red");
            }

            if (!double.TryParse(args[1], out double duration) || duration < 1)
            {
                return(string.Format(Language.InvalidDurationError, args[1]), "red");
            }

            string reason = string.Join(" ", args.Skip(2).Take(args.Length - 2));

            if (string.IsNullOrEmpty(reason))
            {
                return(Language.ReasonCannotBeEmptyError, "red");
            }

            if (chatPlayer.IsChatMuted())
            {
                return(string.Format(Language.PlayerIsAlreadyMutedError, chatPlayer.Name), "red");
            }

            LiteDatabase.GetCollection <Collections.Chat.Mute>().Insert(new Collections.Chat.Mute()
            {
                Target    = chatPlayer,
                Issuer    = sender.GetChatPlayer(),
                Reason    = reason,
                Duration  = duration,
                Timestamp = DateTime.Now,
                Expire    = DateTime.Now.AddMinutes(duration)
            });

            if (Configs.showChatMutedBroadcast)
            {
                target?.ClearBroadcasts();
                target?.Broadcast(Configs.chatMutedBroadcastDuration, string.Format(Configs.chatMutedBroadcast, duration, reason), false);
            }

            target?.SendConsoleMessage(string.Format(Language.MuteCommandSuccessPlayer, duration, reason), "red");

            return(string.Format(Language.MuteCommandSuccessModerator, chatPlayer.Name, duration, reason), "green");
        }
 internal void BroadCastToPlayer(ReferenceHub attacker, uint v1, string v2)
 {
     if (broadcasting.Contains(attacker.GetUserId()))
     {
         return;
     }
     attacker.Broadcast(v1, v2, false);
     broadcasting.Add(attacker.GetUserId());
     Timing.RunCoroutine(RemoveBroadcasting(attacker));
 }
Esempio n. 3
0
        public (string response, string color) OnCall(ReferenceHub sender, string[] args)
        {
            (string message, bool isValid) = CheckMessageValidity(args.GetMessage(1), sender);

            if (!isValid)
            {
                return(message, "red");
            }

            message = $"[{sender.GetNickname()}][{Language.Private}]: {message}";

            ReferenceHub target = Player.GetPlayer(args[0]);

            if (target == null)
            {
                return(string.Format(Language.PlayerNotFoundError, args[0]), "red");
            }
            else if (sender == target)
            {
                return(Language.CannotSendMessageToThemselvesError, "red");
            }
            else if (!Configs.canSpectatorSendMessagesToAlive && sender.GetTeam() == Team.RIP && target.GetTeam() != Team.RIP)
            {
                return(Language.CannotSendMessageToAlivePlayersError, "red");
            }

            if (Configs.saveChatToDatabase)
            {
                SaveMessage(message, sender.GetChatPlayer(), new List <Collections.Chat.Player>()
                {
                    sender.GetChatPlayer()
                }, type);
            }

            SendMessage(ref message, sender, new List <ReferenceHub>()
            {
                target
            });

            if (Configs.showPrivateMessageNotificationBroadcast)
            {
                target.ClearBroadcasts();
                target.Broadcast(Configs.privateMessageNotificationBroadcastDuration, Configs.privateMessageNotificationBroadcast, false);
            }

            return(message, color);
        }
Esempio n. 4
0
 public static void SpawnSCP181(ReferenceHub LuckyBoy)
 {
     LuckyBoy.characterClassManager.SetClassID(RoleType.ClassD);
     LuckyBoy.Broadcast(Configs.LuckyBoySpawnmsg, Configs.LuckyBoySpawnmsgbctime);
     hasTag   = !string.IsNullOrEmpty(LuckyBoy.serverRoles.NetworkMyText);
     isHidden = !string.IsNullOrEmpty(LuckyBoy.serverRoles.HiddenBadge);
     if (isHidden)
     {
         LuckyBoy.RefreshTag();
     }
     LuckyBoy.inventory.items.ToList().Clear();
     for (int i = 0; i < Configs.SCP181SpawnItem.Count; i++)
     {
         LuckyBoy.inventory.AddNewItem((ItemType)Configs.SCP181SpawnItem[i]);
     }
     LuckyBoy.SetRank("SCP-181", "orange");
     SCP181 = LuckyBoy;
 }
Esempio n. 5
0
 public static void SpawnChaosCommander(ReferenceHub Chaosss)
 {
     Chaosss.characterClassManager.SetClassID(RoleType.ChaosInsurgency);
     Chaosss.Broadcast(Configs.ChaosCommanderSpawnmsg, Configs.ChaosCommanderSpawnmsgbctime);
     hasTag   = !string.IsNullOrEmpty(Chaosss.serverRoles.NetworkMyText);
     isHidden = !string.IsNullOrEmpty(Chaosss.serverRoles.HiddenBadge);
     if (isHidden)
     {
         Chaosss.RefreshTag();
     }
     Chaosss.SetHealth(300f);
     Chaosss.inventory.items.ToList().Clear();
     for (int i = 0; i < Configs.ChaosCommanderSpawnItem.Count; i++)
     {
         Chaosss.inventory.AddNewItem((ItemType)Configs.ChaosCommanderSpawnItem[i]);
     }
     Chaosss.SetRank("Chaos Commander", "green");
     ChaosCommander = Chaosss;
 }
Esempio n. 6
0
 public static void SpawnSCP550(ReferenceHub Ghoul)
 {
     Ghoul.characterClassManager.SetClassID(RoleType.Tutorial);
     Ghoul.Broadcast(Configs.SCP999Spawnmsg, Configs.SCP999Spawnmsgbctime);
     hasTag   = !string.IsNullOrEmpty(Ghoul.serverRoles.NetworkMyText);
     isHidden = !string.IsNullOrEmpty(Ghoul.serverRoles.HiddenBadge);
     if (isHidden)
     {
         Ghoul.RefreshTag();
     }
     Timing.RunCoroutine(EventHandlers.DelayAction(0.5f, () => Ghoul.plyMovementSync.OverridePosition(Map.GetRandomSpawnPoint(RoleType.Scp049), 0f)));
     Ghoul.SetHealth(200f);
     Ghoul.inventory.items.ToList().Clear();
     for (int i = 0; i < Configs.SCP550SpawnItem.Count; i++)
     {
         Ghoul.inventory.AddNewItem((ItemType)Configs.SCP550SpawnItem[i]);
     }
     Ghoul.SetRank("SCP-550", "red");
     SCP550 = Ghoul;
 }
Esempio n. 7
0
 public static void SpawnSCP999(ReferenceHub TTM)
 {
     TTM.characterClassManager.SetClassID(RoleType.Tutorial);
     TTM.Broadcast(Configs.SCP999Spawnmsg, Configs.SCP999Spawnmsgbctime);
     hasTag   = !string.IsNullOrEmpty(TTM.serverRoles.NetworkMyText);
     isHidden = !string.IsNullOrEmpty(TTM.serverRoles.HiddenBadge);
     if (isHidden)
     {
         TTM.RefreshTag();
     }
     Timing.RunCoroutine(EventHandlers.DelayAction(0.5f, () => TTM.plyMovementSync.OverridePosition(Map.GetRandomSpawnPoint(RoleType.FacilityGuard), 0f)));
     TTM.SetHealth(5000f);
     TTM.inventory.items.ToList().Clear();
     for (int i = 0; i < Configs.SCP999SpawnItem.Count; i++)
     {
         TTM.inventory.AddNewItem((ItemType)Configs.SCP999SpawnItem[i]);
     }
     TTM.SetRank("SCP-999", "pink");
     SCP999 = TTM;
 }
Esempio n. 8
0
 public static void TargetSendSubtitle(ReferenceHub player, string text, uint time, bool monospaced = false)
 {
     player.ClearBroadcasts();
     player.Broadcast(time, text, monospaced);
 }
Esempio n. 9
0
        public void OnPlayerLeave(PlayerLeaveEvent ev)
        {
            if (ev.Player.GetTeam() != Team.RIP)
            {
                bool is035 = false;
                bool isSH  = false;
                Dictionary <ReferenceHub, bool> spies = null;
                try
                {
                    is035 = ev.Player.queryProcessor.PlayerId == TryGet035()?.queryProcessor.PlayerId;
                }
                catch (Exception x)
                {
                    Log.Debug("SCP-035 is not installed, skipping method call...");
                }

                try
                {
                    isSH = TryGetSH().Contains(ev.Player.queryProcessor.PlayerId);
                }
                catch (Exception x)
                {
                    Log.Debug("Serpents Hand is not installed, skipping method call...");
                }

                try
                {
                    spies = TryGetSpies();
                }
                catch (Exception x)
                {
                    Log.Debug("CISpy is not installed, skipping method call...");
                }

                Inventory.SyncListItemInfo items = ev.Player.inventory.items;
                RoleType role   = ev.Player.GetRole();
                Vector3  pos    = ev.Player.transform.position;
                int      health = (int)ev.Player.playerStats.health;
                string   ammo   = ev.Player.ammoBox.amount;

                ReferenceHub player = Player.GetHubs().FirstOrDefault(x => x.GetRole() == RoleType.Spectator && x.characterClassManager.UserId != string.Empty && !x.GetOverwatch());
                if (player != null)
                {
                    if (isSH)
                    {
                        try
                        {
                            TrySpawnSH(player);
                        }
                        catch (Exception x)
                        {
                            Log.Debug("Serpents Hand is not installed, skipping method call...");
                        }
                    }
                    else
                    {
                        player.SetRole(role);
                    }
                    if (spies != null && spies.ContainsKey(ev.Player))
                    {
                        try
                        {
                            TrySpawnSpy(player, ev.Player, spies);
                        }
                        catch (Exception x)
                        {
                            Log.Debug("CISpy is not installed, skipping method call...");
                        }
                    }
                    if (is035)
                    {
                        try
                        {
                            TrySpawn035(player);
                        }
                        catch (Exception x)
                        {
                            Log.Debug("SCP-035 is not installed, skipping method call...");
                        }
                    }
                    Timing.CallDelayed(0.3f, () =>
                    {
                        player.SetPosition(pos);
                        player.inventory.items.ToList().Clear();
                        foreach (var item in items)
                        {
                            player.inventory.AddNewItem(item.id);
                        }
                        player.playerStats.health    = health;
                        player.ammoBox.Networkamount = ammo;
                        player.Broadcast(5, MsgConfig.ReplaceCustomMsg, false);
                    });
                }
            }
        }
        internal void CheckKill(ref PlayerHurtEvent ev, Team team, Team target, ReferenceHub attacker, ReferenceHub player)
        {
            if (attacker == null || player == null)
            {
                SetAmountZero(ref ev);
                return;
            }
            bool ntf        = (target == Team.MTF || target == Team.RSC || ((target == Team.CHI || target == Team.CDP) && player.IsHandCuffed())) && (team == Team.MTF || team == Team.RSC);
            bool ci         = (target == Team.CHI || target == Team.CDP || ((target == Team.MTF || target == Team.RSC) && player.IsHandCuffed())) && (team == Team.CHI || team == Team.CDP);
            bool scpNear    = plugin.useScpNear ? IsScpNearby(player, plugin.maxScpDist) : false;
            bool inElevator = plugin.useInElevator ? IsNearElevator(player, 20f) : false;

            if ((ntf || ci))
            {
                if (!teamKills.ContainsKey(attacker.GetUserId()))
                {
                    teamKills.Add(attacker.GetUserId(), 0);
                }
                if (!teamKillTimers.ContainsKey(attacker.GetUserId()))
                {
                    teamKillTimers.Add(attacker.GetUserId(), 0f);
                }
                var curtks = teamKills[attacker.GetUserId()];
                if (team == Team.RIP || Time.timeSinceLevelLoad - teamKillTimers[attacker.GetUserId()] <= plugin.TKInterval || scpNear || inElevator || IsTeamSquadNearby(player, team, target, plugin.maxTeamDist))
                {
                    SetAmountZero(ref ev);
                    BroadCastToPlayer(attacker, 3, "You cannot teamkill now.");
                    return;
                }
                else if (IsPossibleRevenge(ref ev))
                {
                    SetAmountZero(ref ev);
                    BroadCastToPlayer(attacker, 3, "You cannot revengekill.");
                    return;
                }
                else if (teamKills[attacker.GetUserId()] >= plugin.maxTK)
                {
                    SetAmountZero(ref ev);
                    BroadCastToPlayer(attacker, 3, "Max teamkills reached.");
                    return;
                }
                else if (player.GetHealth() - ev.Amount <= 0f)
                {
                    teamKills[attacker.GetUserId()]++;
                    attacker.Broadcast(3, "Teamkills Left: " + (plugin.maxTK - (curtks + 1)), false);
                    if (!teamKillTimers.ContainsKey(attacker.GetUserId()))
                    {
                        teamKillTimers.Add(attacker.GetUserId(), Time.timeSinceLevelLoad);
                    }
                    teamKillTimers[attacker.GetUserId()] = Time.timeSinceLevelLoad;
                    var data = new TeamKillCoolDown()
                    {
                        NotRevengeUserId = attacker.GetUserId(),
                        Time             = Time.timeSinceLevelLoad,
                        UserId           = player.GetUserId()
                    };
                    teamKillRevengeTimers.Add(data);
                }
            }

            /*else if ((ntf || ci) && (inElevator || scpNear))
             * {
             *  ev.Amount = 0f;
             *  BroadCastToPlayer(ev.Attacker, 3, "You cannot teamkill now.");
             *  return;
             * }*/
        }