Esempio n. 1
0
        private void CmdRevoke(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg))
            {
                return;
            }
            if (!IsAdmin(arg))
            {
                return;
            }
            if (!arg.HasArgs(3))
            {
                arg.ReplyWith("Syntax: revoke <group|user> <name|id> <permission>");
                return;
            }

            var mode = arg.GetString(0);
            var name = arg.GetString(1);
            var perm = arg.GetString(2);

            if (!permission.PermissionExists(perm))
            {
                arg.ReplyWith("Permission '" + perm + "' doesn't exist");
                return;
            }

            if (mode.Equals("group"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                permission.RevokeGroupPermission(name, perm);
                arg.ReplyWith("Group '" + name + "' revoked permission: " + perm);
            }
            else if (mode.Equals("user"))
            {
                var player = FindPlayer(name);
                if (player == null && !permission.UserExists(name))
                {
                    arg.ReplyWith("User '" + name + "' not found");
                    return;
                }
                var userId = name;
                if (player != null)
                {
                    userId = player.userID.ToString();
                    name   = player.displayName;
                    permission.UpdateNickname(userId, name);
                    name += $"({userId})";
                }
                permission.RevokeUserPermission(userId, perm);
                arg.ReplyWith("User '" + name + "' revoked permission: " + perm);
            }
        }
Esempio n. 2
0
        private void cmdGroup(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg))
            {
                return;
            }
            if (!IsAdmin(arg))
            {
                return;
            }
            if (!arg.HasArgs(2))
            {
                var reply = "Syntax: group <add|set> <name> [title] [rank]";
                reply += "Syntax: group <remove> <name>\n";
                reply += "Syntax: group <parent> <name> <parentName>";
                arg.ReplyWith(reply);
                return;
            }

            var mode  = arg.GetString(0);
            var name  = arg.GetString(1);
            var title = arg.GetString(2);
            var rank  = arg.GetInt(3);

            if (mode.Equals("add"))
            {
                if (permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' already exist");
                    return;
                }
                permission.CreateGroup(name, title, rank);
                arg.ReplyWith("Group '" + name + "' created");
            }
            else if (mode.Equals("remove"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                permission.RemoveGroup(name);
                arg.ReplyWith("Group '" + name + "' deleted");
            }
            else if (mode.Equals("set"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                permission.SetGroupTitle(name, title);
                permission.SetGroupRank(name, rank);
                arg.ReplyWith("Group '" + name + "' changed");
            }
        }
        private void ChangeTab(ConsoleSystem.Arg arg)
        {
            if (arg.Connection == null || arg.Connection.player == null || !arg.HasArgs(4) || _settings == null)
            {
                return;
            }

            var player = arg.Connection.player as BasePlayer;

            if (player == null)
            {
                return;
            }

            if (!PlayerActiveTabs.ContainsKey(player.userID))
            {
                return;
            }

            var previousTabIndex = PlayerActiveTabs[player.userID].ActiveTabIndex;
            var tabToChangeTo    = arg.GetInt(0, 65535);

            if (previousTabIndex == tabToChangeTo)
            {
                return;
            }

            var tabToSelectIndex      = arg.GetInt(0);
            var activeButtonName      = arg.GetString(1);
            var tabToSelectButtonName = arg.GetString(2);
            var mainPanelName         = arg.GetString(3);

            CuiHelper.DestroyUi(player, PlayerActiveTabs[player.userID].ActiveTabContentPanelName);
            CuiHelper.DestroyUi(player, activeButtonName);
            CuiHelper.DestroyUi(player, tabToSelectButtonName);

            var allowedTabs = _settings.Tabs
                              .Where((tab, tabIndex) => string.IsNullOrEmpty(tab.OxideGroup) ||
                                     tab.OxideGroup.Split(',')
                                     .Any(group => Permission.UserHasGroup(player.userID.ToString(CultureInfo.InvariantCulture), group)))
                              .ToList();
            var tabToSelect = allowedTabs[tabToSelectIndex];

            PlayerActiveTabs[player.userID].ActiveTabIndex = tabToSelectIndex;
            PlayerActiveTabs[player.userID].PageIndex      = 0;

            var container           = new CuiElementContainer();
            var tabContentPanelName = CreateTabContent(tabToSelect, container, mainPanelName);
            var newActiveButtonName = AddActiveButton(tabToSelectIndex, tabToSelect, container, mainPanelName);

            AddNonActiveButton(previousTabIndex, container, _settings.Tabs[previousTabIndex], mainPanelName, newActiveButtonName);

            PlayerActiveTabs[player.userID].ActiveTabContentPanelName = tabContentPanelName;

            SendUI(player, container);
        }
Esempio n. 4
0
        private void CmdRevoke(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg))
            {
                return;
            }
            if (!IsAdmin(arg))
            {
                return;
            }
            if (!arg.HasArgs(3))
            {
                ReplyWith(arg.connection, "CommandUsageRevoke");
                return;
            }

            var mode = arg.GetString(0);
            var name = arg.GetString(1);
            var perm = arg.GetString(2);

            if (!permission.PermissionExists(perm))
            {
                ReplyWith(arg.connection, "PermissionNotFound", perm);
                return;
            }

            if (mode.Equals("group"))
            {
                if (!permission.GroupExists(name))
                {
                    ReplyWith(arg.connection, "GroupNotFound", name);
                    return;
                }
                permission.RevokeGroupPermission(name, perm);
                ReplyWith(arg.connection, "GroupPermissionRevoked", name, perm);
            }
            else if (mode.Equals("user"))
            {
                var player = FindPlayer(name);
                if (player == null && !permission.UserExists(name))
                {
                    ReplyWith(arg.connection, "UserNotFound", name);
                    return;
                }
                var userId = name;
                if (player != null)
                {
                    userId = player.userID.ToString();
                    name   = player.displayName;
                    permission.UpdateNickname(userId, name);
                }
                permission.RevokeUserPermission(userId, perm);
                ReplyWith(arg.connection, "UserPermissionRevoked", $"{name} ({userId})", perm);
            }
        }
Esempio n. 5
0
        private void CmdUserGroup(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg))
            {
                return;
            }
            if (!IsAdmin(arg))
            {
                return;
            }
            if (!arg.HasArgs(3))
            {
                ReplyWith(arg.connection, "CommandUsageUserGroup");
                return;
            }

            var mode  = arg.GetString(0);
            var name  = arg.GetString(1);
            var group = arg.GetString(2);

            var player = FindPlayer(name);

            if (player == null && !permission.UserExists(name))
            {
                ReplyWith(arg.connection, "UserNotFound", name);
                return;
            }
            var userId = name;

            if (player != null)
            {
                userId = player.userID.ToString();
                name   = player.displayName;
                permission.UpdateNickname(userId, name);
                name += $"({userId})";
            }

            if (!permission.GroupExists(group))
            {
                ReplyWith(arg.connection, "GroupNotFound", name);
                return;
            }

            if (mode.Equals("add"))
            {
                permission.AddUserGroup(userId, group);
                ReplyWith(arg.connection, "UserAddedToGroup", name, group);
            }
            else if (mode.Equals("remove"))
            {
                permission.RemoveUserGroup(userId, group);
                ReplyWith(arg.connection, "UserRemovedFromGroup", name, group);
            }
        }
Esempio n. 6
0
        private void CmdUserGroup(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg))
            {
                return;
            }
            if (!IsAdmin(arg))
            {
                return;
            }
            if (!arg.HasArgs(3))
            {
                arg.ReplyWith("Usage: usergroup <add|remove> <username> <groupname>");
                return;
            }

            var mode  = arg.GetString(0);
            var name  = arg.GetString(1);
            var group = arg.GetString(2);

            var player = FindPlayer(name);

            if (player == null && !permission.UserExists(name))
            {
                arg.ReplyWith("User '" + name + "' not found");
                return;
            }
            var userId = name;

            if (player != null)
            {
                userId = player.userID.ToString();
                name   = player.displayName;
                permission.UpdateNickname(userId, name);
                name += $"({userId})";
            }

            if (!permission.GroupExists(group))
            {
                arg.ReplyWith("Group '" + group + "' doesn't exist");
                return;
            }

            if (mode.Equals("add"))
            {
                permission.AddUserGroup(userId, group);
                arg.ReplyWith("User '" + name + "' assigned group: " + group);
            }
            else if (mode.Equals("remove"))
            {
                permission.RemoveUserGroup(userId, group);
                arg.ReplyWith("User '" + name + "' removed from group: " + group);
            }
        }
Esempio n. 7
0
 public static void add(ref ConsoleSystem.Arg arg)
 {
     if (enabled)
     {
         string name = arg.GetString(0, string.Empty);
         string text = arg.GetString(1, string.Empty);
         if ((name != string.Empty) && (text != string.Empty))
         {
             ChatUI.AddLine(name, text);
         }
     }
 }
Esempio n. 8
0
        private void cmdGroup(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg))
            {
                return;
            }
            if (arg.argUser != null && !arg.argUser.CanAdmin())
            {
                return;
            }
            if (!arg.HasArgs(2))
            {
                arg.ReplyWith("Usage: group <add|remove|set> <name> [title] [rank]");
                return;
            }

            var mode  = arg.GetString(0);
            var name  = arg.GetString(1);
            var title = arg.GetString(2);
            var rank  = arg.GetInt(3);

            if (mode.Equals("add"))
            {
                if (permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' already exist");
                    return;
                }
                permission.CreateGroup(name, title, rank);
                arg.ReplyWith("Group '" + name + "' created");
            }
            else if (mode.Equals("remove"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                permission.RemoveGroup(name);
                arg.ReplyWith("Group '" + name + "' deleted");
            }
            else if (mode.Equals("set"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                permission.SetGroupTitle(name, title);
                permission.SetGroupRank(name, rank);
                arg.ReplyWith("Group '" + name + "' changed");
            }
        }
Esempio n. 9
0
        private void cmdGrant(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg))
            {
                return;
            }
            if (arg.argUser != null && !arg.argUser.CanAdmin())
            {
                return;
            }
            if (!arg.HasArgs(3))
            {
                arg.ReplyWith("Usage: grant <group|user> <name|id> <permission>");
                return;
            }

            var mode = arg.GetString(0);
            var name = arg.GetString(1);
            var perm = arg.GetString(2);

            if (mode.Equals("group"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                permission.GrantGroupPermission(name, perm, null);
                arg.ReplyWith("Group '" + name + "' granted permission: " + perm);
            }
            else if (mode.Equals("user"))
            {
                var player = FindPlayer(name);
                if (player == null && !permission.UserExists(name))
                {
                    arg.ReplyWith("User '" + name + "' not found");
                    return;
                }
                var userId = name;
                if (player != null)
                {
                    userId = player.userID.ToString();
                    name   = player.displayName;
                    permission.UpdateNickname(userId, name);
                }
                permission.GrantUserPermission(userId, perm, null);
                arg.ReplyWith("User '" + name + "' granted permission: " + perm);
            }
        }
Esempio n. 10
0
    public static void @add(ref ConsoleSystem.Arg arg)
    {
        if (!chat.enabled)
        {
            return;
        }
        string str  = arg.GetString(0, string.Empty);
        string str1 = arg.GetString(1, string.Empty);

        if (str == string.Empty || str1 == string.Empty)
        {
            return;
        }
        ChatUI.AddLine(str, str1);
    }
Esempio n. 11
0
        public static void kick(ConsoleSystem.Arg arg)
        {
            BasePlayer player = arg.GetPlayer(0);

            if (!player || player.net == null || player.net.connection == null)
            {
                arg.ReplyWith("Player not found");
                return;
            }
            string str = arg.GetString(1, "no reason given");

            arg.ReplyWith(string.Concat("Kicked: ", player.displayName));
            Chat.Broadcast(string.Concat(new string[] { "Kicking ", player.displayName, " (", str, ")" }), "SERVER", "#eee", (ulong)0);
            player.Kick(string.Concat("Kicked: ", arg.GetString(1, "No Reason Given")));
        }
Esempio n. 12
0
        private void ConsoleReload(ConsoleSystem.Arg arg)
        {
            if (arg.argUser != null && !arg.argUser.admin)
            {
                return;
            }
            if (!IsAdmin(arg))
            {
                return;
            }
            if (!arg.HasArgs())
            {
                arg.ReplyWith("Usage: reload *|<pluginname>+");
                return;
            }

            if (arg.GetString(0).Equals("*"))
            {
                Interface.Oxide.ReloadAllPlugins();
                return;
            }

            foreach (var name in arg.Args)
            {
                if (!string.IsNullOrEmpty(name))
                {
                    Interface.Oxide.ReloadPlugin(name);
                }
            }
        }
Esempio n. 13
0
        private void GCConsoleCommand(ConsoleSystem.Arg arg)
        {
            if (!arg.IsRcon)
            {
                arg.ReplyWith(Lang("NoPermission"));
                return;
            }

            if (!arg.HasArgs())
            {
                arg.ReplyWith(Lang("InvalidSyntax"));
                return;
            }

            switch (arg.GetString(0).ToLower())
            {
            case "start":
                StartEvent(null, arg.Args.Skip(1).ToArray());
                break;

            case "stop":
                StopEvents(null);
                break;

            default:
                arg.ReplyWith(Lang("InvalidSyntax"));
                break;
            }
        }
Esempio n. 14
0
        public static void print_assets(ConsoleSystem.Arg arg)
        {
            if (AssetPool.storage.Count == 0)
            {
                arg.ReplyWith("Asset pool is empty.");
                return;
            }
            string    str       = arg.GetString(0, string.Empty);
            TextTable textTable = new TextTable();

            textTable.AddColumn("type");
            textTable.AddColumn("allocated");
            textTable.AddColumn("available");
            foreach (KeyValuePair <Type, AssetPool.Pool> keyValuePair in AssetPool.storage)
            {
                string str1 = keyValuePair.Key.ToString();
                string str2 = keyValuePair.Value.allocated.ToString();
                string str3 = keyValuePair.Value.available.ToString();
                if (!string.IsNullOrEmpty(str) && !str1.Contains(str, CompareOptions.IgnoreCase))
                {
                    continue;
                }
                textTable.AddRow(new string[] { str1, str2, str3 });
            }
            arg.ReplyWith(textTable.ToString());
        }
Esempio n. 15
0
        public static void export_prefabs(ConsoleSystem.Arg arg)
        {
            PrefabPoolCollection prefabPoolCollection = GameManager.server.pool;

            if (prefabPoolCollection.storage.Count == 0)
            {
                arg.ReplyWith("Prefab pool is empty.");
                return;
            }
            string        str           = arg.GetString(0, string.Empty);
            StringBuilder stringBuilder = new StringBuilder();

            foreach (KeyValuePair <uint, PrefabPool> keyValuePair in prefabPoolCollection.storage)
            {
                string str1 = keyValuePair.Key.ToString();
                string str2 = StringPool.Get(keyValuePair.Key);
                string str3 = keyValuePair.Value.Count.ToString();
                if (!string.IsNullOrEmpty(str) && !str2.Contains(str, CompareOptions.IgnoreCase))
                {
                    continue;
                }
                stringBuilder.AppendLine(string.Format("{0},{1},{2}", str1, Path.GetFileNameWithoutExtension(str2), str3));
            }
            File.WriteAllText("prefabs.csv", stringBuilder.ToString());
        }
Esempio n. 16
0
        public static void print_prefabs(ConsoleSystem.Arg arg)
        {
            PrefabPoolCollection prefabPoolCollection = GameManager.server.pool;

            if (prefabPoolCollection.storage.Count == 0)
            {
                arg.ReplyWith("Prefab pool is empty.");
                return;
            }
            string    str       = arg.GetString(0, string.Empty);
            TextTable textTable = new TextTable();

            textTable.AddColumn("id");
            textTable.AddColumn("name");
            textTable.AddColumn("count");
            foreach (KeyValuePair <uint, PrefabPool> keyValuePair in prefabPoolCollection.storage)
            {
                string str1 = keyValuePair.Key.ToString();
                string str2 = StringPool.Get(keyValuePair.Key);
                string str3 = keyValuePair.Value.Count.ToString();
                if (!string.IsNullOrEmpty(str) && !str2.Contains(str, CompareOptions.IgnoreCase))
                {
                    continue;
                }
                textTable.AddRow(new string[] { str1, Path.GetFileNameWithoutExtension(str2), str3 });
            }
            arg.ReplyWith(textTable.ToString());
        }
Esempio n. 17
0
        public static void kick(ConsoleSystem.Arg arg)
        {
            BasePlayer player = arg.GetPlayer(0);

            if (!Object.op_Implicit((Object)player) || player.net == null || player.net.get_connection() == null)
            {
                arg.ReplyWith("Player not found");
            }
            else
            {
                string str = arg.GetString(1, "no reason given");
                arg.ReplyWith("Kicked: " + player.displayName);
                Chat.Broadcast("Kicking " + player.displayName + " (" + str + ")", "SERVER", "#eee", 0UL);
                player.Kick("Kicked: " + arg.GetString(1, "No Reason Given"));
            }
        }
Esempio n. 18
0
        bool?OnPlayerChat(ConsoleSystem.Arg arg)
        {
            var player = arg.Player();

            if (player == null || arg.Args.Length == 0)
            {
                return(null);
            }

            if (mutes.ContainsKey(player.userID))
            {
                SendReply(player, $"Chat blocked!!! {mutes[player.userID]}sec.");
                return(false);
            }

            var message = arg.GetString(0);

            foreach (var word in badWordsList)
            {
                if (message.Contains(word))
                {
                    Mute(player);
                    return(false);
                }
            }
            return(null);
        }
Esempio n. 19
0
        private void cmdUnload(ConsoleSystem.Arg arg)
        {
            // Check arg 1 exists
            if (!arg.HasArgs(1))
            {
                arg.ReplyWith("Syntax: oxide.unload <pluginname>");
                return;
            }

            // Get the plugin name
            string name = arg.GetString(0);

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            // Unload
            if (!Interface.GetMod().UnloadPlugin(name))
            {
                arg.ReplyWith(string.Format("Plugin '{0}' not found!", name));
            }
            else
            {
                arg.ReplyWith(string.Format("Plugin '{0}' unloaded.", name));
            }
        }
Esempio n. 20
0
        private void ItemRemove(ConsoleSystem.Arg arg)
        {
            var userId = arg.Connection?.userid.ToString();

            if (string.IsNullOrEmpty(userId))
            {
                userId = "0";
            }
            if (arg.Connection != null && arg.Connection.authLevel < 2)
            {
                arg.ReplyWith(lang.GetMessage("Permission", this, userId));
                return;
            }
            var itemName = arg.GetString(0);

            if (!string.IsNullOrEmpty(itemName))
            {
                var createdItem = ItemManager.CreateByPartialName(itemName);
                if (createdItem != null)
                {
                    arg.ReplyWith(string.Format(lang.GetMessage("ItemRemove", this, userId), createdItem.info.displayName.english));
                    ServerMgr.Instance.StartCoroutine(Delete(BaseNetworkable.serverEntities, userId, item: createdItem));
                    return;
                }
                arg.ReplyWith(string.Format(lang.GetMessage("NoItem", this, userId), itemName));
                return;
            }
            arg.ReplyWith(lang.GetMessage("InvalidArgs", this, userId));
        }
Esempio n. 21
0
        private void CmdLoad(ConsoleSystem.Arg arg)
        {
            if (!IsAdmin(arg))
            {
                return;
            }
            if (!arg.HasArgs())
            {
                arg.ReplyWith("Usage: load *|<pluginname>+");
                return;
            }

            if (arg.GetString(0).Equals("*"))
            {
                Interface.Oxide.LoadAllPlugins();
                return;
            }

            foreach (var name in arg.Args)
            {
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }
                Interface.Oxide.LoadPlugin(name);
                pluginmanager.GetPlugin(name);
            }
        }
Esempio n. 22
0
        private void CmdUnload(ConsoleSystem.Arg arg)
        {
            if (!IsAdmin(arg))
            {
                return;
            }
            if (!arg.HasArgs())
            {
                arg.ReplyWith("Syntax: unload *|<pluginname>+");
                return;
            }

            if (arg.GetString(0).Equals("*"))
            {
                Interface.Oxide.UnloadAllPlugins();
                return;
            }

            foreach (var name in arg.Args)
            {
                if (!string.IsNullOrEmpty(name))
                {
                    Interface.Oxide.UnloadPlugin(name);
                }
            }
        }
Esempio n. 23
0
        public static void ban(ConsoleSystem.Arg arg)
        {
            BasePlayer player = arg.GetPlayer(0);

            if (!Object.op_Implicit((Object)player) || player.net == null || player.net.get_connection() == null)
            {
                arg.ReplyWith("Player not found");
            }
            else
            {
                ServerUsers.User user = ServerUsers.Get(player.userID);
                if (user != null && user.group == ServerUsers.UserGroup.Banned)
                {
                    arg.ReplyWith("User " + (object)player.userID + " is already banned");
                }
                else
                {
                    string notes = arg.GetString(1, "No Reason Given");
                    ServerUsers.Set(player.userID, ServerUsers.UserGroup.Banned, player.displayName, notes);
                    string str = "";
                    if (player.IsConnected && player.net.get_connection().ownerid != player.net.get_connection().userid)
                    {
                        str = str + " and also banned ownerid " + (object)(ulong)player.net.get_connection().ownerid;
                        ServerUsers.Set((ulong)player.net.get_connection().ownerid, ServerUsers.UserGroup.Banned, player.displayName, arg.GetString(1, "Family share owner of " + (object)(ulong)player.net.get_connection().userid));
                    }
                    ServerUsers.Save();
                    arg.ReplyWith("Kickbanned User: "******" - " + player.displayName + str);
                    Chat.Broadcast("Kickbanning " + player.displayName + " (" + notes + ")", "SERVER", "#eee", 0UL);
                    ((Server)Net.sv).Kick(player.net.get_connection(), "Banned: " + notes);
                }
            }
        }
Esempio n. 24
0
 public static void kickall(ConsoleSystem.Arg arg)
 {
     foreach (BasePlayer basePlayer in BasePlayer.activePlayerList.ToArray())
     {
         basePlayer.Kick("Kicked: " + arg.GetString(1, "No Reason Given"));
     }
 }
        private object OnPlayerChat(ConsoleSystem.Arg arg)
        {
            if (UseTB)
            {
                if (configData.Options.UsePluginChatControl)
                {
                    BasePlayer player  = (BasePlayer)arg.Connection.player;
                    string     message = arg.GetString(0, "text");
                    string     color   = configData.Spectators.Chat_Color + configData.Spectators.Chat_Prefix;
                    if (player.GetComponent <TBPlayer>())
                    {
                        switch (player.GetComponent <TBPlayer>().team)
                        {
                        case Team.A:
                            color = configData.TeamA.Chat_Color + configData.TeamA.Chat_Prefix;
                            break;

                        case Team.B:
                            color = configData.TeamB.Chat_Color + configData.TeamB.Chat_Prefix;
                            break;

                        case Team.ADMIN:
                            color = configData.Admin.Chat_Color + configData.Admin.Chat_Prefix;
                            break;
                        }
                    }
                    string formatMsg = $"{color} {player.displayName}</color> : {message}";
                    PrintToChat(formatMsg);
                    return(false);
                }
            }
            return(null);
        }
Esempio n. 26
0
        object OnPlayerChat(ConsoleSystem.Arg arg)
        {
            if (!_config.Enabled)
            {
                return(null);
            }

            var player = (BasePlayer)arg.Connection.player;

            if (!player || !HasPermission(player.UserIDString, PermUse) || !isActive(player.userID))
            {
                return(null);
            }

            var cmd = chatUser[player.userID];

            if (cmd == "g")
            {
                return(null);
            }

            var message = arg.GetString(0, "text");

            rust.RunClientCommand(player, "chat.say", $"/{cmd} {message}");

            if (BC)
            {
                return(null);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 27
0
        object OnPlayerChat(ConsoleSystem.Arg arg)
        {
            string hidden = "";

            for (int i = 0; i < Convert.ToString(Config["PASSWORD"]).Length; i++)
            {
                hidden += "*";
            }
            string original = arg.GetString(0, "text");
            string replaced = original.Replace(Convert.ToString(Config["PASSWORD"]), hidden);

            BasePlayer player = arg.connection.player as BasePlayer;

            Request request = requests.Find(element => element.m_steamID == player.UserIDString);

            if (!request.m_authenticated && Convert.ToBoolean(Config["PREVENT_CHAT"]))
            {
                write(player, "You cannot chat before authentication.");
                return(false);
            }

            if (original != replaced && Convert.ToBoolean(Config["PREVENT_CHAT_PASSWORD"]))
            {
                rust.BroadcastChat("<color=#5af>" + player.displayName + "</color>", replaced, player.UserIDString);
                return(false);
            }

            return(null);
        }
Esempio n. 28
0
        object OnPlayerChat(ConsoleSystem.Arg arg)
        {
            BasePlayer player  = (BasePlayer)arg.connection.player;
            string     message = arg.GetString(0, "text");

            if (stickies.Any(x => x.Key.userID == player.userID && x.Value.type == ChatType.CLAN))
            {
                clanLib.Call("cmdChatClanchat", player, "", new string[] { message });
                return(false);
            }
            else if (stickies.Any(x => x.Key.userID == player.userID && x.Value.type == ChatType.REPLY))
            {
                pmLib.Call("cmdPmReply", player, "", new string[] { message });
                return(false);
            }
            else if (stickies.Any(x => x.Key.userID == player.userID && x.Value.type == ChatType.PRIVATE))
            {
                StickyInfo result = (from el in stickies
                                     where el.Key.userID == player.userID && el.Value.type == ChatType.PRIVATE
                                     select el.Value).First();
                pmLib.Call("cmdPm", player, "", new string[] { result.details, message });
                return(false);
            }

            return(null);
        }
Esempio n. 29
0
        private object IOnPlayerChat(ConsoleSystem.Arg arg)
        {
            // Get the full chat string
            string str = arg.GetString(0).Trim();

            if (string.IsNullOrEmpty(str))
            {
                return(true);
            }

            // Get player objects
            BasePlayer player  = arg.Connection.player as BasePlayer;
            IPlayer    iplayer = player?.IPlayer;

            if (iplayer == null)
            {
                return(null);
            }

            // Call game and covalence hooks
            object chatSpecific  = Interface.CallHook("OnPlayerChat", arg);
            object chatCovalence = Interface.CallHook("OnUserChat", iplayer, str);

            return(chatSpecific ?? chatCovalence); // TODO: Fix 'RustCore' hook conflict when both return
        }
Esempio n. 30
0
        private object OnRunCommand(ConsoleSystem.Arg arg, bool wantreply)
        {
            // Sanity checks
            if (arg == null)
            {
                return(null);
            }

            string cmd = $"{arg.Class}.{arg.Function}";

            // Is it chat.say?
            if (cmd == "chat.say")
            {
                // Get the args
                var str = arg.GetString(0);
                if (str.Length == 0)
                {
                    return(true);
                }

                // Get covalence player
                var iplayer = covalence.PlayerManager.GetPlayer(arg.argUser.userID.ToString());

                // Is it a chat command?
                if (str[0] != '/' && str[0] != '!')
                {
                    return(Interface.CallHook("OnPlayerChat", arg.argUser, str) ?? Interface.CallHook("OnUserChat", iplayer, str));
                }

                // Get the arg string
                var argstr = str.Substring(1);
                if (str.Length == 1)
                {
                    return(true);
                }

                // Parse it
                string   chatcmd;
                string[] args;
                ParseChatCommand(argstr, out chatcmd, out args);
                if (chatcmd == null)
                {
                    return(null);
                }

                // Handle it
                var ply = arg.argUser;
                if (ply != null && !cmdlib.HandleChatCommand(ply, chatcmd, args))
                {
                    ConsoleNetworker.SendClientCommand(ply.networkPlayer, $"chat.add \"Server\" \" Unknown command {chatcmd}\"");
                    return(true);
                }

                // Handled
                arg.ReplyWith(string.Empty);
                return(true);
            }

            return(cmdlib.HandleConsoleCommand(arg, wantreply));
        }