Player::outputChatBox: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
Line 7: Line 7:
===Required Arguments===
===Required Arguments===
*'''text:''' Text what should be output in player chat.
*'''text:''' Text what should be output in player chat.
== Example ==
== Example #1 ==
This example welcomes player on connect.
This example welcomes player on connect.
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript" highlight="3">
mp.events.add(`playerJoin`,  
mp.events.add(`playerJoin`,  
player => {
player => {
const red = `#ff0000`;
player.outputChatBox(`Welcome to the server, ${player.name}!`);
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!`);
}
}
);
);
</syntaxhighlight>
== Example #2 ==
This example just output color texts.
Note: [[chat.colors]] property should be enabled - if you wanna use that.
<syntaxhighlight lang="javascript" highlight="4,5">
let red = `#ff0000`;
let player = mp.player.at(1337);
if (player) {
player.outputChatBox(`!{#dddddd}This is Grey! !{#ffffff}This is White! !{${red}}This is Red!`);
player.outputChatBox(` !{255, 0, 0}This is too Red! !{green}This is Green! !{255, 0, 255, 0.5}This is opacity Pink!`);
};
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 15:17, 26 September 2017

This functions writes a chat message to player.

Syntax

player.outputChatBox(String text);

Required Arguments

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

Example #1

This example welcomes player on connect.

mp.events.add(`playerJoin`, 
	player => {
		player.outputChatBox(`Welcome to the server, ${player.name}!`);
	}
);

Example #2

This example just output color texts. Note: chat.colors property should be enabled - if you wanna use that.

let red = `#ff0000`;
let player = mp.player.at(1337);
if (player) {
	player.outputChatBox(`!{#dddddd}This is Grey! !{#ffffff}This is White! !{${red}}This is Red!`);
	player.outputChatBox(` !{255, 0, 0}This is too Red! !{green}This is Green! !{255, 0, 255, 0.5}This is opacity Pink!`);
};

See Also