How does the the Covalence Command brace work or how does it compare for example?
Code:[Command("test")] void test(IPlayer player, string command, string[] args) { } // Does this one work as both console and chat command?[ChatCommand("test")] void test(BasePlayer player, string command, string[] args) { }[ConsoleCommand("test")] void test(ConsoleSystem.arg args) { }
Solved Registering Covalence commands?
Discussion in 'Rust Development' started by Austinv900, Aug 4, 2016.
-
Wulf Community Admin
It would work as both a console and chat command, though you may need a prefix for console right now as the assumed global. isn't working as far as I know.
-
I see so I would need to set it as plugin.test or something so it would be
/Plugin.test ingame
And plugin.test in console? -
Wulf Community Admin
-
oh okay. so lets say I did prefix it with server. I wouldnt have to prefix the chat command would I?
-
Wulf Community Admin
-
Okay. Sounds easy enough thanks @Wulf
-
Another question. Since im a noob. Im trying to do somthing for lets say a command arg isn't set to return a value. for example.
Code:if (args[1] != null) { string defaultaction = "player"; } else { string defaultaction = args[1]}
Might be a topic for a new thread. -
Wulf Community Admin
Code:var action = args[1] ?? "player";
Code:var action = !string.IsNullOrEmpty(args[1]) ? args[1] : "player";
Code:var action = args.Length >= 2 ? args[1] : "player";
-
I got it working with this instead maybe you have an idea to clean it up?
Code:case "player": if (args.Length == 1) { SendReply(player, $"[<color=#6275a4>{Name}</color>]: Invalid Arguments Ex. <color=green>/{command} player</color> <color=red>{player.displayName}</color>"); return; } var target = rust.FindPlayer(args[1]); if (!target) { SendReply(player, $"Player <color=purple>{args[1]}</color> - Was not found"); return; } if (args.Length == 3) { if (args[2] == "player" || args[2] == "stash" || args[2] == "tc" || args[2] == "all") { defaultAction = args[2]; } else { SendReply(player, $"{args[2]} is a invalid action, please use: player | stash | tc | all"); return; } } string activated; radar(target, defaultAction, defaulttime, defaultdistance, boxheight); if (IsRadar(target)) { activated = "Activated"; } else { activated = "Disabled"; } SendReply(player, $"[<color=#6275a4>{Name}</color>]: You have successfully <color=green>{activated}</color> <color=#6275a4>{Name}</color> for <color=yellow>{target.displayName}</color>"); break;
-
Wulf Community Admin
-
It would.
[DOUBLEPOST=1470365279][/DOUBLEPOST]I would love for you to try Admin Radar when i'm done with it I don't know if you actually play rust or not -
Another bump on the road. When you added IsGod to godmode how did you make it callback so fast. for some reason I can't make it so that AdminPanel reads IsRadar from AdminRadar correctly without setting a delay timer
-
Wulf Community Admin
-
Some how I think I messed myself up on that. I was doing the exact same thing as Godmode was but everytime I took the refresh cui timer out I took the refresh cui part out completely Silly me
-
How can I go about using covalence.RegisterCommand. I can't figure out the callback
-
Wulf Community Admin
You can either use attributes:
Code:[Command("testcmd")] void TestCommand(IPlayer player, string command, string[] args) { // Stuff happens here }
Code:[Command("testcmd", "othercmd")] void TestCommand(IPlayer player, string command, string[] args) { // Stuff happens here }
Code:[Command("testcmd", "othercmd"), Permission("perm.name")] void TestCommand(IPlayer player, string command, string[] args) { // Stuff happens here }
Code:void Init() { AddCovalenceCommand("version" , "VersionCommand"); }
Code:void Init() { AddCovalenceCommand(new[] { "oxide.version", "version" }, "VersionCommand"); }
-
I was attempting to register custom command names from a config. I just did the rust method and forwarded the method to a covalence method
-
Wulf Community Admin
-
I will look into that. Thanks wulf