Exemplo n.º 1
0
        private object OnServerCommand(ConsoleSystem.Arg arg)
        {
            var connection = arg.Connection;

            if (connection == null || string.IsNullOrEmpty(arg.cmd?.FullName))
            {
                return(null);
            }
            if (permission.UserHasPermission(connection.userid.ToString(), permBypass))
            {
                return(null);
            }
            if (!config.BlockedCommands.Contains(arg.cmd.Name) && !config.BlockedCommands.Contains(arg.cmd.FullName))
            {
                return(null);
            }

            arg.ReplyWith(Lang("CommandBlocked", connection.userid.ToString(), arg.cmd.FullName));
            if (config.LogAttempts)
            {
                LogWarning(Lang("CommandAttempted", connection.username, connection.userid, arg.cmd.FullName));
            }
            return(true);
        }
Exemplo n.º 2
0
        public static void debug_toggle(ConsoleSystem.Arg args)
        {
            int num = args.GetInt(0, 0);

            if (num == 0)
            {
                return;
            }
            BaseEntity baseEntity = BaseNetworkable.serverEntities.Find((uint)num) as BaseEntity;

            if (baseEntity == null)
            {
                return;
            }
            baseEntity.SetFlag(BaseEntity.Flags.Debugging, !baseEntity.IsDebugging(), false, true);
            if (baseEntity.IsDebugging())
            {
                baseEntity.OnDebugStart();
            }
            ConsoleSystem.Arg arg = args;
            object[]          d   = new object[] { "Debugging for ", baseEntity.net.ID, " ", null };
            d[3] = (baseEntity.IsDebugging() ? "enabled" : "disabled");
            arg.ReplyWith(string.Concat(d));
        }
Exemplo n.º 3
0
        private object OnRunCommand(ConsoleSystem.Arg arg, bool wantreply)
        {
            if (arg == null)
            {
                return(null);
            }

            var cmdFullName = $"{arg.Class}.{arg.Function}";
            var str         = arg.ArgsStr.Trim('"');
            var netUser     = arg.argUser;

            // Get the covalence player
            var iplayer = netUser != null?Covalence.PlayerManager.FindPlayerById(netUser.userID.ToString()) : null;

            // Is it a console command?
            if (cmdFullName != "chat.say")
            {
                if (Covalence.CommandSystem.HandleConsoleMessage(iplayer, $"{cmdFullName} {str}") || cmdlib.HandleConsoleCommand(arg, wantreply))
                {
                    return(true);
                }
                return(null);
            }

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

            // Is it a chat command?
            if (str[0] != '/')
            {
                var chatSpecific  = Interface.Call("OnPlayerChat", netUser, str);
                var chatCovalence = Interface.Call("OnUserChat", iplayer, str);
                return(chatSpecific ?? chatCovalence);
            }

            // Get the full command
            var command = str.Substring(1);

            // Parse it
            string cmd;

            string[] args;
            ParseCommand(command, out cmd, out args);
            if (cmd == null)
            {
                return(true);
            }

            // Get the covalence player
            if (iplayer == null)
            {
                return(null);
            }

            // Is the command blocked?
            var commandSpecific  = Interface.Call("OnPlayerCommand", arg);
            var commandCovalence = Interface.Call("OnUserCommand", iplayer, cmd, args); // TODO: Fix NRE from chat.say /x via console

            if (commandSpecific != null || commandCovalence != null)
            {
                return(true);
            }

            // Is this a Covalence command?
            if (Covalence.CommandSystem.HandleChatMessage(iplayer, str))
            {
                return(true);                                                         // TODO: Fix NRE from chat.say /x via console
            }
            // Is it a regular chat command?
            if (netUser == null)
            {
                Interface.Oxide.LogDebug("Player is actually a {netUser}!");
            }
            else if (!cmdlib.HandleChatCommand(netUser, cmd, args))
            {
                ConsoleNetworker.SendClientCommand(netUser.networkPlayer, $"chat.add \"Server\" \" Unknown command {cmd}\"");
            }

            // Handled
            arg.ReplyWith(string.Empty);
            return(true);
        }
Exemplo n.º 4
0
        private object IOnServerCommand(ConsoleSystem.Arg arg)
        {
            if (arg?.cmd == null)
            {
                return(null);
            }
            if (Interface.Call("OnServerCommand", arg) != null)
            {
                return(true);
            }

            // Get the args
            var str = arg.GetString(0);

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

            // Check if command is from a player
            var player = arg.Connection?.player as BasePlayer;

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

            // Get the full command
            var message = str.TrimStart('/');

            // Parse it
            string cmd;

            string[] args;
            ParseCommand(message, out cmd, out args);
            if (cmd == null)
            {
                return(null);
            }

            // Get the covalence player
            var iplayer = player.IPlayer;

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

            // Is the command blocked?
            var blockedSpecific  = Interface.Call("OnPlayerCommand", arg);
            var blockedCovalence = Interface.Call("OnUserCommand", iplayer, cmd, args);

            if (blockedSpecific != null || blockedCovalence != null)
            {
                return(true);
            }

            // Is it a chat command?
            if (arg.cmd.FullName != "chat.say")
            {
                return(null);
            }
            if (str[0] != '/')
            {
                return(null);               // TODO: Return if no arguments given
            }
            // Is it a valid chat command?
            if (!Covalence.CommandSystem.HandleChatMessage(iplayer, str) && !cmdlib.HandleChatCommand(player, cmd, args))
            {
                if (!Interface.Oxide.Config.Options.Modded)
                {
                    return(null);
                }

                iplayer.Reply(string.Format(lang.GetMessage("UnknownCommand", this, iplayer.Id), cmd));
                arg.ReplyWith(string.Empty);
                return(true);
            }

            return(null);
        }
Exemplo n.º 5
0
        private void ConsoleShow(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.UserIdValid(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"))
            {
                arg.ReplyWith("Groups:\n" + string.Join(", ", permission.GetGroups()));
            }
        }
Exemplo n.º 6
0
        private void ccmdEco(ConsoleSystem.Arg arg)
        {
            if (!arg.HasArgs())
            {
                arg.ReplyWith("Economy Commands: 'eco.c deposit', 'eco.c save','eco.c balance', 'eco.c withdraw', 'eco.c setmoney', 'eco.c wipe'");
                return;
            }
            var player = arg.Player();

            if (player != null && !HasAccess(player))
            {
                arg.ReplyWith("No permission!");
                return;
            }
            var cmdArg = arg.GetString(0).ToLower();

            switch (cmdArg)
            {
            case "save":
                changed = true;
                SaveEconomics();
                arg.ReplyWith("Economics data saved!");
                break;

            case "wipe":
                economicsData = new Dictionary <ulong, double>();
                changed       = true;
                SaveEconomics();
                arg.ReplyWith("Economics data wiped!");
                break;

            case "deposit":
            case "balance":
            case "withdraw":
            case "setmoney":
                var target = FindPlayer(arg.GetString(1));
                if (target == null)
                {
                    arg.ReplyWith($"No user with steam/name: '{arg.GetString(1)}'!");
                    return;
                }
                if (cmdArg.Equals("balance"))
                {
                    arg.ReplyWith($"Balance({target.displayName}) = {GetPlayerMoney(target.userID)}");
                    return;
                }
                double money = Convert.ToDouble(arg.GetString(2, "0"));
                if (money >= 0)
                {
                    if (cmdArg.Equals("setmoney"))
                    {
                        Set(target.userID, money);
                        arg.ReplyWith($"(SetMoney) New '{target.displayName}' balance: {GetPlayerMoney(target.userID)}");
                        PrintMessage(target, "My_Balance", GetPlayerMoney(target.userID));
                    }
                    else if (cmdArg.Equals("deposit"))
                    {
                        Deposit(target.userID, money);
                        arg.ReplyWith($"(Deposit) New '{target.displayName}' balance: {GetPlayerMoney(target.userID)}");
                        PrintMessage(target, "Received", money);
                    }
                    else if (Withdraw(target.userID, money))
                    {
                        arg.ReplyWith($"(Withdraw) New '{target.displayName}' balance: {GetPlayerMoney(target.userID)}");
                        PrintMessage(target, "Lost", money);
                    }
                    else
                    {
                        arg.ReplyWith("This user haven't enough money!");
                    }
                }
                else
                {
                    arg.ReplyWith($"Syntax Error! (eco.c {cmdArg} <steam/name> <money>)");
                }
                break;

            default:
                arg.ReplyWith("Economy Commands: 'eco.c deposit', 'eco.c save','eco.c balance', 'eco.c withdraw', 'eco.c setmoney'");
                break;
            }
        }
Exemplo n.º 7
0
        private void StackAllConsoleCommand(ConsoleSystem.Arg arg)
        {
            if (arg.IsAdmin != true)
            {
                if ((arg.Connection.userid.ToString() != null) && !(permission.UserHasPermission(arg.Connection.userid.ToString(), "stacksizecontroller.canChangeStackSize")))
                {
                    arg.ReplyWith("[StackSizeController] You don't have permission to use this command.");
                    return;
                }
            }

            if (!pluginLoaded)
            {
                arg.ReplyWith("[StackSizeController] StackSizeController has encountered an error while trying to read the data file. Please contact your server administrator to fix the issue.");
                return;
            }

            if (arg.Args != null)
            {
                if (arg.Args.Length < 1)
                {
                    arg.ReplyWith("[StackSizeController] Syntax Error: Requires 1 argument. Syntax Example: stackall 65000");
                    return;
                }
            }
            else
            {
                arg.ReplyWith("[StackSizeController] Syntax Error: Requires 1 argument. Syntax Example: stackall 65000");
                return;
            }

            int    stackAmount  = 0;
            string replymessage = "";

            var itemList = ItemManager.itemList;

            foreach (var gameitem in itemList)
            {
                if (gameitem.condition.enabled && gameitem.condition.max > 0 && (!(configData.Settings.StackHealthItems)))
                {
                    continue;
                }
                if (gameitem.displayName.english.ToString() == "Salt Water" ||
                    gameitem.displayName.english.ToString() == "Water")
                {
                    continue;
                }

                switch (arg.Args[0].ToLower())
                {
                case "default":
                {
                    stackAmount  = DetermineStack(gameitem);
                    replymessage = "[StackSizeController] The Stack Size of all stackable items has been set to their default values (specified in config).";
                    break;
                }

                default:
                {
                    if (int.TryParse(arg.Args[0], out stackAmount) == false)
                    {
                        arg.ReplyWith("[StackSizeController] Syntax Error: Stack Amount is not a number. Syntax Example: /stackall 65000");
                        return;
                    }
                    replymessage = "[StackSizeController] The Stack Size of all stackable items has been set to " + stackAmount.ToString() + ".";
                    break;
                }
                }

                items.itemlist[gameitem.displayName.english] = Convert.ToInt32(stackAmount);
                gameitem.stackable = Convert.ToInt32(stackAmount);
            }

            SaveData();

            arg.ReplyWith(replymessage);
        }
Exemplo n.º 8
0
        private void Hooks_OnConsoleReceived(ref ConsoleSystem.Arg arg, bool external1)
        {
            StringComparison ic          = StringComparison.InvariantCultureIgnoreCase;
            bool             external    = arg.argUser == null;
            bool             adminRights = (arg.argUser != null && arg.argUser.admin) || external;
            string           userid      = "[external][external]";

            if (adminRights && !external)
            {
                userid = string.Format("[{0}][{1}]", arg.argUser.displayName, arg.argUser.userID.ToString());
            }
            string text   = "";
            string text2  = text;
            string logmsg = string.Format("[ConsoleReceived] userid={0} adminRights={1} command={2}.{3} args={4}", userid, adminRights.ToString(), arg.Class, arg.Function, (arg.HasArgs(1) ? arg.ArgsStr : "none"));

            if (arg.Class.Equals("JianxianS", ic) && arg.Function.Equals("users", ic))
            {
                if (adminRights)
                {
                    if (arg.HasArgs(1))
                    {
                        arg.ReplyWith("您多输入了参数了");
                    }
                    else
                    {
                        int num = 0;

                        foreach (uLink.NetworkPlayer networkPlayer in NetCull.connections)
                        {
                            text2 = "[Player]||\n";
                            object localData = networkPlayer.GetLocalData();
                            if (localData is NetUser)
                            {
                                NetUser netUser = (NetUser)localData;
                                text = string.Concat(new object[]
                                {
                                    text2,
                                    netUser.networkPlayer.id,
                                    ":\"",
                                    netUser.displayName,
                                    "\"||\n"
                                });
                                num++;
                            }
                        }
                        text = text + num.ToString() + "users\n";
                        arg.ReplyWith(text);
                    }
                }
            }
            else if (arg.Class.Equals("JianxianS", ic) && arg.Function.Equals("kick", ic))
            {
                if (adminRights)
                {
                    if (arg.HasArgs(1))
                    {
                        global::PlayerClient[] playerClients = arg.GetPlayerClients(0);
                        foreach (global::PlayerClient playerClient in playerClients)
                        {
                            global::NetUser netUser = playerClient.netUser;
                            if (netUser != null)
                            {
                                netUser.Kick(global::NetError.Facepunch_Kick_RCON, true);
                            }
                        }
                        if (playerClients.Length > 0)
                        {
                            arg.ReplyWith("Kicked " + playerClients.Length + " users!");
                            return;
                        }
                        arg.ReplyWith("Couldn't find anyone!");
                    }
                    else
                    {
                        text = "您少输入参数了";
                        arg.ReplyWith(text);
                    }
                }
            }
            else if (arg.Class.Equals("JianxianS", ic) && arg.Function.Equals("money", ic))
            {
                if (adminRights)
                {
                    string[]         args    = arg.Args;
                    Fougerite.Player jogador = Fougerite.Player.FindByName(args[1]);
                    switch (args[0])
                    {
                    case "+qian":
                        if (jogador != null)
                        {
                            int valor = int.Parse(args[2]);
                            Money.AddMoney(jogador, valor);
                            Fougerite.Server.GetServer().Broadcast("[color#99CC]剑客[ " + jogador.Name + " ][color#FF6633] 充值了 [color#99FF]" + valor + " [color#FF6633]斩仙币  -  !尽情的享受购物吧!");
                            arg.ReplyWith("充值成功");
                        }
                        else
                        {
                            arg.ReplyWith("[color#99FF]剑客 " + args[0] + "查无此人!");
                        }
                        break;

                    case "zero":
                        if (jogador != null)
                        {
                            int valor = 0;
                            Money.SetMoney(jogador, valor);
                            arg.ReplyWith("[color#99FF]剑客: " + jogador.Name + " 斩仙币被系统归零!");
                        }
                        else
                        {
                            arg.ReplyWith("[color#99CC]剑客 " + args[0] + "查无此人!");
                        }
                        break;

                    case "-qian":
                        if (jogador != null)
                        {
                            int valor = int.Parse(args[2]);
                            Money.RemoveMoney(jogador, valor);
                            arg.ReplyWith("[color#99FF]剑客" + jogador.Name + "被系统扣除了  " + valor + "  斩仙币");
                        }
                        else
                        {
                            arg.ReplyWith("[color#99FF]剑客 " + args[0] + "沒找到哦");
                        }
                        break;
                    }
                }
            }
        }
Exemplo n.º 9
0
 public static void listid(ConsoleSystem.Arg arg)
 {
     arg.ReplyWith(ServerUsers.BanListString(true));
 }
Exemplo n.º 10
0
 public static void banlistex(ConsoleSystem.Arg arg)
 {
     arg.ReplyWith(ServerUsers.BanListStringEx());
 }
Exemplo n.º 11
0
        public static void status(ConsoleSystem.Arg arg)
        {
            string str1 = arg.GetString(0, "");
            string str2 = string.Empty;

            if (str1.Length == 0)
            {
                str2 = str2 + "hostname: " + Server.hostname + "\n" + "version : " + 2161.ToString() + " secure (secure mode enabled, connected to Steam3)\n" + "map     : " + Server.level + "\n" + "players : " + (object)BasePlayer.activePlayerList.Count <BasePlayer>() + " (" + (object)Server.maxplayers + " max) (" + (object)((ServerMgr)SingletonComponent <ServerMgr> .Instance).connectionQueue.Queued + " queued) (" + (object)((ServerMgr)SingletonComponent <ServerMgr> .Instance).connectionQueue.Joining + " joining)\n\n";
            }
            TextTable textTable = new TextTable();

            textTable.AddColumn("id");
            textTable.AddColumn("name");
            textTable.AddColumn("ping");
            textTable.AddColumn("connected");
            textTable.AddColumn("addr");
            textTable.AddColumn("owner");
            textTable.AddColumn("violation");
            textTable.AddColumn("kicks");
            foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
            {
                try
                {
                    if (activePlayer.IsValid())
                    {
                        string userIdString = activePlayer.UserIDString;
                        if (activePlayer.net.get_connection() == null)
                        {
                            textTable.AddRow(new string[2]
                            {
                                userIdString,
                                "NO CONNECTION"
                            });
                        }
                        else
                        {
                            // ISSUE: explicit non-virtual call
                            string str3 = __nonvirtual(activePlayer.net.get_connection().ownerid.ToString());
                            string str4 = StringExtensions.QuoteSafe(activePlayer.GetSubName(32));
                            string str5 = ((Server)Net.sv).GetAveragePing(activePlayer.net.get_connection()).ToString();
                            string str6 = (string)activePlayer.net.get_connection().ipaddress;
                            string str7 = activePlayer.violationLevel.ToString("0.0");
                            string str8 = activePlayer.GetAntiHackKicks().ToString();
                            if (!arg.get_IsAdmin() && !arg.get_IsRcon())
                            {
                                str6 = "xx.xxx.xx.xxx";
                            }
                            string str9 = activePlayer.net.get_connection().GetSecondsConnected().ToString() + "s";
                            if (str1.Length > 0 && !StringEx.Contains(str4, str1, CompareOptions.IgnoreCase) && (!userIdString.Contains(str1) && !str3.Contains(str1)))
                            {
                                if (!str6.Contains(str1))
                                {
                                    continue;
                                }
                            }
                            textTable.AddRow(new string[8]
                            {
                                userIdString,
                                str4,
                                str5,
                                str9,
                                str6,
                                str3 == userIdString ? string.Empty : str3,
                                str7,
                                str8
                            });
                        }
                    }
                }
                catch (Exception ex)
                {
                    textTable.AddRow(new string[2]
                    {
                        activePlayer.UserIDString,
                        StringExtensions.QuoteSafe(ex.Message)
                    });
                }
            }
            arg.ReplyWith(str2 + ((object)textTable).ToString());
        }
Exemplo n.º 12
0
        public static void stats(ConsoleSystem.Arg arg)
        {
            TextTable table = new TextTable();

            table.AddColumn("id");
            table.AddColumn("name");
            table.AddColumn("time");
            table.AddColumn("kills");
            table.AddColumn("deaths");
            table.AddColumn("suicides");
            table.AddColumn("player");
            table.AddColumn("building");
            table.AddColumn("entity");
            Action <ulong, string> action = (Action <ulong, string>)((id, name) =>
            {
                ServerStatistics.Storage storage = ServerStatistics.Get(id);
                string shortString = TimeSpan.FromSeconds((double)storage.Get("time")).ToShortString();
                string str1        = storage.Get("kill_player").ToString();
                string str2        = (storage.Get("deaths") - storage.Get("death_suicide")).ToString();
                string str3        = storage.Get("death_suicide").ToString();
                string str4        = storage.Get("hit_player_direct_los").ToString();
                string str5        = storage.Get("hit_player_indirect_los").ToString();
                string str6        = storage.Get("hit_building_direct_los").ToString();
                string str7        = storage.Get("hit_building_indirect_los").ToString();
                string str8        = storage.Get("hit_entity_direct_los").ToString();
                string str9        = storage.Get("hit_entity_indirect_los").ToString();
                table.AddRow(new string[9]
                {
                    id.ToString(),
                    name,
                    shortString,
                    str1,
                    str2,
                    str3,
                    str4 + " / " + str5,
                    str6 + " / " + str7,
                    str8 + " / " + str9
                });
            });
            ulong filterID = arg.GetUInt64(0, 0UL);

            if (filterID == 0UL)
            {
                string str1 = arg.GetString(0, "");
                foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
                {
                    try
                    {
                        if (activePlayer.IsValid())
                        {
                            string str2 = StringExtensions.QuoteSafe(activePlayer.GetSubName(32));
                            if (str1.Length > 0)
                            {
                                if (!StringEx.Contains(str2, str1, CompareOptions.IgnoreCase))
                                {
                                    continue;
                                }
                            }
                            action(activePlayer.userID, str2);
                        }
                    }
                    catch (Exception ex)
                    {
                        table.AddRow(new string[2]
                        {
                            activePlayer.UserIDString,
                            StringExtensions.QuoteSafe(ex.Message)
                        });
                    }
                }
            }
            else
            {
                string     str        = "N/A";
                BasePlayer basePlayer = BasePlayer.activePlayerList.Find((Predicate <BasePlayer>)(p => (long)p.userID == (long)filterID));
                if (Object.op_Implicit((Object)basePlayer))
                {
                    str = StringExtensions.QuoteSafe(basePlayer.GetSubName(32));
                }
                action(filterID, str);
            }
            arg.ReplyWith(((object)table).ToString());
        }
Exemplo n.º 13
0
 public static void sysuid(ConsoleSystem.Arg arg)
 {
     arg.ReplyWith(SystemInfo.get_deviceUniqueIdentifier());
 }
Exemplo n.º 14
0
 public static void sysinfo(ConsoleSystem.Arg arg)
 {
     arg.ReplyWith(SystemInfoGeneralText.currentInfo);
 }
Exemplo n.º 15
0
 public static void version(ConsoleSystem.Arg arg)
 {
     arg.ReplyWith(string.Format("Protocol: {0}\nBuild Date: {1}\nUnity Version: {2}\nChangeset: {3}\nBranch: {4}", (object)Protocol.printable, (object)BuildInfo.get_Current().get_BuildDate(), (object)Application.get_unityVersion(), (object)BuildInfo.get_Current().get_Scm().get_ChangeId(), (object)BuildInfo.get_Current().get_Scm().get_Branch()));
 }
Exemplo n.º 16
0
    public static void find(ref ConsoleSystem.Arg arg)
    {
        string str;

        if (!arg.HasArgs(1))
        {
            return;
        }
        string args  = arg.Args[0];
        string empty = string.Empty;

        Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
        for (int i = 0; i < (int)assemblies.Length; i++)
        {
            Type[] types = assemblies[i].GetTypes();
            for (int j = 0; j < (int)types.Length; j++)
            {
                if (types[j].IsSubclassOf(typeof(ConsoleSystem)))
                {
                    MethodInfo[] methods = types[j].GetMethods();
                    for (int k = 0; k < (int)methods.Length; k++)
                    {
                        if (methods[k].IsStatic)
                        {
                            if (!(args != "*") || types[j].Name.Contains(args) || methods[k].Name.Contains(args))
                            {
                                if (arg.CheckPermissions(methods[k].GetCustomAttributes(true)))
                                {
                                    str   = empty;
                                    empty = string.Concat(new string[] { str, types[j].Name, ".", global.BuildMethodString(ref methods[k]), "\n" });
                                }
                            }
                        }
                    }
                    FieldInfo[] fields = types[j].GetFields();
                    for (int l = 0; l < (int)fields.Length; l++)
                    {
                        if (fields[l].IsStatic)
                        {
                            if (!(args != "*") || types[j].Name.Contains(args) || fields[l].Name.Contains(args))
                            {
                                if (arg.CheckPermissions(fields[l].GetCustomAttributes(true)))
                                {
                                    str   = empty;
                                    empty = string.Concat(new string[] { str, types[j].Name, ".", global.BuildFieldsString(ref fields[l]), "\n" });
                                }
                            }
                        }
                    }
                    PropertyInfo[] properties = types[j].GetProperties();
                    for (int m = 0; m < (int)properties.Length; m++)
                    {
                        if (!(args != "*") || types[j].Name.Contains(args) || properties[m].Name.Contains(args))
                        {
                            if (arg.CheckPermissions(properties[m].GetCustomAttributes(true)))
                            {
                                str   = empty;
                                empty = string.Concat(new string[] { str, types[j].Name, ".", global.BuildPropertyString(ref properties[m]), "\n" });
                            }
                        }
                    }
                }
            }
        }
        arg.ReplyWith(string.Concat("Finding ", args, ":\n", empty));
    }
Exemplo n.º 17
0
        private void GatherRate(ConsoleSystem.Arg arg)
        {
            if (arg.Player() != null && !arg.Player().IsAdmin)
            {
                arg.ReplyWith(NotAllowed);
                return;
            }

            var subcommand = arg.GetString(0).ToLower();

            if (!arg.HasArgs(3) || !subcommands.Contains(subcommand))
            {
                arg.ReplyWith(InvalidArgumentsGather);
                return;
            }

            if (!validResources[arg.GetString(1).ToLower()] && arg.GetString(1) != "*")
            {
                arg.ReplyWith(string.Format(InvalidResource, arg.GetString(1)));
                return;
            }

            var resource = validResources[arg.GetString(1).ToLower()]?.displayName.english ?? "*";
            var modifier = arg.GetFloat(2, -1);
            var remove   = false;

            if (modifier < 0)
            {
                if (arg.GetString(2).ToLower() == "remove")
                {
                    remove = true;
                }
                else
                {
                    arg.ReplyWith(InvalidModifier);
                    return;
                }
            }

            switch (subcommand)
            {
            case "dispenser":
                if (remove)
                {
                    if (GatherResourceModifiers.ContainsKey(resource))
                    {
                        GatherResourceModifiers.Remove(resource);
                    }
                    arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Dispensers));
                }
                else
                {
                    if (GatherResourceModifiers.ContainsKey(resource))
                    {
                        GatherResourceModifiers[resource] = modifier;
                    }
                    else
                    {
                        GatherResourceModifiers.Add(resource, modifier);
                    }
                    arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Dispensers));
                }
                SetConfigValue("Options", "GatherResourceModifiers", GatherResourceModifiers);
                break;

            case "pickup":
                if (remove)
                {
                    if (PickupResourceModifiers.ContainsKey(resource))
                    {
                        PickupResourceModifiers.Remove(resource);
                    }
                    arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Pickups));
                }
                else
                {
                    if (PickupResourceModifiers.ContainsKey(resource))
                    {
                        PickupResourceModifiers[resource] = modifier;
                    }
                    else
                    {
                        PickupResourceModifiers.Add(resource, modifier);
                    }
                    arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Pickups));
                }
                SetConfigValue("Options", "PickupResourceModifiers", PickupResourceModifiers);
                break;

            case "quarry":
                if (remove)
                {
                    if (QuarryResourceModifiers.ContainsKey(resource))
                    {
                        QuarryResourceModifiers.Remove(resource);
                    }
                    arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Quarries));
                }
                else
                {
                    if (QuarryResourceModifiers.ContainsKey(resource))
                    {
                        QuarryResourceModifiers[resource] = modifier;
                    }
                    else
                    {
                        QuarryResourceModifiers.Add(resource, modifier);
                    }
                    arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Quarries));
                }
                SetConfigValue("Options", "QuarryResourceModifiers", QuarryResourceModifiers);
                break;

            case "excavator":
                if (remove)
                {
                    if (ExcavatorResourceModifiers.ContainsKey(resource))
                    {
                        ExcavatorResourceModifiers.Remove(resource);
                    }
                    arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Excavators));
                }
                else
                {
                    if (ExcavatorResourceModifiers.ContainsKey(resource))
                    {
                        ExcavatorResourceModifiers[resource] = modifier;
                    }
                    else
                    {
                        ExcavatorResourceModifiers.Add(resource, modifier);
                    }
                    arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Excavators));
                }
                SetConfigValue("Options", "ExcavatorResourceModifiers", ExcavatorResourceModifiers);
                break;

            case "survey":
                if (remove)
                {
                    if (SurveyResourceModifiers.ContainsKey(resource))
                    {
                        SurveyResourceModifiers.Remove(resource);
                    }
                    arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Charges));
                }
                else
                {
                    if (SurveyResourceModifiers.ContainsKey(resource))
                    {
                        SurveyResourceModifiers[resource] = modifier;
                    }
                    else
                    {
                        SurveyResourceModifiers.Add(resource, modifier);
                    }
                    arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Charges));
                }
                SetConfigValue("Options", "SurveyResourceModifiers", SurveyResourceModifiers);
                break;
            }
        }
Exemplo n.º 18
0
        private object OnServerCommand(ConsoleSystem.Arg arg)
        {
            if (arg?.cmd == null)
            {
                return(null);
            }

            try
            {
                // Get the args
                var str = arg.GetString(0);
                if (string.IsNullOrEmpty(str))
                {
                    return(null);
                }

                // Check if command is from a player
                var player = arg.Connection?.player as BasePlayer;
                if (player == null)
                {
                    return(null);
                }

                // Get the full command
                var message = str.TrimStart('/');

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

                // Get the covalence player
                var iplayer = Covalence.PlayerManager.FindPlayerById(arg.Connection.userid.ToString());
                if (iplayer == null)
                {
                    return(null);
                }

                // Is the command blocked?
                var blockedSpecific  = Interface.Call("OnPlayerCommand", arg);
                var blockedCovalence = Interface.Call("OnUserCommand", iplayer, cmd, args);
                if (blockedSpecific != null || blockedCovalence != null)
                {
                    return(true);
                }

                // Is it a chat command?
                if (arg.cmd.FullName != "chat.say")
                {
                    return(null);
                }
                if (str[0] != '/')
                {
                    return(null);               // TODO: Return if no arguments given
                }
                // Disable chat commands for non-admins if the server is not set to modded
                if (!Interface.Oxide.Config.Options.Modded && !player.IsAdmin && !permission.UserHasGroup(player.UserIDString, "admin"))
                {
                    return(null);
                }

                // Is it a covalance command?
                if (Covalence.CommandSystem.HandleChatMessage(iplayer, str))
                {
                    return(true);
                }

                // Is it a regular chat command?
                if (!cmdlib.HandleChatCommand(player, cmd, args))
                {
                    iplayer.Reply(lang.GetMessage("UnknownCommand", this, iplayer.Id), cmd);
                }
            }
            catch (NullReferenceException ex)
            {
                var sb = new StringBuilder();
                try
                {
                    var      str     = arg?.GetString(0);
                    var      message = str?.Substring(1);
                    string   cmd;
                    string[] args;
                    ParseCommand(message, out cmd, out args);
                    sb.AppendLine("NullReferenceError in Oxide.Game.Rust when running OnServerCommand.");
                    sb.AppendLine($"  Command: {arg.cmd?.FullName}");
                    sb.AppendLine($"  Full command: {str}");
                    sb.AppendLine($"  Command: {cmd}");
                    sb.AppendLine($"  Arguments: {args.ToSentence()}");
                    sb.AppendLine($"  Connection: {arg.Connection}");
                    sb.AppendLine($"  Connection ID: {arg.Connection?.userid}");
                    sb.AppendLine($"  Connection player? {arg.Connection?.player != null}");
                    sb.AppendLine($"  Connection player: {arg.Connection?.player}");
                    sb.AppendLine($"  Connection player type: {arg.Connection?.player?.GetType()}");
                }
                catch
                {
                    // Ignored
                }
                finally
                {
                    RemoteLogger.Exception(ex.Message, sb.ToString());
                }
            }

            // Handled
            arg.ReplyWith(string.Empty);
            return(true);
        }
Exemplo n.º 19
0
        private void StackConsoleCommand(ConsoleSystem.Arg arg)
        {
            if (arg.IsAdmin != true)
            {
                if ((arg.Connection.userid.ToString() != null) && !(permission.UserHasPermission(arg.Connection.userid.ToString(), "stacksizecontroller.canChangeStackSize")))
                {
                    arg.ReplyWith("[StackSizeController] You don't have permission to use this command.");
                    return;
                }
            }

            if (!pluginLoaded)
            {
                arg.ReplyWith("[StackSizeController] StackSizeController has encountered an error while trying to read the data file. Please contact your server administrator to fix the issue.");
                return;
            }

            if (arg.Args != null)
            {
                if (arg.Args.Length < 2)
                {
                    arg.ReplyWith("[StackSizeController] Syntax Error: Requires 2 arguments. Syntax Example: stack ammo.rocket.hv 64 (Use shortname)");
                    return;
                }
            }
            else
            {
                arg.ReplyWith("[StackSizeController] Syntax Error: Requires 2 arguments. Syntax Example: stack ammo.rocket.hv 64 (Use shortname)");
                return;
            }

            int stackAmount = 0;
            List <ItemDefinition> gameitems = ItemManager.itemList.FindAll(x => x.shortname.Equals(arg.Args[0]));

            if (gameitems.Count == 0)
            {
                arg.ReplyWith("[StackSizeController] Syntax Error: That is an incorrect item name. Please use a valid shortname.");
                return;
            }

            string replymessage = "";

            switch (arg.Args[1].ToLower())
            {
            case "default":
            {
                stackAmount  = DetermineStack(gameitems[0]);
                replymessage = "[StackSizeController] Updated Stack Size for " + gameitems[0].displayName.english + " (" + gameitems[0].shortname + ") to " + stackAmount + " (Default value based on config).";
                break;
            }

            default:
            {
                if (int.TryParse(arg.Args[1], out stackAmount) == false)
                {
                    arg.ReplyWith("[StackSizeController] Syntax Error: Stack Amount is not a number. Syntax Example: /stack ammo.rocket.hv 64 (Use shortname)");
                    return;
                }
                replymessage = "[StackSizeController] Updated Stack Size for " + gameitems[0].displayName.english + " (" + gameitems[0].shortname + ") to " + stackAmount + ".";
                break;
            }
            }

            if (gameitems[0].condition.enabled && gameitems[0].condition.max > 0)
            {
                if (!(configData.Settings.StackHealthItems))
                {
                    arg.ReplyWith("[StackSizeController] Error: Stacking health items is disabled in the config.");
                    return;
                }
            }

            items.itemlist[gameitems[0].displayName.english] = Convert.ToInt32(stackAmount);

            gameitems[0].stackable = Convert.ToInt32(stackAmount);

            SaveData();

            arg.ReplyWith(replymessage);
        }
Exemplo n.º 20
0
        void cmdWarpPlayerr(ConsoleSystem.Arg arg)
        {
            BasePlayer target = BasePlayer.Find(arg.Args[0]);

            if ((arg.Args == null) || (arg.Args != null && arg.Args.Length == 0))
            {
                arg.ReplyWith("warp.playerto <PlayerName> <WarpName>");
                return;
            }
            if (arg.Connection != null && arg.Connection.authLevel < 1)
            {
                arg.ReplyWith("You cant use that command!");
                return;
            }
            if (target == null)
            {
                arg.ReplyWith("Player not found!");
                return;
            }

            ulong  steamID = target.userID;
            double nextteletime;


            if (enablecooldown == true)
            {
                if (storedData.cantele.TryGetValue(steamID, out nextteletime))
                {
                    if (GetTimeStamp() >= nextteletime)
                    {
                        storedData.cantele[steamID] = GetTimeStamp() + cooldown;
                        Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData);
                        goto Finish;
                    }
                    else
                    {
                        int nexttele = Convert.ToInt32(nextteletime - GetTimeStamp());
                        SendReplyWithIcon(target, youhavetowait, nexttele.ToString().Replace("-", ""));
                        return;
                    }
                }
                else
                {
                    storedData.cantele.Add(steamID, GetTimeStamp() + cooldown);
                    Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData);
                    goto Finish;
                }
            }

Finish:
            foreach (WarpInfo info in storedData.WarpInfo)
            {
                if (info.WarpName.ToLower() == arg.Args[1].ToLower() || info.WarpId.ToString().ToLower() == arg.Args[1].ToLower())
                {
                    SendReplyWithIcon(target, teleportingto, info.WarpTimer, info.WarpName);
                    arg.ReplyWith($"Teleporting {target.displayName} to {info.WarpName} in {info.WarpTimer}");
                    timer.Once(info.WarpTimer, () => {
                        if (WarpIfRunning == false && target.IsRunning())
                        {
                            SendReplyWithIcon(target, cantwarpwhilerunning);
                            return;
                        }
                        if (WarpIfWounded == false && target.IsWounded())
                        {
                            SendReplyWithIcon(target, cantwarpwhilewounded);
                            return;
                        }
                        if (WarpIfSwimming == false && target.IsSwimming())
                        {
                            SendReplyWithIcon(target, cantwarpwhileswimming);
                            return;
                        }
                        if (WarpIfBuildingBlocked == false & !target.CanBuild())
                        {
                            SendReplyWithIcon(target, cantwarpwhilebuildingblocked);
                            return;
                        }
                        if (WarpIfDucking == false && target.IsDucked())
                        {
                            SendReplyWithIcon(target, cantwarpwhileducking);
                            return;
                        }
                        ForcePlayerPos(target, new Vector3(info.WarpX, info.WarpY, info.WarpZ), info.RandomRange > 0);
                        SendReplyWithIcon(target, youhaveteleportedto, info.WarpName);
                    });
                }
            }
        }
Exemplo n.º 21
0
        // chat.say().Hooks.Chat()
        public static void Command(ConsoleSystem.Arg arg)
        {
            Player player = new Player(arg.Player());

            string[] args = arg.ArgsStr.Substring(2, arg.ArgsStr.Length - 3).Replace("\\", "").Split(new string[] { " " }, StringSplitOptions.None);

            Command cmd = new Command(player, args);

            if (cmd.cmd == "")
            {
                return;
            }

            if (Config.GetBoolValue("Commands", "enabled"))
            {
                if (cmd.cmd == Config.GetValue("Commands", "ShowMyStats"))
                {
                    PlayerStats stats = player.Stats;
                    player.Message(String.Format("You have {0} kills and {1} deaths!", stats.Kills, stats.Deaths));
                    player.Message(String.Format("You have taken {0} dmg, and caused {1} in total!", stats.TotalDamageTaken, stats.TotalDamageDone));
                    return;
                }
                if (cmd.cmd == Config.GetValue("Commands", "ShowStatsOther"))
                {
                    Player pOther = Player.Find(String.Join(" ", cmd.args));
                    if (pOther != null)
                    {
                        PlayerStats stats2 = pOther.Stats;
                        player.Message(String.Format("You have {0} kills and {1} deaths!", stats2.Kills, stats2.Deaths));
                        player.Message(String.Format("You have taken {0} dmg, and caused {1} in total!", stats2.TotalDamageTaken, stats2.TotalDamageDone));
                        return;
                    }
                    player.Message("Can't find player: " + String.Join(" ", cmd.args));
                    return;
                }
                if (cmd.cmd == Config.GetValue("Commands", "ShowLocation"))
                {
                    player.Message(player.Location.ToString());
                    return;
                }
                if (cmd.cmd == Config.GetValue("Commands", "ShowOnlinePlayers"))
                {
                    string msg = Server.GetServer().Players.Count == 1 ? "You are alone!" : String.Format("There are: {0} players online!", Server.GetServer().Players.Count);
                    player.Message(msg);
                    return;
                }
                if (cmd.cmd == Config.GetValue("Commands", "Help"))
                {
                    foreach (string key in Config.PlutonConfig.EnumSection("HelpMessage"))
                    {
                        player.Message(Config.GetValue("HelpMessage", key));
                    }
                }
                if (cmd.cmd == Config.GetValue("Commands", "Commands"))
                {
                    player.Message(String.Join(", ", PluginCommands.GetInstance().getCommands().ToArray()));
                }
                // TODO: command description, usage
            }
            OnCommand.OnNext(cmd);

            if (cmd.ReplyWith != "")
            {
                arg.ReplyWith(cmd.ReplyWith);
            }
        }
Exemplo n.º 22
0
 public static void fps(ConsoleSystem.Arg arg)
 {
     arg.ReplyWith(string.Concat(Performance.report.frameRate.ToString(), " FPS"));
 }
Exemplo n.º 23
0
 private void ConsoleVersion(ConsoleSystem.Arg arg) => arg.ReplyWith($"Oxide {OxideMod.Version} for Rust {Rust.Defines.Connection.protocol}");
Exemplo n.º 24
0
 void GTNCONSOLECMD(ConsoleSystem.Arg args)
 {
     //args.ReplyWith("test");
     if (args.Connection != null)
     {
         return;
     }
     if (args.Args == null)
     {
         args.ReplyWith(msg("GTN console invalid syntax"));
         return;
     }
     if (args.Args.Length == 0)
     {
         args.ReplyWith(msg("GTN console invalid syntax"));
         return;
     }
     if (args.Args.Length > 3)
     {
         args.ReplyWith(msg("GTN console invalid syntax"));
         return;
     }
     if (args.Args[0] == null)
     {
         args.ReplyWith(msg("GTN console invalid syntax"));
         return;
     }
     if (args.Args[0] == "start")
     {
         if (eventActive)
         {
             args.ReplyWith(msg("Event Already Active"));
             return;
         }
         if (args.Args.Length == 3)
         {
             minNumber = Convert.ToInt32(args.Args[1]);
             maxNumber = Convert.ToInt32(args.Args[2]);
             if (minNumber != 0 && maxNumber != 0)
             {
                 number = Convert.ToInt32(Math.Round(Convert.ToDouble(UnityEngine.Random.Range(Convert.ToSingle(minNumber), Convert.ToSingle(maxNumber)))));
                 StartEvent();
                 args.ReplyWith(string.Format(msg("Event Created"), number.ToString()));
             }
             else
             {
                 args.ReplyWith(msg("Invalid Params"));
                 return;
             }
         }
         else
         {
             minNumber = minDefault;
             maxNumber = maxDefault;
             number    = Convert.ToInt32(Math.Round(Convert.ToDouble(UnityEngine.Random.Range(Convert.ToSingle(minNumber), Convert.ToSingle(maxNumber)))));
             StartEvent();
             args.ReplyWith(string.Format(msg("Event Created"), number.ToString()));
         }
         if (autoEventsEnabled)
         {
             if (!autoRepeatTimer.Destroyed)
             {
                 autoRepeatTimer.Destroy();
                 autoRepeatTimer = timer.Repeat(autoEventTime, 0, () => StartEvent());
             }
         }
         return;
     }
     else if (args.Args[0] == "end")
     {
         if (eventActive == false)
         {
             args.ReplyWith(msg("No Event"));
             return;
         }
         if (!eventTimer.Destroyed || eventTimer != null)
         {
             eventTimer.Destroy();
         }
         if (autoEventsEnabled)
         {
             if (!autoRepeatTimer.Destroyed)
             {
                 autoRepeatTimer.Destroy();
                 autoRepeatTimer = timer.Repeat(autoEventTime, 0, () => StartEvent());
             }
         }
         eventActive = false;
         args.ReplyWith("The current event has been cancelled");
         rust.BroadcastChat(msg("Event Timed Out"));
     }
     else
     {
         args.ReplyWith(msg("GTN console invalid syntax"));
     }
     return;
 }
Exemplo n.º 25
0
        private object OnRunCommand(ConsoleSystem.Arg arg)
        {
            // Sanity checks
            if (arg == null)
            {
                return(null);
            }
            if (arg.cmd == null)
            {
                return(null);
            }

            // Is it chat.say?
            if (arg.cmd.namefull == "chat.say")
            {
                // Get the args
                string str = arg.GetString(0, "text");
                if (str.Length == 0)
                {
                    return(null);
                }

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

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

                    // Handle it
                    Command    cmdlib = Interface.GetMod().GetLibrary <Command>("Command");
                    BasePlayer ply    = arg.connection.player as BasePlayer;
                    if (ply == null)
                    {
                        Interface.GetMod().RootLogger.Write(LogType.Debug, "Player is actually a {0}!", arg.connection.player.GetType());
                    }
                    else
                    {
                        if (!cmdlib.HandleChatCommand(ply, cmd, args))
                        {
                            ply.SendConsoleCommand("chat.add", 0, string.Format("Unknown command '{0}'!", cmd));
                        }
                    }

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

            // Default behaviour
            return(null);
        }
Exemplo n.º 26
0
        private void CmdGroup(ConsoleSystem.Arg arg)
        {
            if (!PermissionsLoaded(arg))
            {
                return;
            }
            if (!IsAdmin(arg))
            {
                return;
            }
            if (!arg.HasArgs(2))
            {
                var reply = "Usage: group <add|set> <name> [title] [rank]\n";
                reply += "Usage: group <remove> <name>\n";
                reply += "Usage: 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");
                }
            }
        }
Exemplo n.º 27
0
        void cmdConsoleFind(ConsoleSystem.Arg arg)
        {
            var player = arg.Player();

            arg.ReplyWith(Find(player, arg.Args));
        }
Exemplo n.º 28
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)
            {
                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))
                {
                    player.SendConsoleCommand("chat.add", 0, $"Unknown command '{cmd}'!");
                }

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

            // Default behavior
            return(null);
        }
Exemplo n.º 29
0
 void cmdlmsConsole(ConsoleSystem.Arg arg)
 {
     resetstatsconsole();
     arg.ReplyWith(string.Format(lang.GetMessage("titleconsole", this) + lang.GetMessage("statsresetconsole", this)));
 }
Exemplo n.º 30
0
 public static void echo(ref ConsoleSystem.Arg arg)
 {
     arg.ReplyWith(arg.ArgsStr);
 }