Raft Dedicated Server
  • Introducing Raft Dedicated Servers
    • Introducing RTCP (Our custom networking layer)
  • Tutorials
    • Windows: Installing your server
    • Linux: Installing your server
      • GUI based distro: Installing your server
      • CLI based Distro: Installing your server
    • Pterodactyl: Installing your Server
    • Docker: Installing your Server
    • Configuring your server
    • Managing Player Permissions
    • How to create a plugin project
      • How to load my plugin
  • Programming
    • Creating chat commands
    • Creating console commands
    • Player Permissions
Powered by GitBook
On this page
  1. Programming

Creating chat commands

This page will help you to create chat commands in your plugins.

Chat commands are created through attributes and only works with STATIC methods. Here's different examples :

[ChatCommand("hi", "Says hi to you")]
public static string TestCommand(Network_Player player)
{
    return "Hi " + player.GetName();
}

You can add permissions to command natively.

// The last argument is a permission, this will make the command only available
// to users with the said permission granted.
[ChatCommand("hi", "Says hi to allowed users", "myplugin.commands.hi")]
public static string TestCommand(Network_Player player)
{
    return "Hi " + player.GetName();
}

You can also just make it void and do your own stuff without sending a message to the user.

[ChatCommand(name:"hi",docs:"a description",permission:"myplugin.hicommand")]
public static void TestCommand(Network_Player player)
{
    // Do your stuff.
}

Chat commands can also have arguments with a string[] args parameter as shown below.

[ChatCommand("mycommand")]
public static void TestCommand(Network_Player player, string[] args)
{
    // Do your stuff with the args string array. (does not include the initial command)
}
PreviousHow to load my pluginNextCreating console commands

Last updated 2 years ago