OutputConsole: Difference between revisions
Jump to navigation
Jump to search
(visibleTo is only serverside argument so I changed this page a little) |
Jack Johnson (talk | contribs) (Shortened down the function by taking advantage of the command variable.) |
||
Line 23: | Line 23: | ||
<section name="Server" class="server" show="true">This code creates two console commands. One, 'public', will post a message in the consoles of all players, and the other, 'private', will post a message in only the console of the player that executed the command. | <section name="Server" class="server" show="true">This code creates two console commands. One, 'public', will post a message in the consoles of all players, and the other, 'private', will post a message in only the console of the player that executed the command. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | function message(player,command) | ||
if command == "public" then | |||
outputConsole("Public console message") | |||
else | |||
outputConsole("Private console message",player) | |||
end | |||
end | end | ||
addCommandHandler("public",message) | |||
addCommandHandler("private",message) | |||
addCommandHandler ( "public", | |||
addCommandHandler ( "private", | |||
</syntaxhighlight></section> | </syntaxhighlight></section> | ||
==See Also== | ==See Also== | ||
{{Server functions}} | {{Server functions}} |
Revision as of 12:53, 14 January 2015
This outputs the specified text string to the console window (accessed with F8 or ~ key). It can be specified as a message to certain player(s) or all players.
Syntax
Click to collapse [-]
Clientbool outputConsole ( string text )
Required Arguments
- text: The text string that you wish to send to the console window
Click to collapse [-]
Serverbool outputConsole ( string text, [ element visibleTo=getRootElement() ] )
Required Arguments
- text: The text string that you wish to send to the console window
Optional Arguments
- visibleTo: This specifies who the chat is visible to. Any players in this element will see the chat message. See visibility.
Example
Click to collapse [-]
ServerThis code creates two console commands. One, 'public', will post a message in the consoles of all players, and the other, 'private', will post a message in only the console of the player that executed the command.
function message(player,command) if command == "public" then outputConsole("Public console message") else outputConsole("Private console message",player) end end addCommandHandler("public",message) addCommandHandler("private",message)
See Also
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown