Difference between revisions of "ClearChatBox"

From Multi Theft Auto: Wiki
m (Example)
m (Example)
 
Line 40: Line 40:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
  
local players = getElementsByType('player')
+
for k, v in pairs(getElementsByType('player')) do
 
 
for k, v in pairs(players) do
 
 
   clearChatBox(v)
 
   clearChatBox(v)
 
end
 
end

Latest revision as of 09:10, 22 September 2019

This function clears the chatbox. It does not clear the console (F8)

Syntax

Click to collapse [-]
Client
bool clearChatBox ()

Returns

Returns true if the player's chat was cleared successfully, false otherwise.

Click to collapse [-]
Server
bool clearChatBox ( [ element clearFor = getRootElement() ])

Required Arguments

  • clearFor : The player whose chat is to be cleared. By default, this is set to the root element, which will affect all players.

Returns

Returns true if the player's chat was cleared successfully, false otherwise.

Example

Click to collapse [-]
Client

This example removes spam caused by outputChatBox

for i=1,10 do
  outputChatBox( "spam ..." )
end

clearChatBox()
outputChatBox("Chat cleared successfully!")
Click to expand [+]
Server

See Also