ShowChat: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}  
{{Server client function}}  
This function is used to show or hide the local player's chat.
This function is used to show or hide the player's chat.


==Syntax==
==Syntax==
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool showChat ( bool show )
bool showChat(bool show)
</syntaxhighlight>
</syntaxhighlight>
</section>
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
bool showChat(player thePlayer, bool show)
</syntaxhighlight>
</section>


===Required Arguments===  
===Required Arguments===  
*'''player:''' the player.
*'''show:''' A boolean value determining whether to show (''true'') or hide (''false'') the chat.
*'''show:''' A boolean value determining whether to show (''true'') or hide (''false'') the chat.


Line 15: Line 23:


==Example==  
==Example==  
<section name="Client" class="client" show="true">
This example toggle's the player's chat when they press the "'''i'''" key.
This example toggle's the player's chat when they press the "'''i'''" key.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local isChatVisible = true        -- let's assume the chat is visible
local isChatVisible = true        -- let's assume the chat is visible
function chat ( key, keyState )
function chat(key, keyState)
if ( isChatVisible ) then    -- if it's on
if isChatVisible then    -- if it's on
showChat ( false )    -- turn it off
showChat(false)    -- turn it off
isChatVisible = false
isChatVisible = false
else
else
showChat ( true )      -- if it's off
showChat(true)      -- if it's off
isChatVisible = true  -- turn it on
isChatVisible = true  -- turn it on
end
end
end
end
bindKey ( "i", "down", "toggle chat", chat ) -- the player's "i" key will toggle the chat
bindKey ("i", "down", "toggle chat", chat) -- the player's "i" key will toggle the chat
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Client_output_functions}}
{{Client_output_functions}}

Revision as of 15:30, 4 April 2009

This function is used to show or hide the player's chat.

Syntax

Click to collapse [-]
Client
bool showChat(bool show)
Click to collapse [-]
Server
bool showChat(player thePlayer, bool show)

Required Arguments

  • player: the player.
  • show: A boolean value determining whether to show (true) or hide (false) the chat.

Returns

Returns true if the player's chat was shown or hidden successfully, false otherwise.

Example

Click to collapse [-]
Client

This example toggle's the player's chat when they press the "i" key.

local isChatVisible = true         -- let's assume the chat is visible
function chat(key, keyState)
	if isChatVisible then    -- if it's on
		showChat(false)     -- turn it off
		isChatVisible = false
	else
		showChat(true)      -- if it's off
		isChatVisible = true   -- turn it on
	end
end
bindKey ("i", "down", "toggle chat", chat) -- the player's "i" key will toggle the chat

See Also