ClearChatBox: Difference between revisions
Jump to navigation
Jump to search
CrosRoad95 (talk | contribs) (Created page with "__NOTOC__ {{Server client function}} This function clearing chatbox, not console under F8. ==Syntax== <section name="Client" class="client" show="true"> <syntaxhighlight la...") |
Dutchman101 (talk | contribs) (rework examples section) |
||
(7 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function | {{New feature/item|3.0156|1.5.5|14165|This function clears the chatbox. It does not clear the console (F8)}} | ||
==Syntax== | ==Syntax== | ||
Line 17: | Line 17: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''clearFor :''' The [[player]] whose chat is to be cleared. By default | *'''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=== | ||
Line 23: | Line 23: | ||
</section> | </section> | ||
==Example== | ==Example== | ||
<section name=" | <section name="Server" class="server" show="true"> | ||
This example | This example adds an admin command to clear the chatbox for everyone | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function cmdClearChat(p, cmd) | |||
if not isPlayerStaff(p) then return end | |||
clearChatBox() | |||
end | |||
addCommandHandler("clearchat", cmdClearChat) | |||
-- Utility function | |||
local staffACLs = { | |||
aclGetGroup("Admin"), | |||
aclGetGroup("Moderator") | |||
} | |||
for | function isPlayerStaff(p) | ||
if isElement(p) and getElementType(p) == "player" and not isGuestAccount(getPlayerAccount(p)) then | |||
local object = getAccountName(getPlayerAccount(p)) | |||
for _, group in ipairs(staffACLs) do | |||
if isObjectInACLGroup("user." .. object, group) then | |||
return true | |||
end | |||
end | |||
end | |||
return false | |||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> |
Latest revision as of 04:42, 30 October 2021
This function clears the chatbox. It does not clear the console (F8)
Syntax
Click to collapse [-]
Clientbool clearChatBox ()
Returns
Returns true if the player's chat was cleared successfully, false otherwise.
Click to collapse [-]
Serverbool 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 [-]
ServerThis example adds an admin command to clear the chatbox for everyone
function cmdClearChat(p, cmd) if not isPlayerStaff(p) then return end clearChatBox() end addCommandHandler("clearchat", cmdClearChat) -- Utility function local staffACLs = { aclGetGroup("Admin"), aclGetGroup("Moderator") } function isPlayerStaff(p) if isElement(p) and getElementType(p) == "player" and not isGuestAccount(getPlayerAccount(p)) then local object = getAccountName(getPlayerAccount(p)) for _, group in ipairs(staffACLs) do if isObjectInACLGroup("user." .. object, group) then return true end end end return false end
See Also
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown