<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Maniekxx</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Maniekxx"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Maniekxx"/>
	<updated>2026-04-24T09:56:47Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OutputChatBox&amp;diff=67650</id>
		<title>OutputChatBox</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OutputChatBox&amp;diff=67650"/>
		<updated>2020-10-29T00:42:31Z</updated>

		<summary type="html">&lt;p&gt;Maniekxx: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
{{Note|Avoid outputting text to the chatbox that isn't actually chat, as this can be annoying for players. Output information and status messages to the HUD.}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This outputs the specified text string to the chatbox. It can be specified as a message to certain player(s) or all players.&lt;br /&gt;
&lt;br /&gt;
It can optionally allow you to embed color changes into the string by setting the colorCoded boolean to true. This allows: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
outputChatBox ( &amp;quot;#FF0000Hello #00FF00World&amp;quot;, getRootElement(), 255, 255, 255, true )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will display as: '''&amp;lt;span style='color:red;'&amp;gt;Hello&amp;lt;/span&amp;gt; &amp;lt;span style='color:green'&amp;gt;World&amp;lt;/span&amp;gt; '''&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool outputChatBox ( string text [, element visibleTo = getRootElement(), int r = 231, int g = 217, int b = 176, bool colorCoded = false ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[player]]:outputChat}}&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''text:''' The text string that you wish to send to the chat window. If more than 256 characters it will not be showed in chat.&lt;br /&gt;
&lt;br /&gt;
==Optional Arguments==&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''visibleTo:''' This specifies who the chat is visible to. Any players in this element will see the chat message. See [[visibility]].&lt;br /&gt;
{{New items|5.0157|1.5.7-9.20391|&lt;br /&gt;
*'''visibleTo:''' Can also be a table of players or team.}}&lt;br /&gt;
*'''r:''' The amount of red in the color of the text. Default value is 231.&lt;br /&gt;
*'''g:''' The amount of green in the color of the text. Default value is 217.&lt;br /&gt;
*'''b:''' The amount of blue in the color of the text. Default value is 176.&lt;br /&gt;
*'''colorCoded:''' A boolean value determining whether or not '#RRGGBB' tags should be used.&lt;br /&gt;
Note: The #RRGGBB format must contain capital letters a-f is not acceptable but A-F is. Default RGB values in this format are: '#E7D9B0'.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool outputChatBox ( string text [, int r = 231, int g = 217, int b = 176, bool colorCoded = false ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''text:''' The text string that you wish to send to the chat window. If more than 256 characters it will not be showed in chat.&lt;br /&gt;
&lt;br /&gt;
==Optional Arguments==&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''r:''' The amount of red in the color of the text. Default value is 231.&lt;br /&gt;
*'''g:''' The amount of green in the color of the text. Default value is 217.&lt;br /&gt;
*'''b:''' The amount of blue in the color of the text. Default value is 176.&lt;br /&gt;
*'''colorCoded:''' A boolean value determining whether or not '#RRGGBB' tags should be used.&lt;br /&gt;
Note: The #RRGGBB format must contain capital letters a-f is not acceptable but A-F is. Default RGB values in this format are: '#E7D9B0'.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns ''true'' if the message was displayed successfully. Returns ''false'' if invalid arguments are specified.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 1:''' This example displays a chat message to all users.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
x = 5&lt;br /&gt;
y = 10  &lt;br /&gt;
-- Displays the message&lt;br /&gt;
outputChatBox ( &amp;quot;I have &amp;quot; .. x .. &amp;quot; apples and &amp;quot; .. y .. &amp;quot; oranges.&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' This example outputs a simple colour coded message, &amp;quot;Red White&amp;quot;, where the 'White' is in white colour, and 'Red' is in a red colour.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
 outputChatBox ( &amp;quot;Red #FFFFFFWhite&amp;quot;, getRootElement(), 255, 0, 0, true )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 3:''' This example allows for coloured chat, according to a player's nametag.  This makes use of colour coded outputs.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function colouredChat ( message, theType )&lt;br /&gt;
	if theType == 0 then --if its normal chat (not /me or teamchat) then&lt;br /&gt;
		cancelEvent() --prevent MTA from outputting chat&lt;br /&gt;
		message = string.gsub(message, &amp;quot;#%x%x%x%x%x%x&amp;quot;, &amp;quot;&amp;quot;) --remove any hex tags in a player's chat to prevent custom colours by using lua's string.gsub&lt;br /&gt;
		local r,g,b = getPlayerNametagColor ( source ) --get the player's nametag colour&lt;br /&gt;
		local chatterName = getPlayerName ( source ) --get his name&lt;br /&gt;
		--output a message with the name as his nametag colour, and the rest in white.&lt;br /&gt;
		outputChatBox ( chatterName..&amp;quot;:#FFFFFF &amp;quot;..message, getRootElement(), r, g, b, true )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerChat&amp;quot;, getRootElement(), colouredChat)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 4:''' This example displays a chat message to a single user called ''someguy''.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Find the player element for the player called 'someguy'&lt;br /&gt;
myPlayer = getPlayerFromName ( &amp;quot;someguy&amp;quot; )&lt;br /&gt;
-- If a player was found called 'someguy' then...&lt;br /&gt;
if ( myPlayer ~= false ) then&lt;br /&gt;
    x = 5&lt;br /&gt;
    y = 10&lt;br /&gt;
    -- Display the message&lt;br /&gt;
    outputChatBox ( &amp;quot;I have &amp;quot; .. x .. &amp;quot; apples and &amp;quot; .. y .. &amp;quot; oranges.&amp;quot;, myPlayer )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 5:''' These two functions can speed up typing, and display a message when a player Joins.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local msg_red,msg_green,msg_blue = 255,255,0&lt;br /&gt;
&lt;br /&gt;
function servertalkprivate(message, sendto)&lt;br /&gt;
        --Talk to one client only&lt;br /&gt;
	outputChatBox(tostring(message), sendto, msg_red, msg_green, msg_blue, true)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function servertalk(message)&lt;br /&gt;
        --Talk to everyone&lt;br /&gt;
	servertalkprivate(message, getRootElement())&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function onJoin()&lt;br /&gt;
	servertalkprivate(&amp;quot;Welcome to My Server&amp;quot;, source)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;,getRootElement(),onJoin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 6:''' This can be used to display a message when the player joins and sets its armor to 100.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onJoin()&lt;br /&gt;
         setPedArmor(source, 100)&lt;br /&gt;
         local playerName = getPlayerName(source)&lt;br /&gt;
         outputChatBox(&amp;quot;Welcome &amp;quot;.. playerName ..&amp;quot; To The Server&amp;quot;, source, 0, 154, 255)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, root, onJoin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 7:''' This code will output an message to nearby players.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function displayLocalMessage(player, cmd)&lt;br /&gt;
	if player then -- Check if command was triggered by player&lt;br /&gt;
		local x, y, z = getElementPosition(player) -- Get player position&lt;br /&gt;
		local nearbyPlayers = getElementsWithinRange(x, y, z, 10, &amp;quot;player&amp;quot;) -- Retrieve nearby players in range of 10&lt;br /&gt;
&lt;br /&gt;
		outputChatBox(&amp;quot;Local message :)!&amp;quot;, nearbyPlayers) -- Output our message&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;localmessage&amp;quot;, displayLocalMessage)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 8:''' This example displays your nickname and the amount of money.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function player_info(player,cmd)&lt;br /&gt;
	outputChatBox(&amp;quot;Name: #FFFFFF&amp;quot;..getPlayerName(player),player,255,0,0,true)&lt;br /&gt;
	outputChatBox(&amp;quot;Money: #FFFFFF&amp;quot;..getPlayerMoney(player)..&amp;quot;#00FF00$&amp;quot;,player,255,0,0,true)&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;info&amp;quot;,player_info)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Server functions}}&lt;br /&gt;
[[cs:outputChatBox]]&lt;br /&gt;
[[pl:outputChatBox]]&lt;br /&gt;
[[ru:outputChatBox]]&lt;br /&gt;
[[pt-br:OutputChatBox]]&lt;/div&gt;</summary>
		<author><name>Maniekxx</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OutputChatBox&amp;diff=67649</id>
		<title>OutputChatBox</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OutputChatBox&amp;diff=67649"/>
		<updated>2020-10-29T00:41:51Z</updated>

		<summary type="html">&lt;p&gt;Maniekxx: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
{{Note|Avoid outputting text to the chatbox that isn't actually chat, as this can be annoying for players. Output information and status messages to the HUD.}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This outputs the specified text string to the chatbox. It can be specified as a message to certain player(s) or all players.&lt;br /&gt;
&lt;br /&gt;
It can optionally allow you to embed color changes into the string by setting the colorCoded boolean to true. This allows: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
outputChatBox ( &amp;quot;#FF0000Hello #00FF00World&amp;quot;, getRootElement(), 255, 255, 255, true )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will display as: '''&amp;lt;span style='color:red;'&amp;gt;Hello&amp;lt;/span&amp;gt; &amp;lt;span style='color:green'&amp;gt;World&amp;lt;/span&amp;gt; '''&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool outputChatBox ( string text [, element visibleTo = getRootElement(), int r = 231, int g = 217, int b = 176, bool colorCoded = false ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[player]]:outputChat}}&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''text:''' The text string that you wish to send to the chat window. If more than 256 characters it will not be showed in chat.&lt;br /&gt;
&lt;br /&gt;
==Optional Arguments==&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''visibleTo:''' This specifies who the chat is visible to. Any players in this element will see the chat message. See [[visibility]].&lt;br /&gt;
{{New items|5.0157|1.5.7-9.20391|&lt;br /&gt;
*'''visibleTo:''' Can also be a table of players or team.}}&lt;br /&gt;
*'''r:''' The amount of red in the color of the text. Default value is 231.&lt;br /&gt;
*'''g:''' The amount of green in the color of the text. Default value is 217.&lt;br /&gt;
*'''b:''' The amount of blue in the color of the text. Default value is 176.&lt;br /&gt;
*'''colorCoded:''' A boolean value determining whether or not '#RRGGBB' tags should be used.&lt;br /&gt;
Note: The #RRGGBB format must contain capital letters a-f is not acceptable but A-F is. Default RGB values in this format are: '#E7D9B0'.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool outputChatBox ( string text [, int r = 231, int g = 217, int b = 176, bool colorCoded = false ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''text:''' The text string that you wish to send to the chat window. If more than 256 characters it will not be showed in chat.&lt;br /&gt;
&lt;br /&gt;
==Optional Arguments==&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''r:''' The amount of red in the color of the text. Default value is 231.&lt;br /&gt;
*'''g:''' The amount of green in the color of the text. Default value is 217.&lt;br /&gt;
*'''b:''' The amount of blue in the color of the text. Default value is 176.&lt;br /&gt;
*'''colorCoded:''' A boolean value determining whether or not '#RRGGBB' tags should be used.&lt;br /&gt;
Note: The #RRGGBB format must contain capital letters a-f is not acceptable but A-F is. Default RGB values in this format are: '#E7D9B0'.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns ''true'' if the message was displayed successfully. Returns ''false'' if invalid arguments are specified.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 1:''' This example displays a chat message to all users.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
x = 5&lt;br /&gt;
y = 10  &lt;br /&gt;
-- Displays the message&lt;br /&gt;
outputChatBox ( &amp;quot;I have &amp;quot; .. x .. &amp;quot; apples and &amp;quot; .. y .. &amp;quot; oranges.&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' This example outputs a simple colour coded message, &amp;quot;Red White&amp;quot;, where the 'White' is in white colour, and 'Red' is in a red colour.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
 outputChatBox ( &amp;quot;Red #FFFFFFWhite&amp;quot;, getRootElement(), 255, 0, 0, true )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 3:''' This example allows for coloured chat, according to a player's nametag.  This makes use of colour coded outputs.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function colouredChat ( message, theType )&lt;br /&gt;
	if theType == 0 then --if its normal chat (not /me or teamchat) then&lt;br /&gt;
		cancelEvent() --prevent MTA from outputting chat&lt;br /&gt;
		message = string.gsub(message, &amp;quot;#%x%x%x%x%x%x&amp;quot;, &amp;quot;&amp;quot;) --remove any hex tags in a player's chat to prevent custom colours by using lua's string.gsub&lt;br /&gt;
		local r,g,b = getPlayerNametagColor ( source ) --get the player's nametag colour&lt;br /&gt;
		local chatterName = getPlayerName ( source ) --get his name&lt;br /&gt;
		--output a message with the name as his nametag colour, and the rest in white.&lt;br /&gt;
		outputChatBox ( chatterName..&amp;quot;:#FFFFFF &amp;quot;..message, getRootElement(), r, g, b, true )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerChat&amp;quot;, getRootElement(), colouredChat)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 4:''' This example displays a chat message to a single user called ''someguy''.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Find the player element for the player called 'someguy'&lt;br /&gt;
myPlayer = getPlayerFromName ( &amp;quot;someguy&amp;quot; )&lt;br /&gt;
-- If a player was found called 'someguy' then...&lt;br /&gt;
if ( myPlayer ~= false ) then&lt;br /&gt;
    x = 5&lt;br /&gt;
    y = 10&lt;br /&gt;
    -- Display the message&lt;br /&gt;
    outputChatBox ( &amp;quot;I have &amp;quot; .. x .. &amp;quot; apples and &amp;quot; .. y .. &amp;quot; oranges.&amp;quot;, myPlayer )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 5:''' These two functions can speed up typing, and display a message when a player Joins.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local msg_red,msg_green,msg_blue = 255,255,0&lt;br /&gt;
&lt;br /&gt;
function servertalkprivate(message, sendto)&lt;br /&gt;
        --Talk to one client only&lt;br /&gt;
	outputChatBox(tostring(message), sendto, msg_red, msg_green, msg_blue, true)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function servertalk(message)&lt;br /&gt;
        --Talk to everyone&lt;br /&gt;
	servertalkprivate(message, getRootElement())&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function onJoin()&lt;br /&gt;
	servertalkprivate(&amp;quot;Welcome to My Server&amp;quot;, source)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;,getRootElement(),onJoin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 6:''' This can be used to display a message when the player joins and sets its armor to 100.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onJoin()&lt;br /&gt;
         setPedArmor(source, 100)&lt;br /&gt;
         local playerName = getPlayerName(source)&lt;br /&gt;
         outputChatBox(&amp;quot;Welcome &amp;quot;.. playerName ..&amp;quot; To The Server&amp;quot;, source, 0, 154, 255)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, root, onJoin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 7:''' This code will output an message to nearby players.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function displayLocalMessage(player, cmd)&lt;br /&gt;
	if player then -- Check if command was triggered by player&lt;br /&gt;
		local x, y, z = getElementPosition(player) -- Get player position&lt;br /&gt;
		local nearbyPlayers = getElementsWithinRange(x, y, z, 10, &amp;quot;player&amp;quot;) -- Retrieve nearby players in range of 10&lt;br /&gt;
&lt;br /&gt;
		outputChatBox(&amp;quot;Local message :)!&amp;quot;, nearbyPlayers) -- Output our message&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;localmessage&amp;quot;, displayLocalMessage)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 8:''' This example displays your nickname and the amount of money.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function player_info(player,cmd)&lt;br /&gt;
	outputChatBox(&amp;quot;Name: #FFFFFF&amp;quot;..getPlayerName(plryer),player,255,0,0,true)&lt;br /&gt;
	outputChatBox(&amp;quot;Money: #FFFFFF&amp;quot;..getPlayerMoney(player)..&amp;quot;#00FF00$&amp;quot;,player,255,0,0,true)&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;info&amp;quot;,player_info)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Server functions}}&lt;br /&gt;
[[cs:outputChatBox]]&lt;br /&gt;
[[pl:outputChatBox]]&lt;br /&gt;
[[ru:outputChatBox]]&lt;br /&gt;
[[pt-br:OutputChatBox]]&lt;/div&gt;</summary>
		<author><name>Maniekxx</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OutputChatBox&amp;diff=67648</id>
		<title>OutputChatBox</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OutputChatBox&amp;diff=67648"/>
		<updated>2020-10-29T00:41:24Z</updated>

		<summary type="html">&lt;p&gt;Maniekxx: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
{{Note|Avoid outputting text to the chatbox that isn't actually chat, as this can be annoying for players. Output information and status messages to the HUD.}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This outputs the specified text string to the chatbox. It can be specified as a message to certain player(s) or all players.&lt;br /&gt;
&lt;br /&gt;
It can optionally allow you to embed color changes into the string by setting the colorCoded boolean to true. This allows: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
outputChatBox ( &amp;quot;#FF0000Hello #00FF00World&amp;quot;, getRootElement(), 255, 255, 255, true )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will display as: '''&amp;lt;span style='color:red;'&amp;gt;Hello&amp;lt;/span&amp;gt; &amp;lt;span style='color:green'&amp;gt;World&amp;lt;/span&amp;gt; '''&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool outputChatBox ( string text [, element visibleTo = getRootElement(), int r = 231, int g = 217, int b = 176, bool colorCoded = false ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[player]]:outputChat}}&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''text:''' The text string that you wish to send to the chat window. If more than 256 characters it will not be showed in chat.&lt;br /&gt;
&lt;br /&gt;
==Optional Arguments==&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''visibleTo:''' This specifies who the chat is visible to. Any players in this element will see the chat message. See [[visibility]].&lt;br /&gt;
{{New items|5.0157|1.5.7-9.20391|&lt;br /&gt;
*'''visibleTo:''' Can also be a table of players or team.}}&lt;br /&gt;
*'''r:''' The amount of red in the color of the text. Default value is 231.&lt;br /&gt;
*'''g:''' The amount of green in the color of the text. Default value is 217.&lt;br /&gt;
*'''b:''' The amount of blue in the color of the text. Default value is 176.&lt;br /&gt;
*'''colorCoded:''' A boolean value determining whether or not '#RRGGBB' tags should be used.&lt;br /&gt;
Note: The #RRGGBB format must contain capital letters a-f is not acceptable but A-F is. Default RGB values in this format are: '#E7D9B0'.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool outputChatBox ( string text [, int r = 231, int g = 217, int b = 176, bool colorCoded = false ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''text:''' The text string that you wish to send to the chat window. If more than 256 characters it will not be showed in chat.&lt;br /&gt;
&lt;br /&gt;
==Optional Arguments==&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''r:''' The amount of red in the color of the text. Default value is 231.&lt;br /&gt;
*'''g:''' The amount of green in the color of the text. Default value is 217.&lt;br /&gt;
*'''b:''' The amount of blue in the color of the text. Default value is 176.&lt;br /&gt;
*'''colorCoded:''' A boolean value determining whether or not '#RRGGBB' tags should be used.&lt;br /&gt;
Note: The #RRGGBB format must contain capital letters a-f is not acceptable but A-F is. Default RGB values in this format are: '#E7D9B0'.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns ''true'' if the message was displayed successfully. Returns ''false'' if invalid arguments are specified.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 1:''' This example displays a chat message to all users.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
x = 5&lt;br /&gt;
y = 10  &lt;br /&gt;
-- Displays the message&lt;br /&gt;
outputChatBox ( &amp;quot;I have &amp;quot; .. x .. &amp;quot; apples and &amp;quot; .. y .. &amp;quot; oranges.&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' This example outputs a simple colour coded message, &amp;quot;Red White&amp;quot;, where the 'White' is in white colour, and 'Red' is in a red colour.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
 outputChatBox ( &amp;quot;Red #FFFFFFWhite&amp;quot;, getRootElement(), 255, 0, 0, true )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 3:''' This example allows for coloured chat, according to a player's nametag.  This makes use of colour coded outputs.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function colouredChat ( message, theType )&lt;br /&gt;
	if theType == 0 then --if its normal chat (not /me or teamchat) then&lt;br /&gt;
		cancelEvent() --prevent MTA from outputting chat&lt;br /&gt;
		message = string.gsub(message, &amp;quot;#%x%x%x%x%x%x&amp;quot;, &amp;quot;&amp;quot;) --remove any hex tags in a player's chat to prevent custom colours by using lua's string.gsub&lt;br /&gt;
		local r,g,b = getPlayerNametagColor ( source ) --get the player's nametag colour&lt;br /&gt;
		local chatterName = getPlayerName ( source ) --get his name&lt;br /&gt;
		--output a message with the name as his nametag colour, and the rest in white.&lt;br /&gt;
		outputChatBox ( chatterName..&amp;quot;:#FFFFFF &amp;quot;..message, getRootElement(), r, g, b, true )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerChat&amp;quot;, getRootElement(), colouredChat)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 4:''' This example displays a chat message to a single user called ''someguy''.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Find the player element for the player called 'someguy'&lt;br /&gt;
myPlayer = getPlayerFromName ( &amp;quot;someguy&amp;quot; )&lt;br /&gt;
-- If a player was found called 'someguy' then...&lt;br /&gt;
if ( myPlayer ~= false ) then&lt;br /&gt;
    x = 5&lt;br /&gt;
    y = 10&lt;br /&gt;
    -- Display the message&lt;br /&gt;
    outputChatBox ( &amp;quot;I have &amp;quot; .. x .. &amp;quot; apples and &amp;quot; .. y .. &amp;quot; oranges.&amp;quot;, myPlayer )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 5:''' These two functions can speed up typing, and display a message when a player Joins.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local msg_red,msg_green,msg_blue = 255,255,0&lt;br /&gt;
&lt;br /&gt;
function servertalkprivate(message, sendto)&lt;br /&gt;
        --Talk to one client only&lt;br /&gt;
	outputChatBox(tostring(message), sendto, msg_red, msg_green, msg_blue, true)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function servertalk(message)&lt;br /&gt;
        --Talk to everyone&lt;br /&gt;
	servertalkprivate(message, getRootElement())&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function onJoin()&lt;br /&gt;
	servertalkprivate(&amp;quot;Welcome to My Server&amp;quot;, source)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;,getRootElement(),onJoin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 6:''' This can be used to display a message when the player joins and sets its armor to 100.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onJoin()&lt;br /&gt;
         setPedArmor(source, 100)&lt;br /&gt;
         local playerName = getPlayerName(source)&lt;br /&gt;
         outputChatBox(&amp;quot;Welcome &amp;quot;.. playerName ..&amp;quot; To The Server&amp;quot;, source, 0, 154, 255)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, root, onJoin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 7:''' This code will output an message to nearby players.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function displayLocalMessage(player, cmd)&lt;br /&gt;
	if player then -- Check if command was triggered by player&lt;br /&gt;
		local x, y, z = getElementPosition(player) -- Get player position&lt;br /&gt;
		local nearbyPlayers = getElementsWithinRange(x, y, z, 10, &amp;quot;player&amp;quot;) -- Retrieve nearby players in range of 10&lt;br /&gt;
&lt;br /&gt;
		outputChatBox(&amp;quot;Local message :)!&amp;quot;, nearbyPlayers) -- Output our message&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;localmessage&amp;quot;, displayLocalMessage)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 7:''' This example displays your nickname and the amount of money.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function player_info(player,cmd)&lt;br /&gt;
	outputChatBox(&amp;quot;Name: #FFFFFF&amp;quot;..getPlayerName(plryer),player,255,0,0,true)&lt;br /&gt;
	outputChatBox(&amp;quot;Money: #FFFFFF&amp;quot;..getPlayerMoney(player)..&amp;quot;#00FF00$&amp;quot;,player,255,0,0,true)&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;info&amp;quot;,player_info)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Server functions}}&lt;br /&gt;
[[cs:outputChatBox]]&lt;br /&gt;
[[pl:outputChatBox]]&lt;br /&gt;
[[ru:outputChatBox]]&lt;br /&gt;
[[pt-br:OutputChatBox]]&lt;/div&gt;</summary>
		<author><name>Maniekxx</name></author>
	</entry>
</feed>