Custom chat command not workingSolved
Hi,

i've tried several things, then re-searched the net and some plugins. But i just want an easy ChatCommand which realizes arguments.

Like as example: i want that if i type /global Testmessage there will be broadcasted "Testmessage" in the chat.

[ChatCommand("global")
void GlobalMessage(string message)
{
    PrintToChat($"[Global] {message});
}

^ tried with parameters but i think im to stupid for it, im not a beginner and not an expert in C# but im kinda new to plugin development.

Thanks in advance
Your arguments for the method are not right, use:

void GlobalMessage(BasePlayer player, string command)
In response to Wulf ():
Your arguments for the method are not right, use:

void GlobalMessage(BasePlayer player, s...
Hi, i already had BasePlayer as argument but it didn't work aswell.

Plugin loaded successfully.

[ChatCommand("global")]
void test(BasePlayer player, string msg)
{
   if (player.UserIDString == "765611984xxx")
   {
           player.ChatMessage($"Hi {msg}");
   }
}





But in this case it should say "Hi Testmessage", and its always says what the chatcommand is for.
void test(BasePlayer player, string command, string[] args)
In response to Wulf ():
void test(BasePlayer player, string command, string[] args)
Thank you so much, i've seen it on some plugins, but it always told me cant convert from string to string array. But with the $ operator it seems to work. Thank you so much Wulf
In response to MajorMoose ():
Thank you so much, i've seen it on some plugins, but it always told me cant convert from string to s...
The $ is just used to replace a variable inline, but what I believe you are looking for is the args that I added to your command method shown above. The 2nd argument is not the "message", it's the command; the array of args is everything that you enter with the command.
In response to Wulf ():
The $ is just used to replace a variable inline, but what I believe you are looking for is the args...
Yeah it was exactly this thanks
Locked automatically