Player::outputChatBox: Difference between revisions

From RAGE Multiplayer Wiki
m (Added use of variables)
(Changed syntax; Added RGB example;)
Line 2: Line 2:
This functions writes a chat message to player.
This functions writes a chat message to player.
== Syntax ==
== Syntax ==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="typescript">
player.outputChatBox(reason);
void player.outputChatBox(string text);
</syntaxhighlight>
</syntaxhighlight>
== Arguments ==
===Required Arguments===
<div>
*'''text:''' Text what should be output in player chat.
*reason - string
</div>
== Example ==
== Example ==
This example welcomes player on connect.
This example welcomes player on connect.
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
mp.events.add('playerJoin', player => {
mp.events.add(`playerJoin`,  
  player.outputChatBox('Welcome to the server, ' + player.name + '!');
player => {
  // Example of colours in chat:
const red = `#ff0000`;
  var red = "#ff0000"
player.outputChatBox(`Welcome to the server, ${player.name}!`);
  player.outputChatBox(`!{#dddddd}This is Grey! !{#ffffff}This is White! !{red} This is Red!`);
player.outputChatBox(`!{#dddddd}This is Grey! !{#ffffff}This is White! !{${red}}This is Red! !{255,0,0}This is too Red!`);
});
}
);
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Player_block}}
{{Player_block}}

Revision as of 14:37, 26 September 2017

This functions writes a chat message to player.

Syntax

void player.outputChatBox(string text);

Required Arguments

  • text: Text what should be output in player chat.

Example

This example welcomes player on connect.

mp.events.add(`playerJoin`, 
	player => {
		const red = `#ff0000`;
		player.outputChatBox(`Welcome to the server, ${player.name}!`);
		player.outputChatBox(`!{#dddddd}This is Grey! !{#ffffff}This is White! !{${red}}This is Red! !{255,0,0}This is too Red!`);
	}
);

See Also