Chat Commands
Quickly run code from the chat window
Chat Command Structure
/mycommand 12 secondParamExample Command
import { Airship } from "@Easy/Core/Shared/Airship";
import { ChatCommand } from "@Easy/Core/Shared/Commands/ChatCommand";
import { Player } from "@Easy/Core/Shared/Player/Player";
export class MyCommand extends ChatCommand {
constructor() {
// command name, alias, usage hints, and description
super("mycommand", ["c"], "[string] (optional)", "Print a message");
}
// Player that sent the command and the variables passed through as string arguments
public Execute(player: Player, args: string[]): void {
// Get the parameter if it was sent
let firstParameter = ""
if(args.size() > 0){
firstParameter = args[0];
}
// Create a log message
const logMessage = "Client sent message: " + firstParameter;
// Log to console on server
print(logMessage);
// Send the results to every clients chat window
Airship.Chat.BroadcastMessage(logMessage);
}
}Last updated