Jump to content

Different log files.


Recommended Posts

Posted

I only could do script that save chat and debug messages. See This:

addEventHandler("onResourceStart", resourceRoot, 
function() 
    local newFile = fileCreate("chatSay.log") 
    local newFile2 = fileCreate("debugMsg.log") 
end 
) 
  
addEventHandler("onPlayerChat", root, 
function(msg, msgType) 
local theFile = fileOpen("chatSay.log") 
    if (theFile) then 
        if msgType == 0 then 
            theType = " say: " 
        elseif msgType == 1 then 
            theType = " (/me) " 
        elseif msgType == 2 then 
            theType = " (Team-Say): " 
        end 
  
    local time = getRealTime() 
    local day = time.monthday 
    local month = time.month 
    local hour = time.hour 
    local minute = time.minute 
  
    local anterior = fileRead(theFile, 500) 
    fileWrite(theFile, "[ "..hour..":"..minute.." - "..day.."/"..month.." ] "..getPlayerName(source)..""..theType..""..msg.."\n") 
    fileClose(theFile) 
    else 
    outputDebugString("It is not possible to open the file 'chatSay.log'") 
    end 
end 
) 
  
addEventHandler("onDebugMessage", root, 
function(msg, lvl, file, line) 
local theFile = fileOpen("debugMsg.log") 
    if (theFile) then 
    if line == nil then line = "nil" end 
    if file == nil then file = "nil" end 
        if lvl == 0 then 
        theLevel = "( "..file..":"..line.." ): " 
        elseif lvl == 1 then 
        theLevel = "ERROR ( "..file..":"..line.." ): " 
        elseif lvl == 2 then 
        theLevel = "WARNING ( "..file..":"..line.." ): " 
        elseif lvl == 3 then 
        theLevel = "INFO ( "..file..":"..line.." ): " 
        end 
    local anterior = fileRead(theFile, 500) 
    fileWrite(theFile, theLevel..""..msg) 
    fileClose(theFile) 
    end 
end 
) 

Posted
Wrong section.

You can do this by scripting, but you won't be able to save the logs to "logs" folder but to the resource's folder.

It is possible using modules.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...