OnPlayerChat
This hook is triggered when a player sends a message in the game chat.
public override bool OnPlayerChat(PlayerBase player, string message, int chatType)
{
return true;
}
| Parameter | Type | Description |
|---|
player | PlayerBase | The player who sent the message. |
message | string | The content of the chat message. |
chatType | int | The content of the chat message. |
| Value | Name |
|---|
| 0 | Default |
| 1 | Local |
| 2 | Global |
| 3 | Squad |
| 4 | Admin |
| Type | Description |
|---|
bool | Return true to allow the message to be sent, or false to cancel it. |
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;
}