ShowChat: Difference between revisions
Jump to navigation
Jump to search
(Spanish translated version/ versión traducida al español.) |
|||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function is used to show or hide the player's chat. | |||
==Syntax== | ==Syntax== | ||
<section name=" | <section name="Client" class="client" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool showChat ( bool show ) | bool showChat ( bool show ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | ===Required Arguments=== | ||
*'''show:''' | *'''show:''' A boolean value determining whether to show (''true'') or hide (''false'') the chat. | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the player's chat was shown or hidden successfully, ''false'' otherwise. | |||
</section> | </section> | ||
<section name=" | <section name="Server" class="server" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool showChat ( player thePlayer, bool show ) | bool showChat ( player thePlayer, bool show ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | ===Required Arguments=== | ||
*'''thePlayer:''' | *'''thePlayer:''' The [[player]] whose chat is to be hidden or shown. | ||
*'''show:''' | *'''show:''' A boolean value determining whether to show (''true'') or hide (''false'') the chat. | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the player's chat was shown or hidden successfully, ''false'' otherwise. | |||
</section> | </section> | ||
== | ==Example== | ||
<section name=" | <section name="Client" class="client" show="true"> | ||
This example toggle's the player's chat when they press the "'''i'''" key. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | --This example below is for all versions until 1.4: | ||
local isChatVisible = true -- | local isChatVisible = true --Let's assume the chat is visible as soon as the resource starts. | ||
function chat(key, keyState) | function chat(key, keyState) | ||
if isChatVisible then -- | if isChatVisible then --Check or the chat is visible. | ||
showChat(false) -- | showChat(false) --If it is, hide it. | ||
isChatVisible = false | isChatVisible = false | ||
else | else | ||
showChat(true) -- | showChat(true) --If it is not, show it. | ||
isChatVisible = true | isChatVisible = true | ||
end | end | ||
end | end | ||
bindKey("i", "down", chat) -- | bindKey("i", "down", chat) --Make a bind key to start the function as soon as a player presses the key 'i' | ||
-- | --This example below is for version 1.4 and up: | ||
function chat(key, keyState) | function chat(key, keyState) | ||
if isChatVisible() then -- | if isChatVisible() then --Check or the chat is visible. | ||
showChat(false) -- | showChat(false) --If it is, hide it. | ||
else | else | ||
showChat(true) -- | showChat(true) --If it is not, show it. | ||
end | end | ||
end | end | ||
bindKey("i", "down", chat) -- | bindKey("i", "down", chat) --Make a bind key to start the function as soon as a player presses the key 'i' | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
== | ==See Also== | ||
{{Server functions}} | {{Server functions}} |
Revision as of 18:27, 24 December 2018
This function is used to show or hide the player's chat.
Syntax
Click to collapse [-]
Clientbool showChat ( bool show )
Required Arguments
- 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.
Click to collapse [-]
Serverbool showChat ( player thePlayer, bool show )
Required Arguments
- thePlayer: The player whose chat is to be hidden or shown.
- 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 [-]
ClientThis example toggle's the player's chat when they press the "i" key.
--This example below is for all versions until 1.4: local isChatVisible = true --Let's assume the chat is visible as soon as the resource starts. function chat(key, keyState) if isChatVisible then --Check or the chat is visible. showChat(false) --If it is, hide it. isChatVisible = false else showChat(true) --If it is not, show it. isChatVisible = true end end bindKey("i", "down", chat) --Make a bind key to start the function as soon as a player presses the key 'i' --This example below is for version 1.4 and up: function chat(key, keyState) if isChatVisible() then --Check or the chat is visible. showChat(false) --If it is, hide it. else showChat(true) --If it is not, show it. end end bindKey("i", "down", chat) --Make a bind key to start the function as soon as a player presses the key 'i'
See Also
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown