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?Code:[ConsoleCommand("test")] void cmdTest(ConsoleSystem.Arg arg) { Puts(z); }
I tried {args[0]} {args[1]} {args[2]}, but couldn't get them to work...
Thanks.![]()
Getting arguments from ConsoleSystem?
Discussion in 'Rust Development' started by jackcat, Mar 15, 2018.
-
You should get string[] Args from param arg
Code:Puts(arg.Args[0]);
-
How do I get string[] Args?
-
Code:
[ConsoleCommand("test")] void cmdTest(ConsoleSystem.Arg arg) { for(int i = 0; i < arg.Args.Count; i++) Puts(arg.Args[i]); }
-
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]); } } }
-
Code:
[ConsoleCommand("test")] void cmdTest(ConsoleSystem.Arg arg) { for (int i = 0; i < arg.Args.Length; i++) Puts(arg.Args[i]); }
-
-
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); }
-
Wulf Community Admin
arg.Args[1]
arg.Args[2] -
Thank you Wulf.
-
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); }
-
Thanks Sami
-
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 -
Wulf Community Admin
-
Thanks Wulf. Got it working.
-
Solved.