Terminal Commands
Add custom terminal commands that players can run in the in-game terminal.
Basic Command
typescript
import { Command, RegisterCommand } from "@hotbunny/hackhub-content-sdk";
@RegisterCommand
class PingCommand extends Command {
CommandName = "myping";
Description = "Custom ping tool";
async Run(tools) {
const args = tools.getArgs();
if (args.length === 0) {
tools.printError("Usage: myping <ip>");
return;
}
tools.println(`Pinging ${args[0]}...`);
await tools.sleep(1000);
tools.println("Reply received.");
}
}Properties
| Property | Type | Description |
|---|---|---|
CommandName | string | The command name players type |
Description | string | Help text shown in autocomplete |
Autocomplete | CommandAutoComplete[] | Autocomplete hints |
PackageName | string | Package name (if installable via apt install) |
The Run Method
Run(tools) is called when the player executes the command. It receives a tools object with helper methods.
Tools API
| Method | Description |
|---|---|
tools.getArgs() | Get command arguments as string[] |
tools.println(text) | Print a line to the terminal |
tools.printError(text) | Print an error message |
tools.printWarning(text) | Print a warning message |
tools.printSuccess(text) | Print a success message |
tools.sleep(ms) | Wait for a duration |
tools.clear() | Clear the terminal |
Autocomplete
Define autocomplete hints to help players:
typescript
@RegisterCommand
class ScanCommand extends Command {
CommandName = "modscan";
Description = "Scan a target for vulnerabilities";
Autocomplete = [
{ label: "modscan", type: "STRING" },
{ label: "<target-ip>", type: "IP" },
{ label: "--deep", type: "FLAG" },
];
async Run(tools) {
const args = tools.getArgs();
tools.println(`Scanning ${args[0] || "..."}...`);
await tools.sleep(2000);
tools.printSuccess("Scan complete. No vulnerabilities found.");
}
}Autocomplete Types
| Type | Description |
|---|---|
STRING | Generic text |
IP | IP address |
FLAG | A flag like --verbose |
FILE | File path |
DIRECTORY | Directory path |
USER | Username |
Installable Commands
If you set PackageName, the command must be installed via apt install before use:
typescript
@RegisterCommand
class HackTool extends Command {
CommandName = "hacktool";
Description = "Advanced hacking toolkit";
PackageName = "hacktool";
async Run(tools) {
tools.println("HackTool v1.0 loaded.");
}
}