Skip to main content

PlayerChat

This event is triggered when a player send a message in the chat.

Server-side event

C#​

See OnChatMessage.

JavaScript​

Parameters​

  • player: Player - player, who send message
  • text: String - the text that was sent

Example​

This example will gives 300 money a player if his nickname is "Modernß" and he types "sorry" in chat.

function checkChatMessage(player, text) {
if (player.name === "Modernß" && text == "sorry") {
player.money += 300;
}
};

mp.events.add("playerChat", checkChatMessage);
Client-side event

C#​

public delegate void OnPlayerChatDelegate(string text, CancelEventArgs cancel);

Parameters​

  • text: text, expects System.String type.
  • cancel: cancel, expects RAGE.Events.CancelEventArgs type.

Example​

Events.OnPlayerChat += OnPlayerChat;
public void OnPlayerChat(string text, RAGE.Events.CancelEventArgs cancel)
{
if (text == "who is george")
{
RAGE.Chat.Output("He is the bossmen");
}
else if (text == "who is jaimuzu")
{
RAGE.Chat.Output("He is a beast");
}
}

JavaScript​

Parameters​

  • text: String

Example​

mp.events.add("playerChat", (text) => {
if (text === "test") {
mp.gui.chat.push("You wrote 'test' in chat.");
}
});