Пример #1
0
 public static void connect(ref ConsoleSystem.Arg arg)
 {
     if (UnityEngine.Object.FindObjectOfType(typeof(ClientConnect)))
     {
         Debug.Log("Connect already in progress!");
         return;
     }
     if (NetCull.isClientRunning)
     {
         Debug.Log("Use net.disconnect before trying to connect to a new server.");
         return;
     }
     string[] strArrays = arg.GetString(0, string.Empty).Split(new char[] { ':' });
     if ((int)strArrays.Length != 2)
     {
         Debug.Log("Not a valid ip - or port missing");
         return;
     }
     string str = strArrays[0];
     int num = int.Parse(strArrays[1]);
     Debug.Log(string.Concat(new object[] { "Connecting to ", str, ":", num }));
     PlayerPrefs.SetString("net.lasturl", arg.GetString(0, string.Empty));
     if (!ClientConnect.Instance().DoConnect(str, num))
     {
         return;
     }
     LoadingScreen.Show();
     LoadingScreen.Update("connecting..");
 }
Пример #2
0
 public static void popup(ref ConsoleSystem.Arg arg)
 {
     float num = arg.GetFloat(0, 2f);
     string str = arg.GetString(1, "!");
     string str1 = arg.GetString(2, "This is the text");
     PopupUI.singleton.CreateNotice(num, str, str1);
 }
Пример #3
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);
 }
Пример #4
0
 private static string[] ExtractArgs(ConsoleSystem.Arg arg)
 {
     if (arg == null) return new string[0];
     var argsList = new List<string>();
     var i = 0;
     while (arg.HasArgs(++i)) argsList.Add(arg.GetString(i - 1));
     return argsList.ToArray();
 }
Пример #5
0
    public static void handleCommand(ref ConsoleSystem.Arg arg)
    {
        string name = arg.argUser.user.Displayname;
        string command = arg.GetString(0, "text").Trim();
        uLink.NetworkPlayer player = arg.argUser.networkPlayer;
        Debug.Log((object) ("[HANDLE COMMAND:] " + name + " " + command));
        string[] tmp = command.Split (' ');
        command = tmp [0].Trim ();
        for (int i=3; i < tmp.Length; i++)
            tmp [2] += " " + tmp [i];
        switch (command) {

            case "/share":
                share (ref arg, ref tmp);
                break;

            case "/unshare":
                unshare (ref arg, ref tmp);
                break;

            case "/pm":
                pm (ref arg, ref tmp);
                break;

            case "/ping":
                ping (ref arg);
                break;

            case "/help":
                help (ref arg);
                break;

            case "/location":
                location (ref arg);
                break;

            case "/history":
                history (ref arg);
                break;

            case "/players":
                players (ref arg);
                break;

            case "/starter":
                starter (ref arg);
                break;

            default:
                API.sayUser (player, "Invalid Command! type /help for a list of commmands");
                break;
        }
    }
Пример #6
0
 public static void handleCommand(ConsoleSystem.Arg arg)
 {
     string displayname = arg.argUser.user.Displayname;
     string[] strArray = arg.GetString(0, "text").Trim().Split(new char[] { ' ' });
     string cmd = strArray[0].Trim();
     string[] chatArgs = new string[strArray.Length - 1];
     for (int i = 1; i < strArray.Length; i++)
     {
         chatArgs[i - 1] = strArray[i];
     }
     ChatCommand.CallCommand(cmd, arg, chatArgs);
 }
Пример #7
0
    public static void handleCommand(ref ConsoleSystem.Arg arg)
    {
        uLink.NetworkPlayer player = arg.argUser.networkPlayer;
        string name = arg.argUser.user.Displayname;
        string command = arg.GetString(0, "text").Trim();
        string full = command;
        string[] tmp = command.Split (' ');
        command = tmp [0].Trim ();
        string[] args = new string[tmp.Length - 1];

        switch (command) {

            case "/share":
                share (ref arg, ref args);
                break;

            case "/unshare":
                unshare (ref arg, ref args);
                break;

            case "/pm":
                pm (ref arg, ref args);
                break;

            case "/ping":
                ping (ref arg);
                break;

            case "/help":
                help (ref arg);
                break;

            case "/location":
                location (ref arg);
                break;

            case "/history":
                history (ref arg);
                break;

            case "/players":
                players (ref arg);
                break;

            case "/starter":
                starter (ref arg);
                break;

            default:
                API.sayUser (player, "Invalid Command! type /help for a list of commmands");
                break;
        }
    }
Пример #8
0
    public static void say(ref ConsoleSystem.Arg arg)
    {
        if (!chat.enabled)
            return;
        string str1 = String.QuoteSafe(arg.argUser.user.Displayname);
        string str2 = String.QuoteSafe(arg.GetString(0, "text"));

        if(str2 != null && str2.Length > 1 && str2.Substring(1, 1).Equals("/")) {
            rustpp.handleCommand(ref arg);
        } else {

            if (chat.serverlog)
                Debug.Log((object) ("[YES HIJACKED CHAT:] " + str1 + ":" + str2));

            messages.Add (str2);
            users.Add (str1);
            ConsoleNetworker.Broadcast("chat.add " + str1 + " " + str2);
        }
    }
Пример #9
0
        private void cmdShow(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;
            if (!IsAdmin(arg)) return;
            if (!arg.HasArgs())
            {
                var reply = "Syntax: show <group|user> <name>\n";
                reply += "Syntax: show <groups|perms>";
                arg.ReplyWith(reply);
                return;
            }

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

            if (mode.Equals("perms"))
            {
                var result = "Permissions:\n";
                result += string.Join(", ", permission.GetPermissions());
                arg.ReplyWith(result);
            }
            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})";
                }
                var result = "User '" + name + "' permissions:\n";
                result += string.Join(", ", permission.GetUserPermissions(userId));
                result += "\nUser '" + name + "' groups:\n";
                result += string.Join(", ", permission.GetUserGroups(userId));
                arg.ReplyWith(result);
            }
            else if (mode.Equals("group"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                var result = "Group '" + name + "' users:\n";
                result += string.Join(", ", permission.GetUsersInGroup(name));
                result += "\nGroup '" + name + "' permissions:\n";
                result += string.Join(", ", permission.GetGroupPermissions(name));
                var parent = permission.GetGroupParent(name);
                while (permission.GroupExists(parent))
                {
                    result = "\nParent group '" + parent + "' permissions:\n";
                    result += string.Join(", ", permission.GetGroupPermissions(parent));
                    parent = permission.GetGroupParent(name);
                }
                arg.ReplyWith(result);
            }
            else if (mode.Equals("groups"))
            {
                var result = "Groups:\n";
                result += string.Join(", ", permission.GetGroups());
                arg.ReplyWith(result);
            }
        }
Пример #10
0
        private void cmdRevoke(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;
            if (!IsAdmin(arg)) return;
            if (!arg.HasArgs(3))
            {
                arg.ReplyWith("Usage: revoke <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.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);
                }
                permission.RevokeUserPermission(userId, perm);
                arg.ReplyWith("User '" + name + "' revoked permission: " + perm);
            }
        }
Пример #11
0
 public static void @add(ref ConsoleSystem.Arg arg)
 {
     FavouriteList.Add(arg.GetString(0, string.Empty));
 }
Пример #12
0
        private object OnRunCommand(ConsoleSystem.Arg arg)
        {
            if (arg?.cmd == null) return null;
            if (arg.cmd.namefull != "chat.say") return null;

            if (arg.connection != null)
            {
                if (arg.Player() == null) return true;
                var rustCovalence = Libraries.Covalence.RustCovalenceProvider.Instance;
                var livePlayer = rustCovalence.PlayerManager.GetOnlinePlayer(arg.connection.userid.ToString());
                if (rustCovalence.CommandSystem.HandleChatMessage(livePlayer, arg.GetString(0))) return true;
            }

            // Get the args
            var str = arg.GetString(0, "text");
            if (str.Length == 0) return null;

            // Is it a chat command?
            if (str[0] == '/' || str[0] == '!')
            {
                // Get the message
                var message = str.Substring(1);

                // Parse it
                string cmd;
                string[] args;
                ParseChatCommand(message, out cmd, out args);
                if (cmd == null) return null;

                // Handle it
                var player = arg.connection.player as BasePlayer;
                if (player == null)
                    Interface.Oxide.LogDebug("Player is actually a {0}!", arg.connection.player.GetType());
                else
                    if (!cmdlib.HandleChatCommand(player, cmd, args)) ReplyWith(player.net.connection, "UnknownCommand", cmd);

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

            // Default behavior
            return null;
        }
Пример #13
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);
            }
        }
Пример #14
0
        private void CmdGroup(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;
            if (!IsAdmin(arg)) return;
            if (!arg.HasArgs(2))
            {
                ReplyWith(arg.connection, "CommandUsageGroup");
                return;
            }

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

            if (mode.Equals("add"))
            {
                if (permission.GroupExists(name))
                {
                    ReplyWith(arg.connection, "GroupAlreadyExists", name);
                    return;
                }
                permission.CreateGroup(name, arg.GetString(2), arg.GetInt(3));
                ReplyWith(arg.connection, "GroupCreated", name);
            }
            else if (mode.Equals("remove"))
            {
                if (!permission.GroupExists(name))
                {
                    ReplyWith(arg.connection, "GroupNotFound", name);
                    return;
                }
                permission.RemoveGroup(name);
                ReplyWith(arg.connection, "GroupDeleted", name);
            }
            else if (mode.Equals("set"))
            {
                if (!permission.GroupExists(name))
                {
                    ReplyWith(arg.connection, "GroupNotFound", name);
                    return;
                }
                permission.SetGroupTitle(name, arg.GetString(2));
                permission.SetGroupRank(name, arg.GetInt(3));
                ReplyWith(arg.connection, "GroupChanged", name);
            }
            else if (mode.Equals("parent"))
            {
                if (!permission.GroupExists(name))
                {
                    ReplyWith(arg.connection, "GroupNotFound", name);
                    return;
                }
                var parent = arg.GetString(2);
                if (!string.IsNullOrEmpty(parent) && !permission.GroupExists(parent))
                {
                    ReplyWith(arg.connection, "GroupParentNotFound", parent);
                    return;
                }
                if (permission.SetGroupParent(name, parent))
                    ReplyWith(arg.connection, "GroupParentChanged", name, parent);
                else
                    ReplyWith(arg.connection, "GroupParentNotChanged", name);
            }
        }
Пример #15
0
        private void CmdUnload(ConsoleSystem.Arg arg)
        {
            if (!IsAdmin(arg)) return;
            if (!arg.HasArgs())
            {
                ReplyWith(arg.connection, "CommandUsageUnload");
                return;
            }

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

            foreach (var name in arg.Args)
                if (!string.IsNullOrEmpty(name)) Interface.Oxide.UnloadPlugin(name);
        }
Пример #16
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;

                // Is it a chat command?
                if (str[0] == '/' || str[0] == '!')
                {
                    // 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 Interface.CallHook("OnPlayerChat", arg.argUser, str);
            }

            return cmdlib.HandleConsoleCommand(arg, wantreply);
        }
Пример #17
0
        private void cmdLoad(ConsoleSystem.Arg arg)
        {
            if (arg.argUser != null && !arg.argUser.admin) return;
            // Check arg 1 exists
            if (!arg.HasArgs())
            {
                arg.ReplyWith("Syntax: oxide.load *|<pluginname>+");
                return;
            }

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

            foreach (var name in arg.Args)
            {
                if (string.IsNullOrEmpty(name)) continue;
                // Load
                Interface.Oxide.LoadPlugin(name);
                pluginmanager.GetPlugin(name);
            }
        }
Пример #18
0
        private void cmdGroup(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;

            if (arg.argUser != null && !arg.argUser.CanAdmin()) return;
            // Check 2 args exists
            if (!arg.HasArgs(2))
            {
                arg.ReplyWith("Syntax: oxide.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");
            }
        }
Пример #19
0
        bool OnPlayerChat(ConsoleSystem.Arg arg)
        {
            BasePlayer player = (BasePlayer) arg.connection.player;
            string message = arg.GetString(0, "text");
            if((bool)Config["WordFilter", "Enabled"]) message = GetFilteredMesssage(message);
            string uid = player.userID.ToString();
            var ChatMute = plugins.Find("chatmute");

            if(message == "" || message == null) return false;

            if (message.Contains("<color=") || message.Contains("</color>") || message.Contains("<size=") || message.Contains("</size>") || message.Contains("<b>") || message.Contains("<\b>") || message.Contains("<i>") || message.Contains("</i>"))
            {
                if (!permission.UserHasPermission(uid, "betterchat.formatting"))
                {
                    SendChatMessage(player, "CHAT", "You may not use formatting tags!");
                    return false;
                }
            }

            if (ChatMute != null)
            {
                bool isMuted = (bool) ChatMute.Call("IsMuted", player);
                if (isMuted) return false;
            }

            Dictionary<string, string> playerData = GetPlayerFormatting(player);

            playerData["FormattedOutput"] = playerData["Formatting"];
            playerData["FormattedOutput"] = playerData["FormattedOutput"].Replace("{Rank}", playerData["GroupRank"]);
            playerData["FormattedOutput"] = playerData["FormattedOutput"].Replace("{Title}", "<color=" + playerData["TitleColor"] + ">" + playerData["Title"] + "</color>");
            playerData["FormattedOutput"] = playerData["FormattedOutput"].Replace("{TitleColor}", playerData["TitleColor"]);
            playerData["FormattedOutput"] = playerData["FormattedOutput"].Replace("{NameColor}", playerData["NameColor"]);
            playerData["FormattedOutput"] = playerData["FormattedOutput"].Replace("{TextColor}", playerData["TextColor"]);
            playerData["FormattedOutput"] = playerData["FormattedOutput"].Replace("{Name}", "<color=" + playerData["NameColor"] + ">" + player.displayName + "</color>");
            playerData["FormattedOutput"] = playerData["FormattedOutput"].Replace("{ID}", player.userID.ToString());
            playerData["FormattedOutput"] = playerData["FormattedOutput"].Replace("{Message}", "<color=" + playerData["TextColor"] + ">" + message + "</color>");

            playerData["ConsoleOutput"] = playerData["ConsoleFormatting"];
            playerData["ConsoleOutput"] = playerData["ConsoleOutput"].Replace("{Rank}", playerData["GroupRank"]);
            playerData["ConsoleOutput"] = playerData["ConsoleOutput"].Replace("{Title}", playerData["Title"]);
            playerData["ConsoleOutput"] = playerData["ConsoleOutput"].Replace("{TitleColor}", playerData["TitleColor"]);
            playerData["ConsoleOutput"] = playerData["ConsoleOutput"].Replace("{NameColor}", playerData["NameColor"]);
            playerData["ConsoleOutput"] = playerData["ConsoleOutput"].Replace("{TextColor}", playerData["TextColor"]);
            playerData["ConsoleOutput"] = playerData["ConsoleOutput"].Replace("{Name}", player.displayName);
            playerData["ConsoleOutput"] = playerData["ConsoleOutput"].Replace("{ID}", player.userID.ToString());
            playerData["ConsoleOutput"] = playerData["ConsoleOutput"].Replace("{Message}", message);

            ChatSay(playerData["FormattedOutput"], uid);
            Puts(playerData["ConsoleOutput"]);

            return false;
        }
Пример #20
0
        private void cmdGrant(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;

            if (arg.Player() != null && !arg.Player().IsAdmin()) return;
            // Check 3 args exists
            if (!arg.HasArgs(3))
            {
                arg.ReplyWith("Syntax: oxide.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.GetUserData(name).LastSeenNickname = name;
                }
                permission.GrantUserPermission(userId, perm, null);
                arg.ReplyWith("User '" + name + "' granted permission: " + perm);
            }
        }
Пример #21
0
        private void CmdLang(ConsoleSystem.Arg arg)
        {
            if (!IsAdmin(arg)) return;

            if (arg.HasArgs()) lang.SetServerLanguage(arg.GetString(0));
            ReplyWith(arg.connection, "ServerLanguage", lang.GetServerLanguage());
        }
Пример #22
0
        private void cmdGroup(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;

            if (arg.Player() != null && !arg.Player().IsAdmin()) return;
            // Check 2 args exists
            if (!arg.HasArgs(2))
            {
                var reply = "Syntax: oxide.group <add|set> <name> [title] [rank]\n";
                reply += "Syntax: oxide.group <remove|show> <name>\n";
                reply += "Syntax: oxide.group <parent> <name> <parentName>";
                arg.ReplyWith(reply);
                return;
            }

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

            if (mode.Equals("add"))
            {
                if (permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' already exist");
                    return;
                }
                permission.CreateGroup(name, arg.GetString(2), arg.GetInt(3));
                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, arg.GetString(2));
                permission.SetGroupRank(name, arg.GetInt(3));
                arg.ReplyWith("Group '" + name + "' changed");
            }
            else if (mode.Equals("parent"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                var parent = arg.GetString(2);
                if (!string.IsNullOrEmpty(parent) && !permission.GroupExists(parent))
                {
                    arg.ReplyWith("Parent group '" + parent + "' doesn't exist");
                    return;
                }
                if (permission.SetGroupParent(name, parent))
                    arg.ReplyWith("Group '" + name + "' changed");
                else
                    arg.ReplyWith("Group '" + name + "' failed to change");
            }
            else if (mode.Equals("show"))
            {
                if (!permission.GroupExists(name))
                {
                    arg.ReplyWith("Group '" + name + "' doesn't exist");
                    return;
                }
                var result = "Group '" + name + "' permissions:\n";
                result += string.Join(",", permission.GetGroupPermissions(name));
                arg.ReplyWith(result);
            }
        }
Пример #23
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);
            }
        }
Пример #24
0
        private void cmdUnload(ConsoleSystem.Arg arg)
        {
            if (arg.Player() != null && !arg.Player().IsAdmin()) return;
            // Check arg 1 exists
            if (!arg.HasArgs())
            {
                arg.ReplyWith("Syntax: oxide.unload *|<pluginname>+");
                return;
            }

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

            foreach (var name in arg.Args)
            {
                if (string.IsNullOrEmpty(name)) continue;

                // Unload
                Interface.Oxide.UnloadPlugin(name);
            }
        }
Пример #25
0
        private void CmdShow(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg)) return;
            if (!IsAdmin(arg)) return;
            if (!arg.HasArgs())
            {
                ReplyWith(arg.connection, "CommandUsageShow");
                return;
            }

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

            if (mode.Equals("perms"))
            {
                var result = "Permissions:\n";
                result += string.Join(", ", permission.GetPermissions());
                arg.ReplyWith(result);
            }
            else if (mode.Equals("user"))
            {
                var player = FindPlayer(name);
                if (player == null && !permission.UserExists(name))
                {
                    ReplyWith(arg.connection, "UserNotFound");
                    return;
                }
                var userId = name;
                if (player != null)
                {
                    userId = player.userID.ToString();
                    name = player.displayName;
                    permission.UpdateNickname(userId, name);
                    name += $" ({userId})";
                }
                var result = "User '" + name + "' permissions:\n";
                result += string.Join(", ", permission.GetUserPermissions(userId));
                result += "\nUser '" + name + "' groups:\n";
                result += string.Join(", ", permission.GetUserGroups(userId));
                arg.ReplyWith(result);
            }
            else if (mode.Equals("group"))
            {
                if (!permission.GroupExists(name))
                {
                    ReplyWith(arg.connection, "GroupNotFound", name);
                    return;
                }
                var result = "Group '" + name + "' users:\n";
                result += string.Join(", ", permission.GetUsersInGroup(name));
                result += "\nGroup '" + name + "' permissions:\n";
                result += string.Join(", ", permission.GetGroupPermissions(name));
                var parent = permission.GetGroupParent(name);
                while (permission.GroupExists(parent))
                {
                    result = "\nParent group '" + parent + "' permissions:\n";
                    result += string.Join(", ", permission.GetGroupPermissions(parent));
                    parent = permission.GetGroupParent(parent);
                }
                arg.ReplyWith(result);
            }
            else if (mode.Equals("groups"))
            {
                var result = "Groups:\n";
                result += string.Join(", ", permission.GetGroups());
                arg.ReplyWith(result);
            }
        }
Пример #26
0
        private void cmdReload(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);
        }
        private bool OnPlayerChat(ConsoleSystem.Arg arg)
        {
            var sb = new StringBuilder();
            BasePlayer player = (BasePlayer)arg.connection.player;
            var playerID = player.userID;
            string message = arg.GetString(0, "text");
            string color = (string)Config["DefaultChatColor"];   //Default name color is white
            if(playerTeam.ContainsKey(playerID))
            {
                switch (playerTeam[playerID])
                {
                    case Team.ONE:
                        color = (string)Config["TeamOneChatColor"];
                        break;
                    case Team.TWO:
                        color = (string)Config["TeamTwoChatColor"];
                        break;
                    default:
                        break;
                }
            }
            sb.Append("<color=" + color + ">");
            sb.Append(player.displayName);
            sb.Append("</color>: ");
            sb.Append(message);

            ChatSay(sb.ToString(), player.userID.ToString());
            return false;
        }
Пример #28
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");
            }
        }
Пример #29
0
 public static void @remove(ref ConsoleSystem.Arg arg)
 {
     string str = arg.GetString(0, string.Empty);
     FavouriteList.Remove(str);
 }
Пример #30
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);
            }

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

            if (mode.Equals("add"))
            {
                permission.AddUserGroup(userId, group);
                if (player != null)
                {
                    arg.ReplyWith("User '" + player.displayName + "' assigned group: " + @group);
                }
            }
            else if (mode.Equals("remove"))
            {
                permission.RemoveUserGroup(userId, group);
                if (player != null)
                {
                    arg.ReplyWith("User '" + player.displayName + "' removed from group: " + @group);
                }
            }
        }