Ahmed Ly Posted October 6, 2016 Share Posted October 6, 2016 addEventHandler("onPlayerChat",root, function (message) if message ~= "" or message ~= " " then logs = fileOpen("texts/log.txt",false) name = getPlayerName(source) fileWrite(logs,""..name..":"..message.."") fileClose(logs) end end ) Link to comment
Mr.Loki Posted October 6, 2016 Share Posted October 6, 2016 if not fileExists( "texts/log.txt" ) then fileCreate( "texts/log.txt" ) end addEventHandler("onPlayerChat",root, function (message) if message ~= "" or message ~= " " then local logs = fileOpen("texts/log.txt",false) local name = getPlayerName(source) local text = fileRead(logs, 1000000) local t = getRealTime() local d,m,y,h,m,s = t.monthday,t.month,t.year,t.hour,t.minute,t.second local timestamp = "["..d.."/"..m.."/"..string.sub(y,2).."-"..h..":"..m..":"..s.."]" local text = timestamp.." "..name..": "..message.."\n" fileWrite(logs,text) fileFlush(logs) fileClose(logs) end end ) 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now