In-Game Logging (Any Advice to Improve?)

So I made this logging thing so my admins can check the logs right in-game. Only problem, because networking data has a limit of 65,535 B of data in one message I have to work with it. I am a sloppy Lua coder so my code isn’t exactly the most optimized. If anyone would like to fix it for me that’d be very nice. So my code first figures out how many lines there is so it knows how big to make the text entry, then it finds out if it’s too big, so if it’s too big it only sends the most recent logs and cuts down what it can. And anyone may use it, although I don’t know why you’d want to, but if any skilled lua coders, Garry, stumble across this post, Garry, and want to improve it, Garry, then please help me. And of coarse, if anyone does use it you have to make the actual logging thingy, although I still doubt anyone wants to use it.



// Server side.
function Logs( ply )
	if !ply:IsAdmin() then
		ChatMessage( ply, Color(255,100,100), "You must be an admin to view the logs!" )
		return ""
	end
	
	Lines = 0
	for k, v in string.gmatch(file.Read(LogsFile),"
") do
		Lines = Lines + 1
	end
	
	if Lines >= 600 then
		ReadLogs = string.Trim( file.Read(LogsFile), 40078, string.len(file.Read(LogsFile)) )
	else
		ReadLogs = file.Read(LogsFile)
	end
	
	net.Start( "LogsMenu" )
		net.WriteFloat( Lines*14 )
		net.WriteString( ReadLogs )
	net.Send( ply )
end




// Client side.
net.Receive( "LogsMenu", function()
	local Frame = vgui.Create( "DFrame" )
	Frame:SetSize(800,600)
	Frame:SetVisible(true)
	Frame:SetTitle( "Logs" )
	Frame:ShowCloseButton(true)
	Frame:Center()
	Frame:MakePopup()
	Frame.Paint = function()
		draw.RoundedBox(8,0,0,Frame:GetWide(),Frame:GetTall(),Color(0,0,0,200))
	end
	
	LogsBackground = vgui.Create( "DPanelList", Frame )
	LogsBackground:SetPos(15,30)
	LogsBackground:SetSize(770,550)
	LogsBackground:EnableVerticalScrollbar(true)
	LogsBackground.Paint = function()
		draw.RoundedBox(4,0,0,Frame:GetWide(),Frame:GetTall(),Color(0,0,0,150))
	end
	
	Logs = vgui.Create( "DTextEntry" )
	Logs:SetPos(0,0)
	Logs:SetSize(770,net.ReadFloat())
	Logs:SetEnterAllowed(false)
	Logs:SetMultiline(true)
	Logs:SetDrawBackground(false)
	Logs:SetTextColor(Color(255,255,255))
	Logs:SetText( net.ReadString() )
	Logs:SetEditable(false)
	Logs:SetHighlightColor(Color(0,150,0))
	LogsBackground:AddItem(Logs)
end)


it would help if you provided the code for the functions you call… like the call to ChatMessage is useless to anyone without the function declaration.

It would look like a family tree then. They can just use whatever their gamemode uses for chat functions.

http://www.facepunch.com/showthread.php?t=1230568