OnClientDebugMessage: Difference between revisions
Jump to navigation
Jump to search
(Created page with "__NOTOC__ {{Server event}} 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...") |
mNo edit summary |
||
(11 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{ | {{Client event}} | ||
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. | 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. | ||
'''Note:''' To prevent infinite loops, debug messages that occur inside the function that handles this event won't trigger this event, so you won't be able to rely on debug info to fix faulty code that is inside this function. Since build [https://buildinfo.mtasa.com/index.php?Revision=14683 r14683] debug messages from [[outputDebugString]] and [[iprint]] will show up. | |||
==Parameters== | ==Parameters== | ||
{{New feature/item|3.0158|1.5.7|11412| | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
string message, int level, string file, int line | string message, int level, string file, int line, int r, int g, int b | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | |||
*'''message''': The message which was outputted in the server console, without details like file, line etc | *'''message''': The message which was outputted in the server console, without details like file, line etc | ||
Line 18: | Line 22: | ||
*'''line''': The line in file '''file''' where the debug message was outputted | *'''line''': The line in file '''file''' where the debug message was outputted | ||
**'''Note:''' May return [[nil]] when the source could not be found | **'''Note:''' May return [[nil]] when the source could not be found | ||
{{New feature/item|3.0158|1.5.7|11412| | |||
*'''r''': Amount of red color (0-255) | |||
*'''g''': Amount of green color (0-255) | |||
*'''b''': Amount of blue color (0-255) | |||
}} | |||
==Source== | ==Source== | ||
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]]. | ||
== | ==Examples== | ||
This example outputs the debug message in the console. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function onClientDebugMessage(message, level, file, line) | ||
outputConsole(message) | |||
end | |||
addEventHandler("onClientDebugMessage", root, onClientDebugMessage) | |||
</syntaxhighlight> | |||
This example tells players that they missed a debug message, if they don't have debugscript enabled. | |||
<syntaxhighlight lang="lua"> | |||
function newDebug() | |||
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 32: | Line 54: | ||
===Client event functions=== | ===Client event functions=== | ||
{{Client_event_functions}} | {{Client_event_functions}} | ||
Latest revision as of 11:22, 11 April 2021
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.
Note: To prevent infinite loops, debug messages that occur inside the function that handles this event won't trigger this event, so you won't be able to rely on debug info to fix faulty code that is inside this function. Since build r14683 debug messages from outputDebugString and iprint will show up.
Parameters
string message, int level, string file, int line, int r, int g, int b
- 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
- r: Amount of red color (0-255)
- g: Amount of green color (0-255)
- b: Amount of blue color (0-255)
Source
The source of this event is the root element.
Examples
This example outputs the debug message in the console.
function onClientDebugMessage(message, level, file, line) outputConsole(message) end addEventHandler("onClientDebugMessage", root, onClientDebugMessage)
This example tells players that they missed a debug message, if they don't have debugscript enabled.
function newDebug() 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
- onClientChatMessage
- onClientConsole
- onClientDebugMessage
- onClientExplosion
- onClientFileDownloadComplete
- onClientHUDRender
- onClientMinimize
- onClientMTAFocusChange
- onClientPedsProcessed
- onClientPlayerNetworkStatus
- onClientPreRender
- onClientRender
- onClientRestore
- onClientTransferBoxProgressChange
- onClientTransferBoxVisibilityChange
- onClientWorldSound
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled