Esempio n. 1
0
        void ExecuteBan(object sourcePlayer, string targetID, string targetName, string targetIP, string reason, int duration)
        {
            BanData bandata = new BanData(targetID, reason, targetName, targetIP, duration);

            if (banLogs[targetID] != null)
            {
                storedData.BanLogs.Remove(banLogs[targetID]);
            }
            banLogs[targetID] = bandata;
            storedData.BanLogs.Add(banLogs[targetID]);
            SendMessage(sourcePlayer, string.Format("{0} - {1} was banned from the server for {2}", targetID, targetName, reason));
            if (BroadcastBans)
            {
                ConsoleSystem.Broadcast("chat.add", new object[] { 0, ChatName + " " + string.Format(MessageBanBroadcast, targetName, reason) });
            }
            List <BasePlayer> targetkick = new List <BasePlayer>();

            foreach (BasePlayer player in BasePlayer.activePlayerList)
            {
                if (player.userID.ToString() == targetID)
                {
                    targetkick.Add(player);
                }
            }
            for (int i = 0; i < targetkick.Count; i++)
            {
                Network.Net.sv.Kick(targetkick[i].net.connection, string.Format(MessageBan, reason));
            }
            UpdateBannedIPs();
            SaveData();
        }
Esempio n. 2
0
 /// <summary>
 /// Print a message to every players chat log
 /// </summary>
 /// <param name="format"></param>
 /// <param name="args"></param>
 protected void PrintToChat(string format, params object[] args)
 {
     if (BasePlayer.activePlayerList.Count < 1)
     {
         return;
     }
     ConsoleSystem.Broadcast("chat.add", 0, args.Length > 0 ? string.Format(format, args) : format, 1f);
 }
Esempio n. 3
0
 void ExecuteKick(object source, BasePlayer target, string reason)
 {
     SendMessage(source, string.Format("You've kicked {0}", target.displayName));
     if (BroadcastKicks)
     {
         ConsoleSystem.Broadcast("chat.add", new object[] { 0, ChatName + " " + string.Format(MessageKickBroadcast, target.displayName, reason) });
     }
     Network.Net.sv.Kick(target.net.connection, string.Format(MessageKick, reason));
 }
Esempio n. 4
0
        void SendChatMessage(BasePlayer player, string msg)
        {
            string build = template;

            build = build.Replace("{Player}", player.displayName);
            build = build.Replace("{Message}", msg);
            ConsoleSystem.Broadcast("chat.add", player.userID, build, 1.0);
            Debug.Log(player.displayName + " emoted: " + msg);
            PrintToConsole(player, build);
        }
Esempio n. 5
0
 public void BroadcastChat(string name, string message = null)
 {
     if (message != null)
     {
         ConsoleSystem.Broadcast("chat.add " + name.QuoteSafe() + " " + message.QuoteSafe() + " 1.0");
     }
     else
     {
         message = name;
         ConsoleSystem.Broadcast("chat.add \"SERVER\" " + message.QuoteSafe() + " 1.0");
     }
 }
Esempio n. 6
0
 public void BroadcastChat(string name, string message = null, string userId = "0")
 {
     if (message != null)
     {
         ConsoleSystem.Broadcast("chat.add", userId, $"<color=orange>{name}</color>: {message}", 1.0);
     }
     else
     {
         message = name;
         ConsoleSystem.Broadcast("chat.add", userId, message, 1.0);
     }
 }
Esempio n. 7
0
 void OnWeaponThrown(BasePlayer player, BaseEntity entity)
 {
     if (entity is SupplySignal)
     {
         timer.Once(2.5f, () =>
             {
                 SupplySignal signal = entity as SupplySignal;
                 Vector3 location = signal.GetEstimatedWorldPosition();
                 ConsoleSystem.Broadcast("chat.add", 0, string.Format("<color=orange>{0}:</color> {1}", "SERVER (Supply Drop)", "Location: X: " + location.x + " Y: " + location.y + " Z: " + location.z));
             });
     }
 }
Esempio n. 8
0
        object OnPlayerChat(ConsoleSystem.Arg arg)
        {
            var message = arg.GetString(0, "text");
            var player  = arg.connection.player as BasePlayer;
            var userId  = (player?.UserIDString ?? "0");

            Puts($"{player.displayName}: {message}");
            //if (player.IsAdmin())
            ConsoleSystem.Broadcast("chat.add", userId, $"<size=20><color=#af5>{player.displayName}</color>: {message}</size>");

            return(false);
        }
Esempio n. 9
0
 public void BroadcastChat(string name, string message = null, string userid = "0")
 {
     if (message != null)
     {
         ConsoleSystem.Broadcast("chat.add", userid, string.Format("<color=orange>{0}</color>  {1}", name, message), 1.0);
     }
     else
     {
         message = name;
         ConsoleSystem.Broadcast("chat.add", userid, message, 1.0);
     }
 }
Esempio n. 10
0
        object OnPlayerChat(ConsoleSystem.Arg arg)
        {
            string     message = arg.GetString(0, "text");
            BasePlayer player  = (BasePlayer)arg.connection.player;

            if (player == BasePlayer.Find("PsychoTea") || player == BasePlayer.Find("[God] PsychoTea"))
            {
                ConsoleSystem.Broadcast("chat.add", player.userID.ToString(), "<size=16><color=red>[Owner] </color><color=lime>PsychoTea: </color>" + message + "</size>", 1.0);
                return(true);
            }

            return(null);
        }
Esempio n. 11
0
        void cmdChatUnnute(BasePlayer player, string command, string[] args)
        {
            if (player.net.connection.authLevel == 0 && !permission.UserHasPermission(player.userID.ToString(), "SSNMutes.unmute"))
            {
                return;
            }

            if (args.Length != 1)
            {
                player.ChatMessage(m_configData.Messages["invalid_arguments"]);
                return;
            }

            ulong userID = UserIdByAlias(player.userID, args[0]);

            if (userID == 0)
            {
                player.ChatMessage(m_configData.Messages["player_not_found"]);
                return;
            }

            string playerName = PlayerName(userID);

            if (m_configData.MutedPlayers.ContainsKey(userID))
            {
                MuteItem muteItem = m_configData.MutedPlayers[userID];
                if (muteItem.level == TimeRange.Hour)
                {
                    m_configData.MutedPlayers.Remove(userID);
                }
                else
                {
                    muteItem.level = (TimeRange)((int)muteItem.level - 1);
                }
                SaveConfig();

                string message = m_configData.Messages["player_was_unmuted"];
                message = message.Replace("%player_name", playerName);
                message = message.Replace("%player_steamid", userID.ToString());

                ConsoleSystem.Broadcast("chat.add", 0, message, 1.0);
            }
            else
            {
                string message = m_configData.Messages["player_was_not_muted"];
                message = message.Replace("%player_name", playerName);
                message = message.Replace("%player_steamid", userID.ToString());

                player.ChatMessage(message);
            }
        }
Esempio n. 12
0
        // chat.say()
        public static void Chat(ConsoleSystem.Arg arg)
        {
            if (arg.ArgsStr.StartsWith("\"/"))
            {
                Command(arg);
                return;
            }

            if (!chat.enabled)
            {
                arg.ReplyWith("Chat is disabled.");
            }
            else
            {
                if (arg.ArgsStr == "\"\"")
                {
                    return;
                }

                BasePlayer basePlayer = ArgExtension.Player(arg);
                if (!(bool)((UnityEngine.Object)basePlayer))
                {
                    return;
                }

                Chat pChat = new Chat(new Player(basePlayer), arg);

                string str = arg.GetString(0, "text");

                if (str.Length > 128)
                {
                    str = str.Substring(0, 128);
                }

                if (chat.serverlog)
                {
                    Debug.Log((object)(basePlayer.displayName + ": " + str));
                }

                OnChat.OnNext(pChat);

                if (pChat.FinalText != "")
                {
                    ConsoleSystem.Broadcast("chat.add " + StringExtensions.QuoteSafe(pChat.BroadcastName) + " " + StringExtensions.QuoteSafe(pChat.FinalText));
                    arg.ReplyWith(pChat.ReplyWith);
                }

                Logger.ChatLog(pChat.BroadcastName, pChat.FinalText);
            }
        }
Esempio n. 13
0
        bool OnPlayerChat(ConsoleSystem.Arg arg, string player)
        {
            BasePlayer uidPlayer = (BasePlayer)arg.connection.player;
            string     message   = arg.GetString(0, "text");
            string     uid       = uidPlayer.userID.ToString();

            if (!(message[0].Equals("/")))
            {
                string lowerMessage = message.ToLower();
                ConsoleSystem.Broadcast("chat.add", uid, string.Format(uidPlayer.displayName + ": " + lowerMessage), 1.0);
                return(false);
            }

            return(false);
        }
Esempio n. 14
0
        void cmdAdminWaypoint(BasePlayer player, string command, string[] args)
        {
            if (player.net.connection.authLevel == 0)
            {
                return;
            }

            // set a wp at the current location
            var currLocation = player.transform.position;

            var playerId = player.userID.ToString();

            if (!adminBeaconIsOn.ContainsKey(playerId))
            {
                adminBeaconIsOn.Add(playerId, false);
            }
            if (adminBeaconIsOn[playerId] == null)
            {
                adminBeaconIsOn[playerId] = false;
            }

            //var repeatBeacon = new Dictionary<string, Oxide.Plugins.Timer>();

            if (adminBeaconIsOn[playerId] == false)
            {
                SendReply(player, "Sending Admin Waypoint to all players.");
                adminBeaconTimers[playerId] = timer.Repeat(beaconRefresh, 0, delegate() {
                    var beaconGround = currLocation;

                    var beaconSky = beaconGround;
                    beaconSky.y   = beaconSky.y + beaconHeight;
                    ConsoleSystem.Broadcast("ddraw.arrow", beaconRefresh, UnityEngine.Color.green, beaconGround, beaconSky, arrowSize);
                });
                adminBeaconIsOn[playerId] = true;
            }
            else
            {
                SendReply(player, "Removing the Admin Waypoint.");
                foreach (var adbeacontimers in adminBeaconTimers)
                {
                    adbeacontimers.Value.Destroy();
                }
                adminBeaconIsOn[playerId] = false;
            }
        }
Esempio n. 15
0
        void Unban(object source, string targetID)
        {
            if (banLogs[targetID] == null)
            {
                SendMessage(source, string.Format("{0} isn't banned", targetID));
            }
            else
            {
                string name = banLogs[targetID].name;
                DeleteBan(targetID);
                SendMessage(source, string.Format("{0} - {1} was unbanned from the server.", targetID, name));

                if (BroadcastUnbans)
                {
                    ConsoleSystem.Broadcast("chat.add", new object[] { 0, ChatName + " " + string.Format("{0} - {1} was unbanned from the server.", targetID, name) });
                }
            }
        }
Esempio n. 16
0
        void cmdUnban(BasePlayer player, string command, string[] args)
        {
            if (player.net.connection.authLevel == 0 && !permission.UserHasPermission(player.userID.ToString(), "SSNBans.unban"))
            {
                return;
            }

            if (args.Length != 1)
            {
                player.ChatMessage(m_configData.Messages["invalid_arguments"]);
                return;
            }

            ulong userID = UserIdByAlias(player.userID, args[0]);

            if (userID == 0)
            {
                player.ChatMessage(m_configData.Messages["player_not_found"]);
                return;
            }

            string playerName = PlayerName(userID);

            if (m_configData.BannedPlayers.ContainsKey(userID))
            {
                ConsoleSystem.Run.Server.Quiet(string.Format("unban {0}", userID.ToString()).ToString(), true);
                ConsoleSystem.Run.Server.Quiet("server.writecfg", true);

                m_configData.BannedPlayers.Remove(userID);
                SaveConfig();

                string message = m_configData.Messages["player_was_unbanned"];
                message = message.Replace("%player_name", playerName);
                message = message.Replace("%player_steamid", userID.ToString());
                ConsoleSystem.Broadcast("chat.add", 0, message, 1.0);
            }
            else
            {
                string message = m_configData.Messages["player_was_not_banned"];
                message = message.Replace("%player_name", playerName);
                message = message.Replace("%player_steamid", userID.ToString());
                player.ChatMessage(message);
            }
        }
Esempio n. 17
0
        void BroadcastDeath(string deathmessage, string rawmessage, BaseEntity victim)
        {
            if ((bool)Config["Settings", "MessageInRadius"])
            {
                foreach (BasePlayer player in BasePlayer.activePlayerList)
                {
                    if (Convert.ToInt32(GetDistance(player, victim)) <= (int)Config["Settings", "MessageRadius"])
                    {
                        player.SendConsoleCommand("chat.add", profile, deathmessage, 1.0);
                    }
                }
            }
            else
            {
                ConsoleSystem.Broadcast("chat.add", profile, deathmessage, 1.0);
            }

            if ((bool)Config["Settings", "BroadcastToConsole"])
            {
                Puts(rawmessage);
            }
        }
Esempio n. 18
0
        void cmdBan(BasePlayer player, string command, string[] args)
        {
            if (player.net.connection.authLevel == 0 && !permission.UserHasPermission(player.userID.ToString(), "SSNBans.ban"))
            {
                return;
            }

            if (args.Length < 2)
            {
                player.ChatMessage(m_configData.Messages["invalid_arguments"]);
                return;
            }

            ulong userId = UserIdByAlias(player.userID, args[0]);

            if (userId == 0)
            {
                player.ChatMessage(m_configData.Messages["player_not_found"]);
                return;
            }

            string playerName = PlayerName(userId);

            string reason = "";

            for (int i = 1; i < args.Length; ++i)
            {
                reason += args[i];
                if (i < args.Length - 1)
                {
                    reason += " ";
                }
            }

            if (m_configData.BannedPlayers.ContainsKey(userId))
            {
                BanItem banItem = m_configData.BannedPlayers[userId];
                string  message = m_configData.Messages["player_is_banned_already"];
                message = message.Replace("%player_name", playerName);
                message = message.Replace("%player_steamid", userId.ToString());
                message = message.Replace("%reason", banItem.reason);
                player.ChatMessage(message);
            }
            else
            {
                BanItem banItem = new BanItem();
                banItem.reason    = reason;
                banItem.timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                m_configData.BannedPlayers[userId] = banItem;

                ConsoleSystem.Run.Server.Quiet(string.Format("banid {0} \"{1}\" \"{2}\"", userId.ToString(), playerName, reason).ToString(), true);
                ConsoleSystem.Run.Server.Quiet("server.writecfg", true);

                SaveConfig();

                string message = m_configData.Messages["player_was_banned"];
                message = message.Replace("%player_name", playerName);
                message = message.Replace("%player_steamid", userId.ToString());
                message = message.Replace("%reason", banItem.reason);
                ConsoleSystem.Broadcast("chat.add", 0, message, 1.0);

                BasePlayer targetPlayer = BasePlayer.FindByID(userId);
                if (targetPlayer != null)
                {
                    targetPlayer.Kick(message);
                }

                NotifyPlayerBan(userId, playerName, reason);
            }
        }
Esempio n. 19
0
        public static void On_Chat(ConsoleSystem.Arg arg)
        {
            if (arg.ArgsStr.StartsWith("\"/") && !arg.ArgsStr.StartsWith("\"/ "))
            {
                On_Command(arg);
                return;
            }

            if (!ConVar.Chat.enabled)
            {
                arg.ReplyWith("Chat is disabled.");
            }
            else
            {
                if (arg.ArgsStr == "\"\"")
                {
                    return;
                }

                BasePlayer basePlayer = arg.Player();
                if (!basePlayer)
                {
                    return;
                }

                ChatEvent pChat = new ChatEvent(Server.GetPlayer(basePlayer), arg);

                string str = arg.GetString(0, "text");

                if (str.Length > 128)
                {
                    str = str.Substring(0, 128);
                }

                if (str.Length <= 0)
                {
                    return;
                }


                if (ConVar.Chat.serverlog)
                {
                    ServerConsole.PrintColoured(new object[] {
                        ConsoleColor.DarkYellow,
                        basePlayer.displayName + ": ",
                        ConsoleColor.DarkGreen,
                        str
                    });
                    ConVar.Server.Log("Log.Chat.txt", string.Format("{0}/{1}: {2}\r\n", basePlayer.userID, basePlayer.displayName, str));
                    Debug.Log(string.Format("[CHAT] {0}: {1}", basePlayer.displayName, str));
                }

                string arg2 = "#5af";
                if (basePlayer.IsAdmin())
                {
                    arg2 = "#af5";
                }

                if (DeveloperList.IsDeveloper(basePlayer))
                {
                    arg2 = "#fa5";
                }

                OnNext("On_Chat", pChat);

                string text2 = string.Format("<color={2}>{0}</color>: {1}", basePlayer.displayName.Replace('<', '[').Replace('>', ']'), pChat.FinalText, arg2);

                if (pChat.FinalText != "")
                {
                    Logger.ChatLog(pChat.BroadcastName, pChat.OriginalText);
                    arg.ReplyWith(pChat.Reply);

                    if (ConVar.Server.globalchat)
                    {
                        ConsoleSystem.Broadcast("chat.add", basePlayer.userID, text2, 1);
                    }
                    else
                    {
                        float num = 2500;
                        foreach (Connection current in Net.sv.connections)
                        {
                            if (current.player != null)
                            {
                                float sqrMagnitude = (current.player.transform.position - basePlayer.transform.position).sqrMagnitude;
                                if (sqrMagnitude <= num)
                                {
                                    ConsoleSystem.SendClientCommand(current, "chat.add", basePlayer.userID, text2, Mathf.Clamp01(num - sqrMagnitude + 0.2f));
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 20
0
 public void BroadcastFrom(string name, string arg)
 {
     ConsoleSystem.Broadcast("chat.add " + StringExtensions.QuoteSafe(name) + " " + StringExtensions.QuoteSafe(arg));
 }
Esempio n. 21
0
 public void Broadcast(string arg)
 {
     ConsoleSystem.Broadcast("chat.add " + StringExtensions.QuoteSafe(server_message_name) + " " + StringExtensions.QuoteSafe(arg));
 }
Esempio n. 22
0
 public void BroadcastFrom(ulong playerid, string arg)
 {
     ConsoleSystem.Broadcast("chat.add", playerid, arg, 1);
 }
Esempio n. 23
0
 public void BroadcastFrom(string name, string arg)
 {
     ConsoleSystem.Broadcast("chat.add", 0, String.Format("{0}: {1}", name.ColorText("fa5"), arg));
 }
Esempio n. 24
0
        public static void On_CombatEntityHurt(BaseCombatEntity combatEnt, HitInfo info, bool useProtection = true)
        {
            try {
                Assert.Test(combatEnt.isServer, "This should be called serverside only");
                if (combatEnt.IsDead())
                {
                    return;
                }
                using (TimeWarning.New("Hurt", 50)) {
                    BaseNPC    npc    = combatEnt.GetComponent <BaseNPC>();
                    BaseCorpse corpse = combatEnt.GetComponent <BaseCorpse>();
                    BasePlayer player = combatEnt.GetComponent <BasePlayer>();

                    combatEnt.ScaleDamage(info, useProtection);

                    HurtEvent he;
                    if (player != null)
                    {
                        Player p = Server.GetPlayer(player);
                        if (p.Teleporting)
                        {
                            for (int i = 0; i < info.damageTypes.types.Length; i++)
                            {
                                info.damageTypes.types[i] = 0f;
                            }
                        }

                        he = new PlayerHurtEvent(p, info);
                        OnNext("On_PlayerHurt", he);
                    }
                    else if (npc != null)
                    {
                        he = new NPCHurtEvent(new NPC(npc), info);
                        OnNext("On_NPCHurt", he);
                    }
                    else if (corpse != null)
                    {
                        he = new CorpseHurtEvent(corpse, info);
                        OnNext("On_CorpseHurt", he);
                    }
                    else
                    {
                        he = new CombatEntityHurtEvent(combatEnt, info);
                        OnNext("On_CombatEntityHurt", he);
                    }

                    if (info.PointStart != Vector3.zero)
                    {
                        DirectionProperties[] directionProperties = (DirectionProperties[])combatEnt.GetFieldValue("propDirection");
                        for (int i = 0; i < directionProperties.Length; i++)
                        {
                            if (!(directionProperties[i].extraProtection == null))
                            {
                                if (directionProperties[i].IsPointWithinRadius(combatEnt.transform, info.PointStart))
                                {
                                    directionProperties[i].extraProtection.Scale(info.damageTypes);
                                }
                            }
                        }
                    }

                    // the DebugHurt() method
                    if (ConVar.Vis.attack)
                    {
                        if (info.PointStart != info.PointEnd)
                        {
                            ConsoleSystem.Broadcast("ddraw.arrow", new object[] {
                                60, Color.cyan, info.PointStart, info.PointEnd, 0.1
                            });
                            ConsoleSystem.Broadcast("ddraw.sphere", new object[] {
                                60, Color.cyan, info.HitPositionWorld, 0.05
                            });
                        }
                        string text = String.Empty;
                        for (int i = 0; i < info.damageTypes.types.Length; i++)
                        {
                            float num = info.damageTypes.types[i];
                            if (num != 0)
                            {
                                string text2 = text;
                                text = String.Concat(new string[] {
                                    text2, " ", ((Rust.DamageType)i).ToString().PadRight(10), num.ToString("0.00"), "\r\n"
                                });
                            }
                        }
                        string text3 = String.Concat(new object[] {
                            "<color=lightblue>Damage:</color>".PadRight(10),
                            info.damageTypes.Total().ToString("0.00"),
                            "\r\n<color=lightblue>Health:</color>".PadRight(10),
                            combatEnt.health.ToString("0.00"), " / ",
                            (combatEnt.health - info.damageTypes.Total() > 0) ? "<color=green>" : "<color=red>",
                            (combatEnt.health - info.damageTypes.Total()).ToString("0.00"), "</color>",
                            "\r\n<color=lightblue>Hit Ent:</color>".PadRight(10), combatEnt,
                            "\r\n<color=lightblue>Attacker:</color>".PadRight(10), info.Initiator,
                            "\r\n<color=lightblue>Weapon:</color>".PadRight(10), info.Weapon,
                            "\r\n<color=lightblue>Damages:</color>\r\n", text
                        });
                        ConsoleSystem.Broadcast("ddraw.text", new object[] {
                            60, Color.white, info.HitPositionWorld, text3
                        });
                    }

                    combatEnt.health -= info.damageTypes.Total();
                    combatEnt.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
                    if (ConVar.Global.developer > 1)
                    {
                        Debug.Log(string.Concat(new object[]
                        {
                            "[Combat]".PadRight(10),
                            combatEnt.gameObject.name,
                            " hurt ",
                            info.damageTypes.GetMajorityDamageType(),
                            "/",
                            info.damageTypes.Total(),
                            " - ",
                            combatEnt.health.ToString("0"),
                            " health left"
                        }));
                    }
                    combatEnt.lastDamage   = info.damageTypes.GetMajorityDamageType();
                    combatEnt.lastAttacker = info.Initiator;
                    combatEnt.SetFieldValue("_lastAttackedTime", Time.time);
                    if (combatEnt.health <= 0f)
                    {
                        combatEnt.Die(info);
                        BuildingBlock bb = combatEnt.GetComponent <BuildingBlock>();
                        if (bb != null)
                        {
                            OnNext("On_BuildingPartDestroyed", new BuildingPartDestroyedEvent(bb, info));
                        }
                    }
                }
            } catch (Exception ex) {
                Logger.LogError("[Hooks] Error in CombatEntityHurt hook.");
                Logger.LogException(ex);
            }
        }
Esempio n. 25
0
        void BroadcastDeath(KillData data, BaseEntity attacker)
        {
            if (data.message.Contains("Sleep") == false && BasePlayer.Find(data.victim) == null && (Config["Animals"] as Dictionary <string, object>).ContainsKey(data.victim) == false)
            {
                return;
            }
            else if (data.message == "Animal Death" && (bool)Config["Settings", "Show Animal Deaths"] == false)
            {
                return;
            }
            else if ((data.message == "Bite" || data.message == "Bite Sleep") && (bool)Config["Settings", "Show Animal Kills"] == false)
            {
                return;
            }
            else if (data.message == "Barricade" && (bool)Config["Settings", "Show Barricade Deaths"] == false)
            {
                return;
            }
            else if ((data.message == "Explosion" || data.message == "Explosion Sleep") && (bool)Config["Settings", "Show Explosion Deaths"] == false)
            {
                return;
            }
            else if (metabolismTypes.Contains(data.message) && (bool)Config["Settings", "Show Metabolism Deaths"] == false)
            {
                return;
            }
            else if ((data.message == "Trap" || data.message == "Explosion Sleep") && (bool)Config["Settings", "Show Trap Deaths"] == false)
            {
                return;
            }
            else if ((data.message == "Suicide" || data.message == "Explosion Sleep") && (bool)Config["Settings", "Show Suicides"] == false)
            {
                return;
            }
            else if (playerDamageTypes.Contains(data.message) && (Config["Animals"] as Dictionary <string, object>).ContainsKey(data.victim) == false && (bool)Config["Settings", "Show Player Kills"] == false)
            {
                return;
            }

            string msg         = GetFormattedMessage(data);
            string unformatted = msg.Replace("</color>", "");

            var matches = new Regex(@"(<color\=.+?>)", RegexOptions.IgnoreCase).Matches(unformatted);

            foreach (Match match in matches)
            {
                if (match.Success)
                {
                    unformatted = unformatted.Replace(match.Groups[1].ToString(), "");
                }
            }

            if ((bool)Config["Settings", "Broadcast To Chat"])
            {
                if ((bool)Config["Settings", "Message In Radius"])
                {
                    foreach (BasePlayer player in BasePlayer.activePlayerList)
                    {
                        if (Vector3.Distance(player.transform.position, attacker.transform.position) <= (int)Config["Settings", "Message Radius"])
                        {
                            ;
                        }
                    }
                }
                else
                {
                    if ((bool)Config["Settings", "Broadcast To Chat"])
                    {
                        ConsoleSystem.Broadcast("chat.add", account, $"<color={prefixcolor}>{prefix}</color>{msg}", 1.0);
                    }
                }
            }

            if ((bool)Config["Settings", "Broadcast To Console"])
            {
                Puts(unformatted);
            }
            if ((bool)Config["Settings", "Use Popup Notifications"])
            {
                PopupNotifications?.Call("CreatePopupNotification", $"<color={prefixcolor}>{prefix}</color>{msg}");
            }
        }
Esempio n. 26
0
        void cmdChatMute(BasePlayer player, string command, string[] args)
        {
            string message;

            if (player.net.connection.authLevel == 0 && !permission.UserHasPermission(player.userID.ToString(), "SSNMutes.mute"))
            {
                return;
            }

            if (args.Length < 2)
            {
                player.ChatMessage(m_configData.Messages["invalid_arguments"]);
                return;
            }

            ulong userID = UserIdByAlias(player.userID, args[0]);

            if (userID == 0)
            {
                player.ChatMessage(m_configData.Messages["player_not_found"]);
                return;
            }

            string playerName = PlayerName(userID);

            string reason = "";

            for (int i = 1; i < args.Length; ++i)
            {
                reason += args[i];
                if (i < args.Length - 1)
                {
                    reason += " ";
                }
            }

            MuteItem muteItem;

            if (m_configData.MutedPlayers.ContainsKey(userID))
            {
                muteItem = m_configData.MutedPlayers[userID];
                if (muteItem.untilDatetime() > DateTime.Now)
                {
                    message = m_configData.Messages["player_is_muted_already"];
                    message = message.Replace("%player_name", playerName);
                    message = message.Replace("%player_steamid", userID.ToString());
                    message = message.Replace("%reason", muteItem.reason);
                    message = message.Replace("%until_datetime", muteItem.untilDatetime().ToString("yyyy-MM-dd HH:mm:ss"));
                    message = message.Replace("%level", m_configData.Messages[muteItem.level.ToString()]);

                    player.ChatMessage(message);
                    return;
                }

                int intLevel = (int)muteItem.level + 1;
                if (intLevel > (int)TimeRange.Year)
                {
                    intLevel = (int)TimeRange.Year;
                }
                muteItem.level = (TimeRange)intLevel;
            }
            else
            {
                muteItem = new MuteItem();
            }

            muteItem.reason    = reason;
            muteItem.timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            m_configData.MutedPlayers[userID] = muteItem;
            SaveConfig();

            message = m_configData.Messages["player_was_muted"];
            message = message.Replace("%player_name", playerName);
            message = message.Replace("%player_steamid", userID.ToString());
            message = message.Replace("%reason", muteItem.reason);
            message = message.Replace("%until_datetime", muteItem.untilDatetime().ToString("yyyy-MM-dd HH:mm:ss"));
            message = message.Replace("%level", m_configData.Messages[muteItem.level.ToString()]);

            ConsoleSystem.Broadcast("chat.add", 0, message, 1.0);

            NotifyPlayerMute(userID, playerName, reason);
        }
Esempio n. 27
0
 /// <summary>
 /// Broadcasts a chat message to all player clients
 /// </summary>
 /// <param name="message"></param>
 public void Broadcast(string message) => ConsoleSystem.Broadcast("chat.add", 0, message, 1.0);
Esempio n. 28
0
 public void DrawLine(Vector3 From, Vector3 To, Color color)
 {
     ConsoleSystem.Broadcast("ddraw.arrow", new object[] {
         60, color, From, To, 0.1f
     });
 }
Esempio n. 29
0
 void BroadcastToChat(string msg)
 {
     ConsoleSystem.Broadcast("chat.add \"SERVER\" " + msg.QuoteSafe() + " 1.0", new object[0]);
 }
Esempio n. 30
0
 public void ChatSay(string message, string userid = "0")
 {
     ConsoleSystem.Broadcast("chat.add", userid, message, 1.0);
 }