OnClientDebugMessage: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Added an example.)
Line 22: Line 22:
The [[event system#Event source|source]] of this event is the [[root element]].
The [[event system#Event source|source]] of this event is the [[root element]].


==Example==  
==Examples==  
This (easy) example outputs the debug message in the console, so you don't need to open debugscript 3 :D
This (easy) example outputs the debug message in the console, so you don't need to open debugscript 3 :D
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 29: Line 29:
   outputConsole (message,getLocalPlayer())
   outputConsole (message,getLocalPlayer())
end)
end)
</syntaxhighlight>
This example tells players that they missed a debug message, if they don't have debugscript enabled.
<syntaxhighlight lang="lua">
function newDebug() -- Since we don't need any of the parameters, we can optimize the code and exclude them
if not isDebugViewActive() then -- If their debug view is not active
outputChatBox("* You just missed a debug message. Use the \'/debugscript\' command to view it.",255,0,0) -- Output to them that they missed a debug message
end
end
addEventHandler("onClientDebugMessage",root,newDebug) -- When we get a new client debug message, call the newDebug function
</syntaxhighlight>
</syntaxhighlight>


Line 36: Line 47:
===Client event functions===
===Client event functions===
{{Client_event_functions}}
{{Client_event_functions}}
[[Category:Needs_Example]]

Revision as of 22:13, 26 August 2011

This event is triggered when client-side debug messages (for instance errors or warnings) would appear in the debug window. This event doesn't require the debug window to be enabled to trigger, however.

Parameters

string message, int level, string file, int line
  • message: The message which was outputted in the server console, without details like file, line etc
  • level: The type of debug message which was outputted
    • 0: "Custom" message
    • 1: Error message
    • 2: Warning message
    • 3: Information message
  • file: The file from which the debug message was outputted
    • Note: May return nil when the source could not be found
  • line: The line in file file where the debug message was outputted
    • Note: May return nil when the source could not be found

Source

The source of this event is the root element.

Examples

This (easy) example outputs the debug message in the console, so you don't need to open debugscript 3 :D

addEventHandler ("onClientDebugMessage",getRootElement(),
function(message,level,file,line)
  outputConsole (message,getLocalPlayer())
end)


This example tells players that they missed a debug message, if they don't have debugscript enabled.

function newDebug() -- Since we don't need any of the parameters, we can optimize the code and exclude them
	if not isDebugViewActive() then -- If their debug view is not active
		outputChatBox("* You just missed a debug message. Use the \'/debugscript\' command to view it.",255,0,0) -- Output to them that they missed a debug message
	end
end
addEventHandler("onClientDebugMessage",root,newDebug) -- When we get a new client debug message, call the newDebug function

See Also

Other client events


Client event functions