Aero LogoAero Docs

Command Registration

Expose server commands instantly using the Zero-Touch Command registration system in the Aero Framework.

Zero-Touch Commands

Traditional command registration in FiveM requires invoking registration natives manually or subscribing to event handlers inside your primary scripts.

Aero replaces this boilerplate entirely. Any class within your plugin assemblies that implements the ICommand interface is detected automatically during the plugin startup phase and registered directly into the Cfx.re command structure.

The `ICommand` Interface

To define a command, implement the interface with the following properties:

  • Name: The console execution trigger (e.g. hello).
  • Description: Documentation string describing the command's functionality.
  • Permission: The authorization level required to run the command (e.g. admin or user).
  • Execute(int source, string[] args): The execution handler block invoked upon calling.

Code Example

Here is a command implementation that spawns a vehicle using the framework features:

using Aero.API.Interfaces;
using Aero.API.Features;

public class SpawnCommand : ICommand
{
    public string Name => "car";
    public string Description => "Spawns a vehicle by model name.";
    public string Permission => "admin";

    public void Execute(int source, string[] args)
    {
        if (args.Length < 1)
        {
            Log.Error("Usage: /car [modelName]");
            return;
        }

        string modelName = args[0];
        Log.Info($"Player {source} requested spawning: {modelName}");
        
        // Spawn logic can be integrated using Vehicle Driver here
    }
}