OutputServerLog: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 15: | Line 15: | ||
==Example== | ==Example== | ||
This example outputs client logins to the server log. | <section name="Server" class="server" show="true"> | ||
'''Example 1:''' This example outputs client logins to the server log. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function logClientLogin ( previous_account, current_account ) | function logClientLogin ( previous_account, current_account ) | ||
Line 22: | Line 23: | ||
addEventHandler ( "onClientLogin", getRootElement(), logClientLogin ) | addEventHandler ( "onClientLogin", getRootElement(), logClientLogin ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
'''Example 2:''' This example outputs the clients position to the server | |||
<syntaxhighlight lang="lua"> | |||
function outputPosition(source) | |||
local x,y,z = getElementPosition(source) | |||
outputServerLog(tostring(x) .. "," .. tostring(y) .. "," .. tostring(z)) | |||
end | |||
addCommandHandler("op",outputPosition) | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{Server functions}} | {{Server functions}} |
Revision as of 19:15, 15 January 2009
This outputs a line of text to the server's log. This could be useful for debugging.
Syntax
bool outputServerLog ( string text )
Required Arguments
- text: The text to be output to the log.
Returns
Returns true if successful, false otherwise.
Example
Click to collapse [-]
ServerExample 1: This example outputs client logins to the server log.
function logClientLogin ( previous_account, current_account ) outputServerLog ( "Client " .. getClientName ( source ) .. " logged in as " .. getAccountName ( current_account ) ) end addEventHandler ( "onClientLogin", getRootElement(), logClientLogin )
Example 2: This example outputs the clients position to the server
function outputPosition(source) local x,y,z = getElementPosition(source) outputServerLog(tostring(x) .. "," .. tostring(y) .. "," .. tostring(z)) end addCommandHandler("op",outputPosition)
See Also
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown