PlayerChat

From RAGE Multiplayer Wiki
Revision as of 12:52, 23 May 2019 by RoboN1X (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

Server-Side
Event

C.png C# Js.png JavaScript




C# Syntax
C.png


JavaScript Syntax
Jslogo.png

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.png C# Js.png JavaScript



C# Syntax
C.png

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 Syntax
Jslogo.png

Parameters

  • text: String

Example

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


See also

Checkpoint

Colshape

Entity

Player

Streaming

Vehicle

Waypoint