Chalwk / HALO-SCRIPT-PROJECTS

:white_check_mark: Halo PC|CE - Add-ons for Phasor V2+ and SAPP :new_zealand:
Other
32 stars 13 forks source link

Console Log #89

Closed Dark3211 closed 4 years ago

Dark3211 commented 4 years ago

Will the script be for Halo PC, CE or BOTH?

What server extension are you using?

Will the script need to be map and/or gametype specific?

Script Details:

Save a log file (console.log) in the root folder.

Hello, I would like to know if it is possible to create a script that shows everything that is shown in the console (console log).

Example:

sv_name: SAPP V10.2.1 sv_rcon_password: 'password' true sv_maxplayers: 16 0 Loading SAPP ... Starting threads ... Searching for Halo functions ... Patching Halo's code for codecaves ... Loading commands ... 14 custom commands were loaded. Loading Lua scripts ... Loading settings ...

Example of Error:

OnScriptUnLoad >> Lua Error: attempt to call a nil value

Chalwk commented 4 years ago

Unfortunately, it's not possible to display certain start-up information; Which is most of it, actually. But I'll see what I can come up with.

Dark3211 commented 4 years ago

Ok, but it is possible to record the errors (shown in the console, if they have any) of all the scripts loaded by the server?

Chalwk commented 4 years ago

Due to a limitation with SAPP, the only thing you can do is copy/paste the below code into each individual script you have. Put this at the bottom of each script.

SAPP's OnError() function is raised every time there is an error but this is on a per-script basis.

This code snippet will save error logs to a file called errors.txt in the server root directory.

function OnError()
    local path = "errors.txt"
    local file = assert(io.open(path, "a+"))
    if (file ~= nil) then
        file:write(debug.traceback() .. " \n\n")
        io.close(file)
    end
end