Schedule Dedicated Servers Documentation
  • SDS Documentation
  • Schedule In Unity
    • Extracting the game to unity
    • Creating an assetbundle
  • Creating plugins
    • How to create a plugin
    • The ClientAPI (custom content)
  • Custom Assets
  • Plugin Events
  • Texture/Material Replacement
  • Chat Messages
  • Chat Commands
  • Console Commands
  • HAPI Methods
Powered by GitBook
On this page
  • Example Simple Command Without Permissions
  • A command with a description and a required permission.
  • As an example here is the players command from SDS.

Chat Commands

Adding chat commands is as easy as making your method public static and adding the ChatCommand attribute as shown below.

Example Simple Command Without Permissions

[ChatCommand("discord")]
public static void DiscordCommand(Player player)
{
    player.SendChatMessage("You can join our discord at discord.gg/xxxxx");
}

A command with a description and a required permission.

[ChatCommand(name: "kickme", permission: "chat.kickme", docs: "Syntax: '/kickme' Kicks yourself from the server.")]
public static void Command_players(Player player)
{
    player.Kick("Such an useful command.");
}

As an example here is the players command from SDS.

This command uses a string as the return type for ease of use, it directly sends the message in chat OR in the console if ran by the console. If a command is ran by the console the player will be null. The player can NEVER be null in other cases. The console also bypass any permissions.

[ChatCommand(name: "players", permission: "chat.players", docs: "Syntax: '/players' Lists all players in the world.")]
public static string Command_players(Player player, string[] args)
{
    List<Player> players = Player.PlayerList.WithoutServerPlayer();
    string playerList = string.Join(", ", players.Select(x => x.PlayerName));
    return $"Players ({players.Count}): {playerList}.";
}

PreviousChat MessagesNextConsole Commands

Last updated 1 month ago