OutputServerLog: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 26: Line 26:
'''Example 2:''' This example outputs the clients position to the server
'''Example 2:''' This example outputs the clients position to the server
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function outputPosition(source)
local function outputPosition(source)
outputServerLog( table.concat({getElementPosition(source)}, ", ") )
  outputServerLog( table.concat({getElementPosition(source)}, ", ") )
end
end
addCommandHandler("op",outputPosition)
addCommandHandler("op", outputPosition)
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Revision as of 09:36, 16 October 2017

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 [-]
Server

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

local function outputPosition(source)
   outputServerLog( table.concat({getElementPosition(source)}, ", ") )
end
addCommandHandler("op", outputPosition)

See Also