ShowChat: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Spanish translated version/ versión traducida al español.)
(Undo revision 61740 by Zelev (talk))
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server client function}}  
{{Server client function}}  
Esta función es usada para mostrar y/o ocultar el chat del jugador.
This function is used to show or hide the player's chat.


==Syntax==
==Syntax==
<section name="Cliente" class="client" show="true">
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool showChat ( bool show )
bool showChat ( bool show )
</syntaxhighlight>
</syntaxhighlight>


===Argumentos Requeridos===  
===Required Arguments===  
*'''show:''' Un valor boolean determinando si mostrar (''true'') o ocultar (''false'') el chat.
*'''show:''' A boolean value determining whether to show (''true'') or hide (''false'') the chat.


===Returns===
===Returns===
Se vuelve ''true'' si el chat del jugador fue mostrado o ocultado con éxito, ''false'' de lo contrario.
Returns ''true'' if the player's chat was shown or hidden successfully, ''false'' otherwise.
</section>
</section>
<section name="Servidor" class="server" show="true">
<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>


===Argumentos Requeridos===  
===Required Arguments===  
*'''thePlayer:''' El [[player]] al cual se le muestra o oculta el chat.
*'''thePlayer:''' The [[player]] whose chat is to be hidden or shown.
*'''show:''' Un valor boolean determinando si mostrar (''true'') o ocultar (''false'') el chat.
*'''show:''' A boolean value determining whether to show (''true'') or hide (''false'') the chat.


===Returns===
===Returns===
Se vuelve ''true'' si el chat del jugador fue mostrado o ocultado con éxito, ''false'' de lo contrario.
Returns ''true'' if the player's chat was shown or hidden successfully, ''false'' otherwise.
</section>
</section>


==Ejemplo==  
==Example==  
<section name="Cliente" class="client" show="true">
<section name="Client" class="client" show="true">
Este ejemplo alterna (muestra o oculta) el chat del jugador cuando presiona la tecla "'''i'''".
This example toggle's the player's chat when they press the "'''i'''" key.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--El siguiente ejemplo es para todas las versiones hasta la 1.4:
--This example below is for all versions until 1.4:
local isChatVisible = true --Asumamos que el chat es visible tan pronto inicie el resource.
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 --Revisa si el chat está visible.
     if isChatVisible then --Check or the chat is visible.
         showChat(false) --Si lo está, ocúltalo.
         showChat(false) --If it is, hide it.
         isChatVisible = false
         isChatVisible = false
     else
     else
         showChat(true) --Si no lo está, muéstralo.
         showChat(true) --If it is not, show it.
         isChatVisible = true
         isChatVisible = true
     end
     end
end
end


bindKey("i", "down", chat) --Haz una tecla de enlace (bind, bindea) para inciar la función tan pronto un jugador presione la tecla 'i'
bindKey("i", "down", chat) --Make a bind key to start the function as soon as a player presses the key 'i'




--El siguiente ejemplo es para las versiones 1.4 en adelante:
--This example below is for version 1.4 and up:
function chat(key, keyState)
function chat(key, keyState)
     if isChatVisible() then --Revisa si el chat está visible.
     if isChatVisible() then --Check or the chat is visible.
         showChat(false) --Si lo está, ocúltalo.
         showChat(false) --If it is, hide it.
     else
     else
         showChat(true) --Si no lo está, muéstralo.
         showChat(true) --If it is not, show it.
     end
     end
end
end


bindKey("i", "down", chat) --Haz una tecla de enlace (bind, bindea) para iniciar la función tan pronto un jugador presione la tecla 'i'
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>


==Ver también==
==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 [-]
Client
bool 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 [-]
Server
bool 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 [-]
Client

This 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