ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server events
  3. onDebugMessage

Event

onDebugMessage

ServerChat and consoleIdentical to MTA:SA

A debug message appeared (an error, a warning or outputDebugString). Useful for collecting script errors in one place.

Handler

addEventHandler("onDebugMessage", root, function(message, level, file, line, r, g, b) ... end)

Parameters

messagestring
The message.
levelint
Level: 1 error, 2 warning, 3 info.
filestring
The file.
lineint
The line.
rint
Red colour.
gint
Green colour.
bint
Blue colour.

Source

source is root.

Example

addEventHandler("onDebugMessage", root, function(message, level, file, line)
    if level == 1 then
        local f = fileExists("bledy.log") and fileOpen("bledy.log") or fileCreate("bledy.log")
        fileSetPos(f, fileGetSize(f))
        fileWrite(f, ("%s:%s %s\n"):format(tostring(file), tostring(line), message))
        fileClose(f)
    end
end)

See also