addDebugHook | Multi Theft Auto: Wiki Skip to content

addDebugHook

Client-side
Server-side
Shared
Needs checking

This function was partially migrated from the old wiki. Please review manually:

  • Missing section: Callback parameters

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function allows tracing of MTA functions and events. It should only be used when debugging scripts as it may degrade script performance.

Syntax

addDebugHook ( )

Code Examples

server

This example will dump info about all triggered events:

function onPreEvent( sourceResource, eventName, eventSource, eventClient, luaFilename, luaLineNumber, ... )
local args = { ... }
local srctype = eventSource and getElementType(eventSource)
local resname = sourceResource and getResourceName(sourceResource)
local plrname = eventClient and getPlayerName(eventClient)
outputDebugString( "preEvent"
.. " " .. tostring(resname)
.. " " .. tostring(eventName)
.. " source:" .. tostring(srctype)
.. " player:" .. tostring(plrname)
.. " file:" .. tostring(luaFilename)
.. "(" .. tostring(luaLineNumber) .. ")"
.. " numArgs:" .. tostring(#args)
.. " arg1:" .. tostring(args[1])
)
end
addDebugHook( "preEvent", onPreEvent )