Table of Contents

Class Chat

Namespace
AO
Assembly
CoreAssembly.dll

Chat is a core engine system to work with the in game chat.

public static class Chat
Inheritance
Chat
Inherited Members

Methods

AddChatMessage(string, string, MessageStyle)

Add a message to the local chat history. Does not broadcast the message to other players.

public static void AddChatMessage(string sender, string message, Chat.MessageStyle style)

Parameters

sender string
message string
style Chat.MessageStyle

RegisterChatCommandHandler(Action<Player, string>)

Register a chat command handler. This is only supported on the server. Invoked when a player sends a message that starts with a '/'.

[Obsolete("Use RegisterChatCommandHandler(Func<Player, string, bool>) instead. The new version requires you to return a bool to indicate if the command was handled to compose better with the new [ChatCommand] attribute. This will become an error in proto 40.")]
public static void RegisterChatCommandHandler(Action<Player, string> handler)

Parameters

handler Action<Player, string>

Examples

Chat.RegisterChatCommandHandler((Player player, string message) => {
    if (message == "hello") {
        Chat.SendMessage("Hello, " + player.Name, player);
    }
});

RegisterChatCommandHandler(Func<Player, string, bool>)

Register a chat command handler. This is only supported on the server. Invoked when a player sends a message that starts with a '/'.

public static void RegisterChatCommandHandler(Func<Player, string, bool> handler)

Parameters

handler Func<Player, string, bool>

Examples

Chat.RegisterChatCommandHandler((Player player, string message) => {
    if (message == "hello") {
        Chat.SendMessage("Hello, " + player.Name, player);
        return true; // return true to indicate that the command was handled
    }
    return false; // return false to indicate that the command was not handled
});

SendMessage(Player, string)

Send a message to a player. This is only supported on the server. Pass null as the player to broadcast the chat message to all players.

public static void SendMessage(Player player, string message)

Parameters

player Player
message string

SetChatMode(Mode)

public static void SetChatMode(Chat.Mode mode)

Parameters

mode Chat.Mode