OutputServerLog: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Undo revision 43289 by Glossy (talk))
Line 15: Line 15:


==Example==  
==Example==  
<section name="Server" class="server" show="true">
<section name="Zone Gaming " class="Zone Gaming" show="true">
'''Example 1:''' This example outputs client logins to the server log.
'''Example 1:''' This example outputs client logins to the server log.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">

Revision as of 07:17, 21 December 2016

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 [-]
Zone Gaming

Example 1: This example outputs client logins to the server log.

function logClientLogin ( previous_account, current_account )
	outputServerLog ( "Client " .. getPlayerName ( 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