Oxygen

OnPlayerChat

This hook is triggered when a player sends a message in the game chat.

Definition

public override bool OnPlayerChat(PlayerBase player, string message, int chatType)
{
    return true;
}

Parameters

ParameterTypeDescription
playerPlayerBaseThe player who sent the message.
messagestringThe content of the chat message.
chatTypeintThe content of the chat message.

Chat type (Enum)

ValueName
0Default
1Local
2Global
3Squad
4Admin

Return Value

TypeDescription
boolReturn true to allow the message to be sent, or false to cancel it.

Usage Example

public override bool OnPlayerChat(PlayerBase player, string message, int chatType)
{
    if (message.Contains("badword"))
    {
        Console.WriteLine($"Blocked message from {player.Name}");
        return false;
    }
    return true;
}

On this page