1. Code:
    [ConsoleCommand("test")]
            void cmdTest(ConsoleSystem.Arg arg)
    {
    Puts(z);
    }
    
    How can I get specific arguments from consolecommand? For example if I type test x y z into console, then how can I get that z specifically?

    I tried {args[0]} {args[1]} {args[2]}, but couldn't get them to work...
    Thanks. :)
     
  2. You should get string[] Args from param arg
    Code:
    Puts(arg.Args[0]);
    Use IntelliSense in your IDE. It will be a helpful thing for your needs.
     
  3. How do I get string[] Args?
     
  4. Code:
    [ConsoleCommand("test")]
    void cmdTest(ConsoleSystem.Arg arg)
    {
       for(int i = 0; i < arg.Args.Count; i++)
          Puts(arg.Args[i]);
    }
     
     
  5. Code:
    using UnityEngine;
    using System.Collections.Generic;
    using System.Linq;namespace Oxide.Plugins
    {
        [Info("Test", "jackcat", 0.1)]
        [Description("None.")]    class Test : RustPlugin
        {
            [ConsoleCommand("test")]
            void cmdTest(ConsoleSystem.Arg arg)
            {
            for(int i = 0; i < arg.Args.Count; i++)
            Puts(arg.Args[i]);
            }
        }       
    }
    
    Gives error: Error while compiling: Test.cs(18,18): error CS0019: Operator `<' cannot be applied to operands of type `int' and `method group'
     
  6. Code:
            [ConsoleCommand("test")]
            void cmdTest(ConsoleSystem.Arg arg)
            {
                for (int i = 0; i < arg.Args.Length; i++)
                    Puts(arg.Args[i]);
            }
    
     
  7. Thanks that works. :)
     
  8. Is it possible getting multiple args that way? Something like:

    Code:
     [ConsoleCommand("test")]
            void cmdTest(ConsoleSystem.Arg arg)
            {
               
                for (int one = 0; one < arg.Args.Length; one++)
                for (int two = 1; two < arg.Args.Length; two++)
                for (int three = 2; three < arg.Args.Length; three++)
               
                a = arg.Args[one];   
                b = arg.Args[two];       
                c = arg.Args[three];       
               
                Puts("A = " + a + "B = " + b + "C = " + c);
            }
    
    Thanks.
     
  9. Wulf

    Wulf Community Admin

    arg.Args[0]
    arg.Args[1]
    arg.Args[2]
     
  10. Thank you Wulf. :)
     
  11. Code:
            [ConsoleCommand("test")]
            void cmdTest(ConsoleSystem.Arg arg)
            {
                string argument = "";
                for (int i = 0; i < arg.Args.Length; i++)
                    argument += $"\nArgument {i} => {arg.Args[i]}";
                Puts(argument);
            }
    
     
  12. Thanks Sami :)
     
  13. Can I use those args as ints? For example... if I type into console position 1000 50 2000
    exx = arg.Args[0];
    wyy = arg.Args[1];
    zed = arg.Args[2];

    Then exx would be for exaple 1000, wyy 50, zed 2000
     
  14. Wulf

    Wulf Community Admin

    Look up converting string to int in C#.
     
  15. Thanks Wulf. Got it working. :)
     
  16. Solved.