• (easy I guess) Chat log?
    8 replies, posted
Blah blah use ulx and put the server folders in your client lua autorun blah blah BULLSHIT. I want some log that logs EVERYTHING put through console, even if it's not visible to the player. I do this because it'd be nice to log fags and post ban requests.
[code] hook.Add("ShutDown" , "SaveLogs" , function() -- Because saving repeatedly lags if theLog then file.Write("Logs/"..string.Explode(os.date() , " ")[1]:gsub("/" , "_").."/"..string.Explode(" " , os.date())[2]..".txt" , theLog) end end ) hook.Add("OnPlayerChat" , "GetLog" , function(p , t) t1 = t:gsub("\n" , "\\n") t2 = t1:gsub("\b" , "\\b") t3 = t2:gsub("\t" , "\\b") -- Enter other escape characters in here if you want. text = t3 theLog = theLog.."\n".."[["string.Explode(" " , os.date())[2].. "]] "..p:Nick()..": "..text end ) [/code] Should work. There is alot more that can be logged that I can't be bothered writing atm :P Edit: You're wanting this serverside, right? Edit2: 'Ban requests' I'll change it :/
[QUOTE=|FlapJack|;17047459][code] hook.Add("ShutDown" , "SaveLogs" , function() -- Because saving repeatedly lags if theLog then file.Write("Logs/"..string.Explode(os.date() , " ")[1]:gsub("/" , "_").."/"..string.Explode(" " , os.date())[2]..".txt" , theLog) end end ) hook.Add("OnPlayerChat" , "GetLog" , function(p , t) t1 = t:gsub("\n" , "\\n") t2 = t1:gsub("\b" , "\\b") t3 = t2:gsub("\t" , "\\b") -- Enter other escape characters in here if you want. text = t3 theLog = theLog.."\n".."[["string.Explode(" " , os.date())[2].. "]] "..p:Nick()..": "..text end ) [/code] Should work. There is alot more that can be logged that I can't be bothered writing atm :P Edit: You're wanting this serverside, right? Edit2: 'Ban requests' I'll change it :/[/QUOTE] what? no clientside also, I want it COMPLETELY independent of any other addon
[QUOTE=Phoenixthehorse;17047612]what? no clientside also, I want it COMPLETELY independent of any other addon[/QUOTE] ... It is...
[QUOTE=|FlapJack|;17047687]... It is...[/QUOTE] just saying i've had some tards send me lua scripts that rely on 5 other 500000000000GB addons
It's a shame because what FlapJack coded, will only work if the client leaves/shuts down, or the server does. But If some one crashes the server or client, i'm pretty sure logs are lost.
[QUOTE=JSharpe;17048349]It's a shame because what FlapJack coded, will only work if the client leaves/shuts down, or the server does. But If some one crashes the server or client, i'm pretty sure logs are lost.[/QUOTE] lol fail no offense
ShutDown is also called on disconnection and changelevel. Unfortunately, the only way around it is by periodically (Using a timer) saving, or using the laggy method - reading and saving on chat. Yes, crashing will lose the logs :/
[url=http://www.garrysmod.org/downloads/?a=view&id=62574][img]http://www.garrysmod.org/img/?t=dll&id=62574[/img][/url] You need HLSW to see/use this thing.. but other than that its awesome.
Sorry, you need to Log In to post a reply to this thread.