OnChatCommand

From GT-MP
Jump to: navigation, search
OnChatCommand
Shared Function
Utilities-terminal.png Server-Side System-users.png Client-Side
Csharp.png C# Javascript.png JavaScript



Dialog-warning.pngRework required!

The contents of this page are possibly invalid or incomplete. Please treat the contents of this page with caution!

If you are able to, please modify the page so that it's factually correct.


This type of event is mainly used for commands handling but is a very legacy way of doing commands and is not recommended, new ways of command handling (Reference here) are proven to be more performant, efficient and easier to code.

Requirements

First of all, it should be defined in your Main constructor for it to be called, otherwise it wouldn't be initiated at all!

   public Main()
   {
      API.onChatCommand += OnChatCommandHandler;
   }

Handler signature

In C#
Server-Side Function

OnChatCommandHandler(Client player, string command, CancelEventArgs e)

In Javascript
Client-Side Function

OnChatCommandHandler(string msg)

Usage example(s)

   public void OnChatCommandHandler(Client player, string command, CancelEventArgs e)
   { 
      // Code goes here
   }