This repository was archived by the owner on Feb 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Command System
ZeroTwo edited this page Aug 24, 2024
·
2 revisions
The API has an internal command system that can be really helpful for beginners and people who don't want to make long code. Now lets break it down.
The main class that we use is NotCommands used like the normal interface like ICommand.
Here's an Example on how to use this with both Player and Server that can run the command
[CommandHandler(typeof(RemoteAdminCommandHandler))]
public class ExampleCommand : NotCommands
{
public override string[] GetAliases() => ["ex"];
public override string GetCommandName() => "Example";
public override string GetDescription() => "Example command.";
public override string[] GetPerms() => null;
public override string[] GetUsage() => ["string"];
public override bool Function(string[] args, ICommandSender sender, out string result)
{
if (!TryGetArgument(args, 1, out string arg1) || !int.TryParse(arg1, out int id))
{
result = "I need a number please, UwU!";
return true;
}
result = $"Is your number {arg1}?";
return false;
}
}Now if we run /example 1 or example 1 in the RA we should get "Is your number 1.".
[CommandHandler(typeof(RemoteAdminCommandHandler))]
public class ExampleCommand : NotCommands
{
public override string[] GetAliases() => ["ex"];
public override string GetCommandName() => "Example";
public override string GetDescription() => "Example command.";
public override string[] GetUsage() => ["string"];
public override bool GetRequirePlayer() => true;
public override bool PlayerBasedFunction(Player player, string[] args, out string result)
{
if (!TryGetArgument(args, 1, out string arg1) || !int.TryParse(arg1, out int id))
{
result = "I need a number please, UwU!";
return true;
}
result = $"Is your number {arg1}?";
return false;
}
}Same command but now only the client will be able to execute the command